OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 165 } |
166 | 166 |
167 // Utility method to setup an additional stream to send and receive video. | 167 // Utility method to setup an additional stream to send and receive video. |
168 // Used to test send and recv between two streams. | 168 // Used to test send and recv between two streams. |
169 void SetUpSecondStream() { | 169 void SetUpSecondStream() { |
170 SetUpSecondStreamWithNoRecv(); | 170 SetUpSecondStreamWithNoRecv(); |
171 // Setup recv for second stream. | 171 // Setup recv for second stream. |
172 EXPECT_TRUE(channel_->AddRecvStream( | 172 EXPECT_TRUE(channel_->AddRecvStream( |
173 cricket::StreamParams::CreateLegacy(kSsrc + 2))); | 173 cricket::StreamParams::CreateLegacy(kSsrc + 2))); |
174 // Make the second renderer available for use by a new stream. | 174 // Make the second renderer available for use by a new stream. |
175 EXPECT_TRUE(channel_->SetRenderer(kSsrc + 2, &renderer2_)); | 175 EXPECT_TRUE(channel_->SetSink(kSsrc + 2, &renderer2_)); |
176 } | 176 } |
177 // Setup an additional stream just to send video. Defer add recv stream. | 177 // Setup an additional stream just to send video. Defer add recv stream. |
178 // This is required if you want to test unsignalled recv of video rtp packets. | 178 // This is required if you want to test unsignalled recv of video rtp packets. |
179 void SetUpSecondStreamWithNoRecv() { | 179 void SetUpSecondStreamWithNoRecv() { |
180 // SetUp() already added kSsrc make sure duplicate SSRCs cant be added. | 180 // SetUp() already added kSsrc make sure duplicate SSRCs cant be added. |
181 EXPECT_TRUE(channel_->AddRecvStream( | 181 EXPECT_TRUE(channel_->AddRecvStream( |
182 cricket::StreamParams::CreateLegacy(kSsrc))); | 182 cricket::StreamParams::CreateLegacy(kSsrc))); |
183 EXPECT_TRUE(channel_->SetRenderer(kSsrc, &renderer_)); | 183 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_)); |
184 EXPECT_FALSE(channel_->AddSendStream( | 184 EXPECT_FALSE(channel_->AddSendStream( |
185 cricket::StreamParams::CreateLegacy(kSsrc))); | 185 cricket::StreamParams::CreateLegacy(kSsrc))); |
186 EXPECT_TRUE(channel_->AddSendStream( | 186 EXPECT_TRUE(channel_->AddSendStream( |
187 cricket::StreamParams::CreateLegacy(kSsrc + 2))); | 187 cricket::StreamParams::CreateLegacy(kSsrc + 2))); |
188 // We dont add recv for the second stream. | 188 // We dont add recv for the second stream. |
189 | 189 |
190 // Setup the receive and renderer for second stream after send. | 190 // Setup the receive and renderer for second stream after send. |
191 video_capturer_2_.reset(CreateFakeVideoCapturer()); | 191 video_capturer_2_.reset(CreateFakeVideoCapturer()); |
192 cricket::VideoFormat format(640, 480, | 192 cricket::VideoFormat format(640, 480, |
193 cricket::VideoFormat::FpsToInterval(30), | 193 cricket::VideoFormat::FpsToInterval(30), |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 EXPECT_TRUE(SetSend(true)); | 435 EXPECT_TRUE(SetSend(true)); |
436 EXPECT_TRUE(SendFrame()); | 436 EXPECT_TRUE(SendFrame()); |
437 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); | 437 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); |
438 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); | 438 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); |
439 EXPECT_EQ(codec.id, GetPayloadType(p.get())); | 439 EXPECT_EQ(codec.id, GetPayloadType(p.get())); |
440 } | 440 } |
441 // Tests that we can send and receive frames. | 441 // Tests that we can send and receive frames. |
442 void SendAndReceive(const cricket::VideoCodec& codec) { | 442 void SendAndReceive(const cricket::VideoCodec& codec) { |
443 EXPECT_TRUE(SetOneCodec(codec)); | 443 EXPECT_TRUE(SetOneCodec(codec)); |
444 EXPECT_TRUE(SetSend(true)); | 444 EXPECT_TRUE(SetSend(true)); |
445 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 445 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
446 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 446 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
447 EXPECT_TRUE(SendFrame()); | 447 EXPECT_TRUE(SendFrame()); |
448 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); | 448 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); |
449 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); | 449 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); |
450 EXPECT_EQ(codec.id, GetPayloadType(p.get())); | 450 EXPECT_EQ(codec.id, GetPayloadType(p.get())); |
451 } | 451 } |
452 void SendReceiveManyAndGetStats(const cricket::VideoCodec& codec, | 452 void SendReceiveManyAndGetStats(const cricket::VideoCodec& codec, |
453 int duration_sec, int fps) { | 453 int duration_sec, int fps) { |
454 EXPECT_TRUE(SetOneCodec(codec)); | 454 EXPECT_TRUE(SetOneCodec(codec)); |
455 EXPECT_TRUE(SetSend(true)); | 455 EXPECT_TRUE(SetSend(true)); |
456 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 456 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
457 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 457 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
458 for (int i = 0; i < duration_sec; ++i) { | 458 for (int i = 0; i < duration_sec; ++i) { |
459 for (int frame = 1; frame <= fps; ++frame) { | 459 for (int frame = 1; frame <= fps; ++frame) { |
460 EXPECT_TRUE(WaitAndSendFrame(1000 / fps)); | 460 EXPECT_TRUE(WaitAndSendFrame(1000 / fps)); |
461 EXPECT_FRAME_WAIT(frame + i * fps, codec.width, codec.height, kTimeout); | 461 EXPECT_FRAME_WAIT(frame + i * fps, codec.width, codec.height, kTimeout); |
462 } | 462 } |
463 } | 463 } |
464 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); | 464 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); |
465 EXPECT_EQ(codec.id, GetPayloadType(p.get())); | 465 EXPECT_EQ(codec.id, GetPayloadType(p.get())); |
466 } | 466 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 EXPECT_TRUE(SetOneCodec(DefaultCodec())); | 526 EXPECT_TRUE(SetOneCodec(DefaultCodec())); |
527 cricket::VideoSendParameters parameters; | 527 cricket::VideoSendParameters parameters; |
528 parameters.codecs.push_back(DefaultCodec()); | 528 parameters.codecs.push_back(DefaultCodec()); |
529 parameters.options.conference_mode = rtc::Optional<bool>(true); | 529 parameters.options.conference_mode = rtc::Optional<bool>(true); |
530 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 530 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
531 EXPECT_TRUE(SetSend(true)); | 531 EXPECT_TRUE(SetSend(true)); |
532 EXPECT_TRUE(channel_->AddRecvStream( | 532 EXPECT_TRUE(channel_->AddRecvStream( |
533 cricket::StreamParams::CreateLegacy(1))); | 533 cricket::StreamParams::CreateLegacy(1))); |
534 EXPECT_TRUE(channel_->AddRecvStream( | 534 EXPECT_TRUE(channel_->AddRecvStream( |
535 cricket::StreamParams::CreateLegacy(2))); | 535 cricket::StreamParams::CreateLegacy(2))); |
536 EXPECT_TRUE(channel_->SetRenderer(1, &renderer1)); | 536 EXPECT_TRUE(channel_->SetSink(1, &renderer1)); |
537 EXPECT_TRUE(channel_->SetRenderer(2, &renderer2)); | 537 EXPECT_TRUE(channel_->SetSink(2, &renderer2)); |
538 EXPECT_EQ(0, renderer1.num_rendered_frames()); | 538 EXPECT_EQ(0, renderer1.num_rendered_frames()); |
539 EXPECT_EQ(0, renderer2.num_rendered_frames()); | 539 EXPECT_EQ(0, renderer2.num_rendered_frames()); |
540 std::vector<uint32_t> ssrcs; | 540 std::vector<uint32_t> ssrcs; |
541 ssrcs.push_back(1); | 541 ssrcs.push_back(1); |
542 ssrcs.push_back(2); | 542 ssrcs.push_back(2); |
543 network_interface_.SetConferenceMode(true, ssrcs); | 543 network_interface_.SetConferenceMode(true, ssrcs); |
544 EXPECT_TRUE(SendFrame()); | 544 EXPECT_TRUE(SendFrame()); |
545 EXPECT_FRAME_ON_RENDERER_WAIT( | 545 EXPECT_FRAME_ON_RENDERER_WAIT( |
546 renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout); | 546 renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout); |
547 EXPECT_FRAME_ON_RENDERER_WAIT( | 547 EXPECT_FRAME_ON_RENDERER_WAIT( |
(...skipping 26 matching lines...) Expand all Loading... |
574 void GetStatsMultipleSendStreams() { | 574 void GetStatsMultipleSendStreams() { |
575 // Normal setup; note that we set the SSRC explicitly to ensure that | 575 // Normal setup; note that we set the SSRC explicitly to ensure that |
576 // it will come first in the senders map. | 576 // it will come first in the senders map. |
577 EXPECT_TRUE(SetOneCodec(DefaultCodec())); | 577 EXPECT_TRUE(SetOneCodec(DefaultCodec())); |
578 cricket::VideoSendParameters parameters; | 578 cricket::VideoSendParameters parameters; |
579 parameters.codecs.push_back(DefaultCodec()); | 579 parameters.codecs.push_back(DefaultCodec()); |
580 parameters.options.conference_mode = rtc::Optional<bool>(true); | 580 parameters.options.conference_mode = rtc::Optional<bool>(true); |
581 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 581 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
582 EXPECT_TRUE(channel_->AddRecvStream( | 582 EXPECT_TRUE(channel_->AddRecvStream( |
583 cricket::StreamParams::CreateLegacy(kSsrc))); | 583 cricket::StreamParams::CreateLegacy(kSsrc))); |
584 EXPECT_TRUE(channel_->SetRenderer(kSsrc, &renderer_)); | 584 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_)); |
585 EXPECT_TRUE(SetSend(true)); | 585 EXPECT_TRUE(SetSend(true)); |
586 EXPECT_TRUE(SendFrame()); | 586 EXPECT_TRUE(SendFrame()); |
587 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); | 587 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); |
588 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); | 588 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); |
589 | 589 |
590 // Add an additional capturer, and hook up a renderer to receive it. | 590 // Add an additional capturer, and hook up a renderer to receive it. |
591 cricket::FakeVideoRenderer renderer2; | 591 cricket::FakeVideoRenderer renderer2; |
592 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( | 592 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( |
593 CreateFakeVideoCapturer()); | 593 CreateFakeVideoCapturer()); |
594 capturer->SetScreencast(true); | 594 capturer->SetScreencast(true); |
595 const int kTestWidth = 160; | 595 const int kTestWidth = 160; |
596 const int kTestHeight = 120; | 596 const int kTestHeight = 120; |
597 cricket::VideoFormat format(kTestWidth, kTestHeight, | 597 cricket::VideoFormat format(kTestWidth, kTestHeight, |
598 cricket::VideoFormat::FpsToInterval(5), | 598 cricket::VideoFormat::FpsToInterval(5), |
599 cricket::FOURCC_I420); | 599 cricket::FOURCC_I420); |
600 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format)); | 600 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format)); |
601 EXPECT_TRUE(channel_->AddSendStream( | 601 EXPECT_TRUE(channel_->AddSendStream( |
602 cricket::StreamParams::CreateLegacy(5678))); | 602 cricket::StreamParams::CreateLegacy(5678))); |
603 EXPECT_TRUE(channel_->SetCapturer(5678, capturer.get())); | 603 EXPECT_TRUE(channel_->SetCapturer(5678, capturer.get())); |
604 EXPECT_TRUE(channel_->AddRecvStream( | 604 EXPECT_TRUE(channel_->AddRecvStream( |
605 cricket::StreamParams::CreateLegacy(5678))); | 605 cricket::StreamParams::CreateLegacy(5678))); |
606 EXPECT_TRUE(channel_->SetRenderer(5678, &renderer2)); | 606 EXPECT_TRUE(channel_->SetSink(5678, &renderer2)); |
607 EXPECT_TRUE(capturer->CaptureCustomFrame( | 607 EXPECT_TRUE(capturer->CaptureCustomFrame( |
608 kTestWidth, kTestHeight, cricket::FOURCC_I420)); | 608 kTestWidth, kTestHeight, cricket::FOURCC_I420)); |
609 EXPECT_FRAME_ON_RENDERER_WAIT( | 609 EXPECT_FRAME_ON_RENDERER_WAIT( |
610 renderer2, 1, kTestWidth, kTestHeight, kTimeout); | 610 renderer2, 1, kTestWidth, kTestHeight, kTimeout); |
611 | 611 |
612 // Get stats, and make sure they are correct for two senders. We wait until | 612 // Get stats, and make sure they are correct for two senders. We wait until |
613 // the number of expected packets have been sent to avoid races where we | 613 // the number of expected packets have been sent to avoid races where we |
614 // check stats before it has been updated. | 614 // check stats before it has been updated. |
615 cricket::VideoMediaInfo info; | 615 cricket::VideoMediaInfo info; |
616 for (uint32_t i = 0; i < kTimeout; ++i) { | 616 for (uint32_t i = 0; i < kTimeout; ++i) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 // Packets are being paced out, so these can mismatch between the first and | 684 // Packets are being paced out, so these can mismatch between the first and |
685 // second call to NumRtpPackets until pending packets are paced out. | 685 // second call to NumRtpPackets until pending packets are paced out. |
686 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout); | 686 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout); |
687 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout); | 687 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout); |
688 EXPECT_EQ(1, NumSentSsrcs()); | 688 EXPECT_EQ(1, NumSentSsrcs()); |
689 EXPECT_EQ(0, NumRtpPackets(kSsrc)); | 689 EXPECT_EQ(0, NumRtpPackets(kSsrc)); |
690 EXPECT_EQ(0, NumRtpBytes(kSsrc)); | 690 EXPECT_EQ(0, NumRtpBytes(kSsrc)); |
691 } | 691 } |
692 // Test that we can set the default video renderer before and after | 692 // Test that we can set the default video renderer before and after |
693 // media is received. | 693 // media is received. |
694 void SetRenderer() { | 694 void SetSink() { |
695 uint8_t data1[] = { | 695 uint8_t data1[] = { |
696 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | 696 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
697 | 697 |
698 rtc::Buffer packet1(data1, sizeof(data1)); | 698 rtc::Buffer packet1(data1, sizeof(data1)); |
699 rtc::SetBE32(packet1.data() + 8, kSsrc); | 699 rtc::SetBE32(packet1.data() + 8, kSsrc); |
700 channel_->SetRenderer(kDefaultReceiveSsrc, NULL); | 700 channel_->SetSink(kDefaultReceiveSsrc, NULL); |
701 EXPECT_TRUE(SetDefaultCodec()); | 701 EXPECT_TRUE(SetDefaultCodec()); |
702 EXPECT_TRUE(SetSend(true)); | 702 EXPECT_TRUE(SetSend(true)); |
703 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 703 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
704 channel_->OnPacketReceived(&packet1, rtc::PacketTime()); | 704 channel_->OnPacketReceived(&packet1, rtc::PacketTime()); |
705 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 705 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
706 EXPECT_TRUE(SendFrame()); | 706 EXPECT_TRUE(SendFrame()); |
707 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); | 707 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); |
708 } | 708 } |
709 | 709 |
710 // Tests empty StreamParams is rejected. | 710 // Tests empty StreamParams is rejected. |
711 void RejectEmptyStreamParams() { | 711 void RejectEmptyStreamParams() { |
712 // Remove the send stream that was added during Setup. | 712 // Remove the send stream that was added during Setup. |
713 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); | 713 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); |
714 | 714 |
715 cricket::StreamParams empty; | 715 cricket::StreamParams empty; |
716 EXPECT_FALSE(channel_->AddSendStream(empty)); | 716 EXPECT_FALSE(channel_->AddSendStream(empty)); |
717 EXPECT_TRUE(channel_->AddSendStream( | 717 EXPECT_TRUE(channel_->AddSendStream( |
718 cricket::StreamParams::CreateLegacy(789u))); | 718 cricket::StreamParams::CreateLegacy(789u))); |
719 } | 719 } |
720 | 720 |
721 // Tests setting up and configuring a send stream. | 721 // Tests setting up and configuring a send stream. |
722 void AddRemoveSendStreams() { | 722 void AddRemoveSendStreams() { |
723 EXPECT_TRUE(SetOneCodec(DefaultCodec())); | 723 EXPECT_TRUE(SetOneCodec(DefaultCodec())); |
724 EXPECT_TRUE(SetSend(true)); | 724 EXPECT_TRUE(SetSend(true)); |
725 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 725 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
726 EXPECT_TRUE(SendFrame()); | 726 EXPECT_TRUE(SendFrame()); |
727 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); | 727 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); |
728 EXPECT_GT(NumRtpPackets(), 0); | 728 EXPECT_GT(NumRtpPackets(), 0); |
729 uint32_t ssrc = 0; | 729 uint32_t ssrc = 0; |
730 size_t last_packet = NumRtpPackets() - 1; | 730 size_t last_packet = NumRtpPackets() - 1; |
731 rtc::scoped_ptr<const rtc::Buffer> | 731 rtc::scoped_ptr<const rtc::Buffer> |
732 p(GetRtpPacket(static_cast<int>(last_packet))); | 732 p(GetRtpPacket(static_cast<int>(last_packet))); |
733 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); | 733 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); |
734 EXPECT_EQ(kSsrc, ssrc); | 734 EXPECT_EQ(kSsrc, ssrc); |
735 | 735 |
(...skipping 21 matching lines...) Expand all Loading... |
757 EXPECT_TRUE(SetDefaultCodec()); | 757 EXPECT_TRUE(SetDefaultCodec()); |
758 cricket::VideoSendParameters parameters; | 758 cricket::VideoSendParameters parameters; |
759 parameters.codecs.push_back(DefaultCodec()); | 759 parameters.codecs.push_back(DefaultCodec()); |
760 parameters.options.conference_mode = rtc::Optional<bool>(true); | 760 parameters.options.conference_mode = rtc::Optional<bool>(true); |
761 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 761 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
762 EXPECT_TRUE(SetSend(true)); | 762 EXPECT_TRUE(SetSend(true)); |
763 EXPECT_TRUE(channel_->AddRecvStream( | 763 EXPECT_TRUE(channel_->AddRecvStream( |
764 cricket::StreamParams::CreateLegacy(1))); | 764 cricket::StreamParams::CreateLegacy(1))); |
765 EXPECT_TRUE(channel_->AddRecvStream( | 765 EXPECT_TRUE(channel_->AddRecvStream( |
766 cricket::StreamParams::CreateLegacy(2))); | 766 cricket::StreamParams::CreateLegacy(2))); |
767 EXPECT_TRUE(channel_->SetRenderer(1, &renderer1)); | 767 EXPECT_TRUE(channel_->SetSink(1, &renderer1)); |
768 EXPECT_TRUE(channel_->SetRenderer(2, &renderer2)); | 768 EXPECT_TRUE(channel_->SetSink(2, &renderer2)); |
769 EXPECT_EQ(0, renderer1.num_rendered_frames()); | 769 EXPECT_EQ(0, renderer1.num_rendered_frames()); |
770 EXPECT_EQ(0, renderer2.num_rendered_frames()); | 770 EXPECT_EQ(0, renderer2.num_rendered_frames()); |
771 std::vector<uint32_t> ssrcs; | 771 std::vector<uint32_t> ssrcs; |
772 ssrcs.push_back(1); | 772 ssrcs.push_back(1); |
773 ssrcs.push_back(2); | 773 ssrcs.push_back(2); |
774 network_interface_.SetConferenceMode(true, ssrcs); | 774 network_interface_.SetConferenceMode(true, ssrcs); |
775 EXPECT_TRUE(SendFrame()); | 775 EXPECT_TRUE(SendFrame()); |
776 EXPECT_FRAME_ON_RENDERER_WAIT( | 776 EXPECT_FRAME_ON_RENDERER_WAIT( |
777 renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout); | 777 renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout); |
778 EXPECT_FRAME_ON_RENDERER_WAIT( | 778 EXPECT_FRAME_ON_RENDERER_WAIT( |
(...skipping 10 matching lines...) Expand all Loading... |
789 } | 789 } |
790 | 790 |
791 // Tests that we can add and remove capturers and frames are sent out properly | 791 // Tests that we can add and remove capturers and frames are sent out properly |
792 void AddRemoveCapturer() { | 792 void AddRemoveCapturer() { |
793 cricket::VideoCodec codec = DefaultCodec(); | 793 cricket::VideoCodec codec = DefaultCodec(); |
794 codec.width = 320; | 794 codec.width = 320; |
795 codec.height = 240; | 795 codec.height = 240; |
796 const int time_between_send = TimeBetweenSend(codec); | 796 const int time_between_send = TimeBetweenSend(codec); |
797 EXPECT_TRUE(SetOneCodec(codec)); | 797 EXPECT_TRUE(SetOneCodec(codec)); |
798 EXPECT_TRUE(SetSend(true)); | 798 EXPECT_TRUE(SetSend(true)); |
799 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 799 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
800 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 800 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
801 EXPECT_TRUE(SendFrame()); | 801 EXPECT_TRUE(SendFrame()); |
802 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); | 802 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); |
803 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( | 803 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( |
804 CreateFakeVideoCapturer()); | 804 CreateFakeVideoCapturer()); |
805 capturer->SetScreencast(true); | 805 capturer->SetScreencast(true); |
806 cricket::VideoFormat format(480, 360, | 806 cricket::VideoFormat format(480, 360, |
807 cricket::VideoFormat::FpsToInterval(30), | 807 cricket::VideoFormat::FpsToInterval(30), |
808 cricket::FOURCC_I420); | 808 cricket::FOURCC_I420); |
809 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format)); | 809 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 EXPECT_TRUE(capturer->CaptureCustomFrame(format.width, format.height, | 850 EXPECT_TRUE(capturer->CaptureCustomFrame(format.width, format.height, |
851 cricket::FOURCC_I420)); | 851 cricket::FOURCC_I420)); |
852 } | 852 } |
853 } | 853 } |
854 | 854 |
855 // Tests that if RemoveCapturer is called without a capturer ever being | 855 // Tests that if RemoveCapturer is called without a capturer ever being |
856 // added, the plugin shouldn't crash (and no black frame should be sent). | 856 // added, the plugin shouldn't crash (and no black frame should be sent). |
857 void RemoveCapturerWithoutAdd() { | 857 void RemoveCapturerWithoutAdd() { |
858 EXPECT_TRUE(SetOneCodec(DefaultCodec())); | 858 EXPECT_TRUE(SetOneCodec(DefaultCodec())); |
859 EXPECT_TRUE(SetSend(true)); | 859 EXPECT_TRUE(SetSend(true)); |
860 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 860 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
861 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 861 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
862 EXPECT_TRUE(SendFrame()); | 862 EXPECT_TRUE(SendFrame()); |
863 EXPECT_FRAME_WAIT(1, 640, 400, kTimeout); | 863 EXPECT_FRAME_WAIT(1, 640, 400, kTimeout); |
864 // Wait for one frame so they don't get dropped because we send frames too | 864 // Wait for one frame so they don't get dropped because we send frames too |
865 // tightly. | 865 // tightly. |
866 rtc::Thread::Current()->ProcessMessages(30); | 866 rtc::Thread::Current()->ProcessMessages(30); |
867 // Remove the capturer. | 867 // Remove the capturer. |
868 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); | 868 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); |
869 // Wait for one black frame for removing the capturer. | 869 // Wait for one black frame for removing the capturer. |
870 EXPECT_FRAME_WAIT(2, 640, 400, kTimeout); | 870 EXPECT_FRAME_WAIT(2, 640, 400, kTimeout); |
871 | 871 |
872 // No capturer was added, so this RemoveCapturer should | 872 // No capturer was added, so this RemoveCapturer should |
873 // fail. | 873 // fail. |
874 EXPECT_FALSE(channel_->SetCapturer(kSsrc, NULL)); | 874 EXPECT_FALSE(channel_->SetCapturer(kSsrc, NULL)); |
875 rtc::Thread::Current()->ProcessMessages(300); | 875 rtc::Thread::Current()->ProcessMessages(300); |
876 // Verify no more frames were sent. | 876 // Verify no more frames were sent. |
877 EXPECT_EQ(2, renderer_.num_rendered_frames()); | 877 EXPECT_EQ(2, renderer_.num_rendered_frames()); |
878 } | 878 } |
879 | 879 |
880 // Tests that we can add and remove capturer as unique sources. | 880 // Tests that we can add and remove capturer as unique sources. |
881 void AddRemoveCapturerMultipleSources() { | 881 void AddRemoveCapturerMultipleSources() { |
882 // WebRTC implementation will drop frames if pushed to quickly. Wait the | 882 // WebRTC implementation will drop frames if pushed to quickly. Wait the |
883 // interval time to avoid that. | 883 // interval time to avoid that. |
884 // WebRTC implementation will drop frames if pushed to quickly. Wait the | 884 // WebRTC implementation will drop frames if pushed to quickly. Wait the |
885 // interval time to avoid that. | 885 // interval time to avoid that. |
886 // Set up the stream associated with the engine. | 886 // Set up the stream associated with the engine. |
887 EXPECT_TRUE(channel_->AddRecvStream( | 887 EXPECT_TRUE(channel_->AddRecvStream( |
888 cricket::StreamParams::CreateLegacy(kSsrc))); | 888 cricket::StreamParams::CreateLegacy(kSsrc))); |
889 EXPECT_TRUE(channel_->SetRenderer(kSsrc, &renderer_)); | 889 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_)); |
890 cricket::VideoFormat capture_format; // default format | 890 cricket::VideoFormat capture_format; // default format |
891 capture_format.interval = cricket::VideoFormat::FpsToInterval(30); | 891 capture_format.interval = cricket::VideoFormat::FpsToInterval(30); |
892 // Set up additional stream 1. | 892 // Set up additional stream 1. |
893 cricket::FakeVideoRenderer renderer1; | 893 cricket::FakeVideoRenderer renderer1; |
894 EXPECT_FALSE(channel_->SetRenderer(1, &renderer1)); | 894 EXPECT_FALSE(channel_->SetSink(1, &renderer1)); |
895 EXPECT_TRUE(channel_->AddRecvStream( | 895 EXPECT_TRUE(channel_->AddRecvStream( |
896 cricket::StreamParams::CreateLegacy(1))); | 896 cricket::StreamParams::CreateLegacy(1))); |
897 EXPECT_TRUE(channel_->SetRenderer(1, &renderer1)); | 897 EXPECT_TRUE(channel_->SetSink(1, &renderer1)); |
898 EXPECT_TRUE(channel_->AddSendStream( | 898 EXPECT_TRUE(channel_->AddSendStream( |
899 cricket::StreamParams::CreateLegacy(1))); | 899 cricket::StreamParams::CreateLegacy(1))); |
900 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer1( | 900 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer1( |
901 CreateFakeVideoCapturer()); | 901 CreateFakeVideoCapturer()); |
902 capturer1->SetScreencast(true); | 902 capturer1->SetScreencast(true); |
903 EXPECT_EQ(cricket::CS_RUNNING, capturer1->Start(capture_format)); | 903 EXPECT_EQ(cricket::CS_RUNNING, capturer1->Start(capture_format)); |
904 // Set up additional stream 2. | 904 // Set up additional stream 2. |
905 cricket::FakeVideoRenderer renderer2; | 905 cricket::FakeVideoRenderer renderer2; |
906 EXPECT_FALSE(channel_->SetRenderer(2, &renderer2)); | 906 EXPECT_FALSE(channel_->SetSink(2, &renderer2)); |
907 EXPECT_TRUE(channel_->AddRecvStream( | 907 EXPECT_TRUE(channel_->AddRecvStream( |
908 cricket::StreamParams::CreateLegacy(2))); | 908 cricket::StreamParams::CreateLegacy(2))); |
909 EXPECT_TRUE(channel_->SetRenderer(2, &renderer2)); | 909 EXPECT_TRUE(channel_->SetSink(2, &renderer2)); |
910 EXPECT_TRUE(channel_->AddSendStream( | 910 EXPECT_TRUE(channel_->AddSendStream( |
911 cricket::StreamParams::CreateLegacy(2))); | 911 cricket::StreamParams::CreateLegacy(2))); |
912 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer2( | 912 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer2( |
913 CreateFakeVideoCapturer()); | 913 CreateFakeVideoCapturer()); |
914 capturer2->SetScreencast(true); | 914 capturer2->SetScreencast(true); |
915 EXPECT_EQ(cricket::CS_RUNNING, capturer2->Start(capture_format)); | 915 EXPECT_EQ(cricket::CS_RUNNING, capturer2->Start(capture_format)); |
916 // State for all the streams. | 916 // State for all the streams. |
917 EXPECT_TRUE(SetOneCodec(DefaultCodec())); | 917 EXPECT_TRUE(SetOneCodec(DefaultCodec())); |
918 // A limitation in the lmi implementation requires that SetCapturer() is | 918 // A limitation in the lmi implementation requires that SetCapturer() is |
919 // called after SetOneCodec(). | 919 // called after SetOneCodec(). |
(...skipping 29 matching lines...) Expand all Loading... |
949 const int kScaledWidth = 20; | 949 const int kScaledWidth = 20; |
950 const int kScaledHeight = 2500; | 950 const int kScaledHeight = 2500; |
951 | 951 |
952 cricket::VideoCodec codec(DefaultCodec()); | 952 cricket::VideoCodec codec(DefaultCodec()); |
953 EXPECT_TRUE(SetOneCodec(codec)); | 953 EXPECT_TRUE(SetOneCodec(codec)); |
954 EXPECT_TRUE(SetSend(true)); | 954 EXPECT_TRUE(SetSend(true)); |
955 | 955 |
956 cricket::FakeVideoRenderer renderer; | 956 cricket::FakeVideoRenderer renderer; |
957 EXPECT_TRUE(channel_->AddRecvStream( | 957 EXPECT_TRUE(channel_->AddRecvStream( |
958 cricket::StreamParams::CreateLegacy(kSsrc))); | 958 cricket::StreamParams::CreateLegacy(kSsrc))); |
959 EXPECT_TRUE(channel_->SetRenderer(kSsrc, &renderer)); | 959 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer)); |
960 EXPECT_EQ(0, renderer.num_rendered_frames()); | 960 EXPECT_EQ(0, renderer.num_rendered_frames()); |
961 | 961 |
962 EXPECT_TRUE(SendFrame()); | 962 EXPECT_TRUE(SendFrame()); |
963 EXPECT_GT_FRAME_ON_RENDERER_WAIT( | 963 EXPECT_GT_FRAME_ON_RENDERER_WAIT( |
964 renderer, 1, codec.width, codec.height, kTimeout); | 964 renderer, 1, codec.width, codec.height, kTimeout); |
965 | 965 |
966 // Registering an external capturer is currently the same as screen casting | 966 // Registering an external capturer is currently the same as screen casting |
967 // (update the test when this changes). | 967 // (update the test when this changes). |
968 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( | 968 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( |
969 CreateFakeVideoCapturer()); | 969 CreateFakeVideoCapturer()); |
970 capturer->SetScreencast(true); | 970 capturer->SetScreencast(true); |
971 const std::vector<cricket::VideoFormat>* formats = | 971 const std::vector<cricket::VideoFormat>* formats = |
972 capturer->GetSupportedFormats(); | 972 capturer->GetSupportedFormats(); |
973 cricket::VideoFormat capture_format = (*formats)[0]; | 973 cricket::VideoFormat capture_format = (*formats)[0]; |
974 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(capture_format)); | 974 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(capture_format)); |
975 // Capture frame to not get same frame timestamps as previous capturer. | 975 // Capture frame to not get same frame timestamps as previous capturer. |
976 capturer->CaptureFrame(); | 976 capturer->CaptureFrame(); |
977 EXPECT_TRUE(channel_->SetCapturer(kSsrc, capturer.get())); | 977 EXPECT_TRUE(channel_->SetCapturer(kSsrc, capturer.get())); |
978 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30)); | 978 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30)); |
979 EXPECT_TRUE(capturer->CaptureCustomFrame(kWidth, kHeight, | 979 EXPECT_TRUE(capturer->CaptureCustomFrame(kWidth, kHeight, |
980 cricket::FOURCC_ARGB)); | 980 cricket::FOURCC_ARGB)); |
981 EXPECT_GT_FRAME_ON_RENDERER_WAIT( | 981 EXPECT_GT_FRAME_ON_RENDERER_WAIT( |
982 renderer, 2, kScaledWidth, kScaledHeight, kTimeout); | 982 renderer, 2, kScaledWidth, kScaledHeight, kTimeout); |
983 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); | 983 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); |
984 } | 984 } |
985 | 985 |
986 // Tests that we can adapt video resolution with 16:10 aspect ratio properly. | 986 // Tests that we can adapt video resolution with 16:10 aspect ratio properly. |
987 void AdaptResolution16x10() { | 987 void AdaptResolution16x10() { |
988 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 988 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
989 cricket::VideoCodec codec(DefaultCodec()); | 989 cricket::VideoCodec codec(DefaultCodec()); |
990 codec.width = 640; | 990 codec.width = 640; |
991 codec.height = 400; | 991 codec.height = 400; |
992 SendAndReceive(codec); | 992 SendAndReceive(codec); |
993 codec.width /= 2; | 993 codec.width /= 2; |
994 codec.height /= 2; | 994 codec.height /= 2; |
995 // Adapt the resolution. | 995 // Adapt the resolution. |
996 EXPECT_TRUE(SetOneCodec(codec)); | 996 EXPECT_TRUE(SetOneCodec(codec)); |
997 EXPECT_TRUE(WaitAndSendFrame(30)); | 997 EXPECT_TRUE(WaitAndSendFrame(30)); |
998 EXPECT_FRAME_WAIT(2, codec.width, codec.height, kTimeout); | 998 EXPECT_FRAME_WAIT(2, codec.width, codec.height, kTimeout); |
999 } | 999 } |
1000 // Tests that we can adapt video resolution with 4:3 aspect ratio properly. | 1000 // Tests that we can adapt video resolution with 4:3 aspect ratio properly. |
1001 void AdaptResolution4x3() { | 1001 void AdaptResolution4x3() { |
1002 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 1002 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
1003 cricket::VideoCodec codec(DefaultCodec()); | 1003 cricket::VideoCodec codec(DefaultCodec()); |
1004 codec.width = 640; | 1004 codec.width = 640; |
1005 codec.height = 400; | 1005 codec.height = 400; |
1006 SendAndReceive(codec); | 1006 SendAndReceive(codec); |
1007 codec.width /= 2; | 1007 codec.width /= 2; |
1008 codec.height /= 2; | 1008 codec.height /= 2; |
1009 // Adapt the resolution. | 1009 // Adapt the resolution. |
1010 EXPECT_TRUE(SetOneCodec(codec)); | 1010 EXPECT_TRUE(SetOneCodec(codec)); |
1011 EXPECT_TRUE(WaitAndSendFrame(30)); | 1011 EXPECT_TRUE(WaitAndSendFrame(30)); |
1012 EXPECT_FRAME_WAIT(2, codec.width, codec.height, kTimeout); | 1012 EXPECT_FRAME_WAIT(2, codec.width, codec.height, kTimeout); |
1013 } | 1013 } |
1014 // Tests that we can drop all frames properly. | 1014 // Tests that we can drop all frames properly. |
1015 void AdaptDropAllFrames() { | 1015 void AdaptDropAllFrames() { |
1016 // Set the channel codec's resolution to 0, which will require the adapter | 1016 // Set the channel codec's resolution to 0, which will require the adapter |
1017 // to drop all frames. | 1017 // to drop all frames. |
1018 cricket::VideoCodec codec(DefaultCodec()); | 1018 cricket::VideoCodec codec(DefaultCodec()); |
1019 codec.width = codec.height = codec.framerate = 0; | 1019 codec.width = codec.height = codec.framerate = 0; |
1020 EXPECT_TRUE(SetOneCodec(codec)); | 1020 EXPECT_TRUE(SetOneCodec(codec)); |
1021 EXPECT_TRUE(SetSend(true)); | 1021 EXPECT_TRUE(SetSend(true)); |
1022 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 1022 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
1023 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 1023 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
1024 EXPECT_TRUE(SendFrame()); | 1024 EXPECT_TRUE(SendFrame()); |
1025 EXPECT_TRUE(SendFrame()); | 1025 EXPECT_TRUE(SendFrame()); |
1026 rtc::Thread::Current()->ProcessMessages(500); | 1026 rtc::Thread::Current()->ProcessMessages(500); |
1027 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 1027 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
1028 } | 1028 } |
1029 // Tests that we can reduce the frame rate on demand properly. | 1029 // Tests that we can reduce the frame rate on demand properly. |
1030 // TODO(fbarchard): This test is flakey on pulse. Fix and re-enable | 1030 // TODO(fbarchard): This test is flakey on pulse. Fix and re-enable |
1031 void AdaptFramerate() { | 1031 void AdaptFramerate() { |
1032 cricket::VideoCodec codec(DefaultCodec()); | 1032 cricket::VideoCodec codec(DefaultCodec()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 frame_count += 2; | 1072 frame_count += 2; |
1073 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); | 1073 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); |
1074 } | 1074 } |
1075 // Tests that adapted frames won't be upscaled to a higher resolution. | 1075 // Tests that adapted frames won't be upscaled to a higher resolution. |
1076 void SendsLowerResolutionOnSmallerFrames() { | 1076 void SendsLowerResolutionOnSmallerFrames() { |
1077 cricket::VideoCodec codec = DefaultCodec(); | 1077 cricket::VideoCodec codec = DefaultCodec(); |
1078 codec.width = 320; | 1078 codec.width = 320; |
1079 codec.height = 240; | 1079 codec.height = 240; |
1080 EXPECT_TRUE(SetOneCodec(codec)); | 1080 EXPECT_TRUE(SetOneCodec(codec)); |
1081 EXPECT_TRUE(SetSend(true)); | 1081 EXPECT_TRUE(SetSend(true)); |
1082 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 1082 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
1083 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 1083 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
1084 EXPECT_TRUE(SendFrame()); | 1084 EXPECT_TRUE(SendFrame()); |
1085 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); | 1085 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); |
1086 | 1086 |
1087 // Check that we send smaller frames at the new resolution. | 1087 // Check that we send smaller frames at the new resolution. |
1088 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(33)); | 1088 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(33)); |
1089 EXPECT_TRUE(video_capturer_->CaptureCustomFrame( | 1089 EXPECT_TRUE(video_capturer_->CaptureCustomFrame( |
1090 codec.width / 2, codec.height / 2, cricket::FOURCC_I420)); | 1090 codec.width / 2, codec.height / 2, cricket::FOURCC_I420)); |
1091 EXPECT_FRAME_WAIT(2, codec.width / 2, codec.height / 2, kTimeout); | 1091 EXPECT_FRAME_WAIT(2, codec.width / 2, codec.height / 2, kTimeout); |
1092 } | 1092 } |
1093 | 1093 |
1094 // Tests that we can mute and unmute the channel properly. | 1094 // Tests that we can mute and unmute the channel properly. |
1095 void MuteStream() { | 1095 void MuteStream() { |
1096 EXPECT_TRUE(SetDefaultCodec()); | 1096 EXPECT_TRUE(SetDefaultCodec()); |
1097 cricket::FakeVideoCapturer video_capturer; | 1097 cricket::FakeVideoCapturer video_capturer; |
1098 video_capturer.Start( | 1098 video_capturer.Start( |
1099 cricket::VideoFormat( | 1099 cricket::VideoFormat( |
1100 640, 480, | 1100 640, 480, |
1101 cricket::VideoFormat::FpsToInterval(30), | 1101 cricket::VideoFormat::FpsToInterval(30), |
1102 cricket::FOURCC_I420)); | 1102 cricket::FOURCC_I420)); |
1103 EXPECT_TRUE(channel_->SetCapturer(kSsrc, &video_capturer)); | 1103 EXPECT_TRUE(channel_->SetCapturer(kSsrc, &video_capturer)); |
1104 EXPECT_TRUE(SetSend(true)); | 1104 EXPECT_TRUE(SetSend(true)); |
1105 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 1105 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
1106 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 1106 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
1107 // Mute the channel and expect black output frame. | 1107 // Mute the channel and expect black output frame. |
1108 int frame_count = 0; | 1108 int frame_count = 0; |
1109 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr)); | 1109 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr)); |
1110 EXPECT_TRUE(video_capturer.CaptureFrame()); | 1110 EXPECT_TRUE(video_capturer.CaptureFrame()); |
1111 ++frame_count; | 1111 ++frame_count; |
1112 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); | 1112 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); |
1113 EXPECT_TRUE(renderer_.black_frame()); | 1113 EXPECT_TRUE(renderer_.black_frame()); |
1114 // Unmute the channel and expect non-black output frame. | 1114 // Unmute the channel and expect non-black output frame. |
1115 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr)); | 1115 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr)); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc()); | 1189 EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc()); |
1190 uint32_t new_ssrc = kSsrc + 100; | 1190 uint32_t new_ssrc = kSsrc + 100; |
1191 EXPECT_TRUE(channel_->AddSendStream( | 1191 EXPECT_TRUE(channel_->AddSendStream( |
1192 cricket::StreamParams::CreateLegacy(new_ssrc))); | 1192 cricket::StreamParams::CreateLegacy(new_ssrc))); |
1193 // Re-use default channel. | 1193 // Re-use default channel. |
1194 EXPECT_EQ(new_ssrc, channel_->GetDefaultSendChannelSsrc()); | 1194 EXPECT_EQ(new_ssrc, channel_->GetDefaultSendChannelSsrc()); |
1195 EXPECT_FALSE(channel_->AddSendStream( | 1195 EXPECT_FALSE(channel_->AddSendStream( |
1196 cricket::StreamParams::CreateLegacy(new_ssrc))); | 1196 cricket::StreamParams::CreateLegacy(new_ssrc))); |
1197 EXPECT_TRUE(channel_->AddRecvStream( | 1197 EXPECT_TRUE(channel_->AddRecvStream( |
1198 cricket::StreamParams::CreateLegacy(new_ssrc))); | 1198 cricket::StreamParams::CreateLegacy(new_ssrc))); |
1199 EXPECT_TRUE(channel_->SetRenderer(new_ssrc, &renderer_)); | 1199 EXPECT_TRUE(channel_->SetSink(new_ssrc, &renderer_)); |
1200 EXPECT_FALSE(channel_->AddRecvStream( | 1200 EXPECT_FALSE(channel_->AddRecvStream( |
1201 cricket::StreamParams::CreateLegacy(new_ssrc))); | 1201 cricket::StreamParams::CreateLegacy(new_ssrc))); |
1202 | 1202 |
1203 EXPECT_TRUE(channel_->SetCapturer(new_ssrc, video_capturer_.get())); | 1203 EXPECT_TRUE(channel_->SetCapturer(new_ssrc, video_capturer_.get())); |
1204 | 1204 |
1205 SendAndReceive(codec); | 1205 SendAndReceive(codec); |
1206 EXPECT_TRUE(channel_->RemoveSendStream(new_ssrc)); | 1206 EXPECT_TRUE(channel_->RemoveSendStream(new_ssrc)); |
1207 EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc()); | 1207 EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc()); |
1208 } | 1208 } |
1209 | 1209 |
1210 const rtc::scoped_ptr<webrtc::Call> call_; | 1210 const rtc::scoped_ptr<webrtc::Call> call_; |
1211 VideoEngineOverride<E> engine_; | 1211 VideoEngineOverride<E> engine_; |
1212 rtc::scoped_ptr<cricket::FakeVideoCapturer> video_capturer_; | 1212 rtc::scoped_ptr<cricket::FakeVideoCapturer> video_capturer_; |
1213 rtc::scoped_ptr<cricket::FakeVideoCapturer> video_capturer_2_; | 1213 rtc::scoped_ptr<cricket::FakeVideoCapturer> video_capturer_2_; |
1214 rtc::scoped_ptr<C> channel_; | 1214 rtc::scoped_ptr<C> channel_; |
1215 cricket::FakeNetworkInterface network_interface_; | 1215 cricket::FakeNetworkInterface network_interface_; |
1216 cricket::FakeVideoRenderer renderer_; | 1216 cricket::FakeVideoRenderer renderer_; |
1217 cricket::VideoMediaChannel::Error media_error_; | 1217 cricket::VideoMediaChannel::Error media_error_; |
1218 | 1218 |
1219 // Used by test cases where 2 streams are run on the same channel. | 1219 // Used by test cases where 2 streams are run on the same channel. |
1220 cricket::FakeVideoRenderer renderer2_; | 1220 cricket::FakeVideoRenderer renderer2_; |
1221 }; | 1221 }; |
1222 | 1222 |
1223 #endif // TALK_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT | 1223 #endif // TALK_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT |
OLD | NEW |