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

Side by Side Diff: webrtc/media/base/videoengine_unittest.h

Issue 1728503002: Replace scoped_ptr with unique_ptr in webrtc/media/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@up1
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/media/base/videocapturer.cc ('k') | webrtc/media/base/videoframe_unittest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ // NOLINT 11 #ifndef WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ // NOLINT
12 #define WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ 12 #define WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_
13 13
14 #include <memory>
14 #include <string> 15 #include <string>
15 #include <vector> 16 #include <vector>
16 17
17 #include "webrtc/base/bytebuffer.h" 18 #include "webrtc/base/bytebuffer.h"
18 #include "webrtc/base/gunit.h" 19 #include "webrtc/base/gunit.h"
19 #include "webrtc/base/timeutils.h" 20 #include "webrtc/base/timeutils.h"
20 #include "webrtc/call.h" 21 #include "webrtc/call.h"
21 #include "webrtc/media/base/fakenetworkinterface.h" 22 #include "webrtc/media/base/fakenetworkinterface.h"
22 #include "webrtc/media/base/fakevideocapturer.h" 23 #include "webrtc/media/base/fakevideocapturer.h"
23 #include "webrtc/media/base/fakevideorenderer.h" 24 #include "webrtc/media/base/fakevideorenderer.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 } 332 }
332 return true; 333 return true;
333 } 334 }
334 335
335 // Parse all RTCP packet, from start_index to stop_index, and count how many 336 // Parse all RTCP packet, from start_index to stop_index, and count how many
336 // FIR (PT=206 and FMT=4 according to RFC 5104). If successful, set the count 337 // FIR (PT=206 and FMT=4 according to RFC 5104). If successful, set the count
337 // and return true. 338 // and return true.
338 bool CountRtcpFir(int start_index, int stop_index, int* fir_count) { 339 bool CountRtcpFir(int start_index, int stop_index, int* fir_count) {
339 int count = 0; 340 int count = 0;
340 for (int i = start_index; i < stop_index; ++i) { 341 for (int i = start_index; i < stop_index; ++i) {
341 rtc::scoped_ptr<const rtc::Buffer> p(GetRtcpPacket(i)); 342 std::unique_ptr<const rtc::Buffer> p(GetRtcpPacket(i));
342 rtc::ByteBuffer buf(*p); 343 rtc::ByteBuffer buf(*p);
343 size_t total_len = 0; 344 size_t total_len = 0;
344 // The packet may be a compound RTCP packet. 345 // The packet may be a compound RTCP packet.
345 while (total_len < p->size()) { 346 while (total_len < p->size()) {
346 // Read FMT, type and length. 347 // Read FMT, type and length.
347 uint8_t fmt = 0; 348 uint8_t fmt = 0;
348 uint8_t type = 0; 349 uint8_t type = 0;
349 uint16_t length = 0; 350 uint16_t length = 0;
350 if (!buf.ReadUInt8(&fmt)) return false; 351 if (!buf.ReadUInt8(&fmt)) return false;
351 fmt &= 0x1F; 352 fmt &= 0x1F;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 EXPECT_TRUE(SetSend(true)); 397 EXPECT_TRUE(SetSend(true));
397 EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size()); 398 EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size());
398 EXPECT_EQ(64 * 1024, network_interface_.recvbuf_size()); 399 EXPECT_EQ(64 * 1024, network_interface_.recvbuf_size());
399 } 400 }
400 // Tests that we can send frames and the right payload type is used. 401 // Tests that we can send frames and the right payload type is used.
401 void Send(const cricket::VideoCodec& codec) { 402 void Send(const cricket::VideoCodec& codec) {
402 EXPECT_TRUE(SetOneCodec(codec)); 403 EXPECT_TRUE(SetOneCodec(codec));
403 EXPECT_TRUE(SetSend(true)); 404 EXPECT_TRUE(SetSend(true));
404 EXPECT_TRUE(SendFrame()); 405 EXPECT_TRUE(SendFrame());
405 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); 406 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
406 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); 407 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
407 EXPECT_EQ(codec.id, GetPayloadType(p.get())); 408 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
408 } 409 }
409 // Tests that we can send and receive frames. 410 // Tests that we can send and receive frames.
410 void SendAndReceive(const cricket::VideoCodec& codec) { 411 void SendAndReceive(const cricket::VideoCodec& codec) {
411 EXPECT_TRUE(SetOneCodec(codec)); 412 EXPECT_TRUE(SetOneCodec(codec));
412 EXPECT_TRUE(SetSend(true)); 413 EXPECT_TRUE(SetSend(true));
413 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); 414 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
414 EXPECT_EQ(0, renderer_.num_rendered_frames()); 415 EXPECT_EQ(0, renderer_.num_rendered_frames());
415 EXPECT_TRUE(SendFrame()); 416 EXPECT_TRUE(SendFrame());
416 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); 417 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
417 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); 418 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
418 EXPECT_EQ(codec.id, GetPayloadType(p.get())); 419 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
419 } 420 }
420 void SendReceiveManyAndGetStats(const cricket::VideoCodec& codec, 421 void SendReceiveManyAndGetStats(const cricket::VideoCodec& codec,
421 int duration_sec, int fps) { 422 int duration_sec, int fps) {
422 EXPECT_TRUE(SetOneCodec(codec)); 423 EXPECT_TRUE(SetOneCodec(codec));
423 EXPECT_TRUE(SetSend(true)); 424 EXPECT_TRUE(SetSend(true));
424 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); 425 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
425 EXPECT_EQ(0, renderer_.num_rendered_frames()); 426 EXPECT_EQ(0, renderer_.num_rendered_frames());
426 for (int i = 0; i < duration_sec; ++i) { 427 for (int i = 0; i < duration_sec; ++i) {
427 for (int frame = 1; frame <= fps; ++frame) { 428 for (int frame = 1; frame <= fps; ++frame) {
428 EXPECT_TRUE(WaitAndSendFrame(1000 / fps)); 429 EXPECT_TRUE(WaitAndSendFrame(1000 / fps));
429 EXPECT_FRAME_WAIT(frame + i * fps, codec.width, codec.height, kTimeout); 430 EXPECT_FRAME_WAIT(frame + i * fps, codec.width, codec.height, kTimeout);
430 } 431 }
431 } 432 }
432 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); 433 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
433 EXPECT_EQ(codec.id, GetPayloadType(p.get())); 434 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
434 } 435 }
435 436
436 // Test that stats work properly for a 1-1 call. 437 // Test that stats work properly for a 1-1 call.
437 void GetStats() { 438 void GetStats() {
438 const int kDurationSec = 3; 439 const int kDurationSec = 3;
439 const int kFps = 10; 440 const int kFps = 10;
440 SendReceiveManyAndGetStats(DefaultCodec(), kDurationSec, kFps); 441 SendReceiveManyAndGetStats(DefaultCodec(), kDurationSec, kFps);
441 442
442 cricket::VideoMediaInfo info; 443 cricket::VideoMediaInfo info;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 EXPECT_TRUE(channel_->AddRecvStream( 551 EXPECT_TRUE(channel_->AddRecvStream(
551 cricket::StreamParams::CreateLegacy(kSsrc))); 552 cricket::StreamParams::CreateLegacy(kSsrc)));
552 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_)); 553 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_));
553 EXPECT_TRUE(SetSend(true)); 554 EXPECT_TRUE(SetSend(true));
554 EXPECT_TRUE(SendFrame()); 555 EXPECT_TRUE(SendFrame());
555 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); 556 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
556 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); 557 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
557 558
558 // Add an additional capturer, and hook up a renderer to receive it. 559 // Add an additional capturer, and hook up a renderer to receive it.
559 cricket::FakeVideoRenderer renderer2; 560 cricket::FakeVideoRenderer renderer2;
560 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( 561 std::unique_ptr<cricket::FakeVideoCapturer> capturer(
561 CreateFakeVideoCapturer()); 562 CreateFakeVideoCapturer());
562 capturer->SetScreencast(true); 563 capturer->SetScreencast(true);
563 const int kTestWidth = 160; 564 const int kTestWidth = 160;
564 const int kTestHeight = 120; 565 const int kTestHeight = 120;
565 cricket::VideoFormat format(kTestWidth, kTestHeight, 566 cricket::VideoFormat format(kTestWidth, kTestHeight,
566 cricket::VideoFormat::FpsToInterval(5), 567 cricket::VideoFormat::FpsToInterval(5),
567 cricket::FOURCC_I420); 568 cricket::FOURCC_I420);
568 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format)); 569 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format));
569 EXPECT_TRUE(channel_->AddSendStream( 570 EXPECT_TRUE(channel_->AddSendStream(
570 cricket::StreamParams::CreateLegacy(5678))); 571 cricket::StreamParams::CreateLegacy(5678)));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 parameters.max_bandwidth_bps = 128 * 1024; 617 parameters.max_bandwidth_bps = 128 * 1024;
617 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 618 EXPECT_TRUE(channel_->SetSendParameters(parameters));
618 } 619 }
619 // Test that we can set the SSRC for the default send source. 620 // Test that we can set the SSRC for the default send source.
620 void SetSendSsrc() { 621 void SetSendSsrc() {
621 EXPECT_TRUE(SetDefaultCodec()); 622 EXPECT_TRUE(SetDefaultCodec());
622 EXPECT_TRUE(SetSend(true)); 623 EXPECT_TRUE(SetSend(true));
623 EXPECT_TRUE(SendFrame()); 624 EXPECT_TRUE(SendFrame());
624 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); 625 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
625 uint32_t ssrc = 0; 626 uint32_t ssrc = 0;
626 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); 627 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
627 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); 628 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
628 EXPECT_EQ(kSsrc, ssrc); 629 EXPECT_EQ(kSsrc, ssrc);
629 // Packets are being paced out, so these can mismatch between the first and 630 // Packets are being paced out, so these can mismatch between the first and
630 // second call to NumRtpPackets until pending packets are paced out. 631 // second call to NumRtpPackets until pending packets are paced out.
631 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout); 632 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout);
632 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout); 633 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout);
633 EXPECT_EQ(1, NumSentSsrcs()); 634 EXPECT_EQ(1, NumSentSsrcs());
634 EXPECT_EQ(0, NumRtpPackets(kSsrc - 1)); 635 EXPECT_EQ(0, NumRtpPackets(kSsrc - 1));
635 EXPECT_EQ(0, NumRtpBytes(kSsrc - 1)); 636 EXPECT_EQ(0, NumRtpBytes(kSsrc - 1));
636 } 637 }
637 // Test that we can set the SSRC even after codecs are set. 638 // Test that we can set the SSRC even after codecs are set.
638 void SetSendSsrcAfterSetCodecs() { 639 void SetSendSsrcAfterSetCodecs() {
639 // Remove stream added in Setup. 640 // Remove stream added in Setup.
640 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); 641 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
641 EXPECT_TRUE(SetDefaultCodec()); 642 EXPECT_TRUE(SetDefaultCodec());
642 EXPECT_TRUE(channel_->AddSendStream( 643 EXPECT_TRUE(channel_->AddSendStream(
643 cricket::StreamParams::CreateLegacy(999))); 644 cricket::StreamParams::CreateLegacy(999)));
644 EXPECT_TRUE(channel_->SetCapturer(999u, video_capturer_.get())); 645 EXPECT_TRUE(channel_->SetCapturer(999u, video_capturer_.get()));
645 EXPECT_TRUE(SetSend(true)); 646 EXPECT_TRUE(SetSend(true));
646 EXPECT_TRUE(WaitAndSendFrame(0)); 647 EXPECT_TRUE(WaitAndSendFrame(0));
647 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); 648 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
648 uint32_t ssrc = 0; 649 uint32_t ssrc = 0;
649 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); 650 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
650 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); 651 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
651 EXPECT_EQ(999u, ssrc); 652 EXPECT_EQ(999u, ssrc);
652 // Packets are being paced out, so these can mismatch between the first and 653 // Packets are being paced out, so these can mismatch between the first and
653 // second call to NumRtpPackets until pending packets are paced out. 654 // second call to NumRtpPackets until pending packets are paced out.
654 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout); 655 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout);
655 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout); 656 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout);
656 EXPECT_EQ(1, NumSentSsrcs()); 657 EXPECT_EQ(1, NumSentSsrcs());
657 EXPECT_EQ(0, NumRtpPackets(kSsrc)); 658 EXPECT_EQ(0, NumRtpPackets(kSsrc));
658 EXPECT_EQ(0, NumRtpBytes(kSsrc)); 659 EXPECT_EQ(0, NumRtpBytes(kSsrc));
659 } 660 }
(...skipping 29 matching lines...) Expand all
689 // Tests setting up and configuring a send stream. 690 // Tests setting up and configuring a send stream.
690 void AddRemoveSendStreams() { 691 void AddRemoveSendStreams() {
691 EXPECT_TRUE(SetOneCodec(DefaultCodec())); 692 EXPECT_TRUE(SetOneCodec(DefaultCodec()));
692 EXPECT_TRUE(SetSend(true)); 693 EXPECT_TRUE(SetSend(true));
693 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); 694 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
694 EXPECT_TRUE(SendFrame()); 695 EXPECT_TRUE(SendFrame());
695 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); 696 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
696 EXPECT_GT(NumRtpPackets(), 0); 697 EXPECT_GT(NumRtpPackets(), 0);
697 uint32_t ssrc = 0; 698 uint32_t ssrc = 0;
698 size_t last_packet = NumRtpPackets() - 1; 699 size_t last_packet = NumRtpPackets() - 1;
699 rtc::scoped_ptr<const rtc::Buffer> 700 std::unique_ptr<const rtc::Buffer>
700 p(GetRtpPacket(static_cast<int>(last_packet))); 701 p(GetRtpPacket(static_cast<int>(last_packet)));
701 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); 702 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
702 EXPECT_EQ(kSsrc, ssrc); 703 EXPECT_EQ(kSsrc, ssrc);
703 704
704 // Remove the send stream that was added during Setup. 705 // Remove the send stream that was added during Setup.
705 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); 706 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
706 int rtp_packets = NumRtpPackets(); 707 int rtp_packets = NumRtpPackets();
707 708
708 EXPECT_TRUE(channel_->AddSendStream( 709 EXPECT_TRUE(channel_->AddSendStream(
709 cricket::StreamParams::CreateLegacy(789u))); 710 cricket::StreamParams::CreateLegacy(789u)));
(...skipping 29 matching lines...) Expand all
739 std::vector<uint32_t> ssrcs; 740 std::vector<uint32_t> ssrcs;
740 ssrcs.push_back(1); 741 ssrcs.push_back(1);
741 ssrcs.push_back(2); 742 ssrcs.push_back(2);
742 network_interface_.SetConferenceMode(true, ssrcs); 743 network_interface_.SetConferenceMode(true, ssrcs);
743 EXPECT_TRUE(SendFrame()); 744 EXPECT_TRUE(SendFrame());
744 EXPECT_FRAME_ON_RENDERER_WAIT( 745 EXPECT_FRAME_ON_RENDERER_WAIT(
745 renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout); 746 renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
746 EXPECT_FRAME_ON_RENDERER_WAIT( 747 EXPECT_FRAME_ON_RENDERER_WAIT(
747 renderer2, 1, DefaultCodec().width, DefaultCodec().height, kTimeout); 748 renderer2, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
748 749
749 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); 750 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
750 EXPECT_EQ(DefaultCodec().id, GetPayloadType(p.get())); 751 EXPECT_EQ(DefaultCodec().id, GetPayloadType(p.get()));
751 EXPECT_EQ(DefaultCodec().width, renderer1.width()); 752 EXPECT_EQ(DefaultCodec().width, renderer1.width());
752 EXPECT_EQ(DefaultCodec().height, renderer1.height()); 753 EXPECT_EQ(DefaultCodec().height, renderer1.height());
753 EXPECT_EQ(DefaultCodec().width, renderer2.width()); 754 EXPECT_EQ(DefaultCodec().width, renderer2.width());
754 EXPECT_EQ(DefaultCodec().height, renderer2.height()); 755 EXPECT_EQ(DefaultCodec().height, renderer2.height());
755 EXPECT_TRUE(channel_->RemoveRecvStream(2)); 756 EXPECT_TRUE(channel_->RemoveRecvStream(2));
756 EXPECT_TRUE(channel_->RemoveRecvStream(1)); 757 EXPECT_TRUE(channel_->RemoveRecvStream(1));
757 } 758 }
758 759
759 // Tests that we can add and remove capturers and frames are sent out properly 760 // Tests that we can add and remove capturers and frames are sent out properly
760 void AddRemoveCapturer() { 761 void AddRemoveCapturer() {
761 cricket::VideoCodec codec = DefaultCodec(); 762 cricket::VideoCodec codec = DefaultCodec();
762 codec.width = 320; 763 codec.width = 320;
763 codec.height = 240; 764 codec.height = 240;
764 const int time_between_send = TimeBetweenSend(codec); 765 const int time_between_send = TimeBetweenSend(codec);
765 EXPECT_TRUE(SetOneCodec(codec)); 766 EXPECT_TRUE(SetOneCodec(codec));
766 EXPECT_TRUE(SetSend(true)); 767 EXPECT_TRUE(SetSend(true));
767 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); 768 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
768 EXPECT_EQ(0, renderer_.num_rendered_frames()); 769 EXPECT_EQ(0, renderer_.num_rendered_frames());
769 EXPECT_TRUE(SendFrame()); 770 EXPECT_TRUE(SendFrame());
770 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); 771 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
771 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( 772 std::unique_ptr<cricket::FakeVideoCapturer> capturer(
772 CreateFakeVideoCapturer()); 773 CreateFakeVideoCapturer());
773 capturer->SetScreencast(true); 774 capturer->SetScreencast(true);
774 cricket::VideoFormat format(480, 360, 775 cricket::VideoFormat format(480, 360,
775 cricket::VideoFormat::FpsToInterval(30), 776 cricket::VideoFormat::FpsToInterval(30),
776 cricket::FOURCC_I420); 777 cricket::FOURCC_I420);
777 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format)); 778 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format));
778 // All capturers start generating frames with the same timestamp. ViE does 779 // All capturers start generating frames with the same timestamp. ViE does
779 // not allow the same timestamp to be used. Capture one frame before 780 // not allow the same timestamp to be used. Capture one frame before
780 // associating the capturer with the channel. 781 // associating the capturer with the channel.
781 EXPECT_TRUE(capturer->CaptureCustomFrame(format.width, format.height, 782 EXPECT_TRUE(capturer->CaptureCustomFrame(format.width, format.height,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 cricket::VideoFormat capture_format; // default format 859 cricket::VideoFormat capture_format; // default format
859 capture_format.interval = cricket::VideoFormat::FpsToInterval(30); 860 capture_format.interval = cricket::VideoFormat::FpsToInterval(30);
860 // Set up additional stream 1. 861 // Set up additional stream 1.
861 cricket::FakeVideoRenderer renderer1; 862 cricket::FakeVideoRenderer renderer1;
862 EXPECT_FALSE(channel_->SetSink(1, &renderer1)); 863 EXPECT_FALSE(channel_->SetSink(1, &renderer1));
863 EXPECT_TRUE(channel_->AddRecvStream( 864 EXPECT_TRUE(channel_->AddRecvStream(
864 cricket::StreamParams::CreateLegacy(1))); 865 cricket::StreamParams::CreateLegacy(1)));
865 EXPECT_TRUE(channel_->SetSink(1, &renderer1)); 866 EXPECT_TRUE(channel_->SetSink(1, &renderer1));
866 EXPECT_TRUE(channel_->AddSendStream( 867 EXPECT_TRUE(channel_->AddSendStream(
867 cricket::StreamParams::CreateLegacy(1))); 868 cricket::StreamParams::CreateLegacy(1)));
868 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer1( 869 std::unique_ptr<cricket::FakeVideoCapturer> capturer1(
869 CreateFakeVideoCapturer()); 870 CreateFakeVideoCapturer());
870 capturer1->SetScreencast(true); 871 capturer1->SetScreencast(true);
871 EXPECT_EQ(cricket::CS_RUNNING, capturer1->Start(capture_format)); 872 EXPECT_EQ(cricket::CS_RUNNING, capturer1->Start(capture_format));
872 // Set up additional stream 2. 873 // Set up additional stream 2.
873 cricket::FakeVideoRenderer renderer2; 874 cricket::FakeVideoRenderer renderer2;
874 EXPECT_FALSE(channel_->SetSink(2, &renderer2)); 875 EXPECT_FALSE(channel_->SetSink(2, &renderer2));
875 EXPECT_TRUE(channel_->AddRecvStream( 876 EXPECT_TRUE(channel_->AddRecvStream(
876 cricket::StreamParams::CreateLegacy(2))); 877 cricket::StreamParams::CreateLegacy(2)));
877 EXPECT_TRUE(channel_->SetSink(2, &renderer2)); 878 EXPECT_TRUE(channel_->SetSink(2, &renderer2));
878 EXPECT_TRUE(channel_->AddSendStream( 879 EXPECT_TRUE(channel_->AddSendStream(
879 cricket::StreamParams::CreateLegacy(2))); 880 cricket::StreamParams::CreateLegacy(2)));
880 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer2( 881 std::unique_ptr<cricket::FakeVideoCapturer> capturer2(
881 CreateFakeVideoCapturer()); 882 CreateFakeVideoCapturer());
882 capturer2->SetScreencast(true); 883 capturer2->SetScreencast(true);
883 EXPECT_EQ(cricket::CS_RUNNING, capturer2->Start(capture_format)); 884 EXPECT_EQ(cricket::CS_RUNNING, capturer2->Start(capture_format));
884 // State for all the streams. 885 // State for all the streams.
885 EXPECT_TRUE(SetOneCodec(DefaultCodec())); 886 EXPECT_TRUE(SetOneCodec(DefaultCodec()));
886 // A limitation in the lmi implementation requires that SetCapturer() is 887 // A limitation in the lmi implementation requires that SetCapturer() is
887 // called after SetOneCodec(). 888 // called after SetOneCodec().
888 // TODO(hellner): this seems like an unnecessary constraint, fix it. 889 // TODO(hellner): this seems like an unnecessary constraint, fix it.
889 EXPECT_TRUE(channel_->SetCapturer(1, capturer1.get())); 890 EXPECT_TRUE(channel_->SetCapturer(1, capturer1.get()));
890 EXPECT_TRUE(channel_->SetCapturer(2, capturer2.get())); 891 EXPECT_TRUE(channel_->SetCapturer(2, capturer2.get()));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 cricket::StreamParams::CreateLegacy(kSsrc))); 927 cricket::StreamParams::CreateLegacy(kSsrc)));
927 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer)); 928 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer));
928 EXPECT_EQ(0, renderer.num_rendered_frames()); 929 EXPECT_EQ(0, renderer.num_rendered_frames());
929 930
930 EXPECT_TRUE(SendFrame()); 931 EXPECT_TRUE(SendFrame());
931 EXPECT_GT_FRAME_ON_RENDERER_WAIT( 932 EXPECT_GT_FRAME_ON_RENDERER_WAIT(
932 renderer, 1, codec.width, codec.height, kTimeout); 933 renderer, 1, codec.width, codec.height, kTimeout);
933 934
934 // Registering an external capturer is currently the same as screen casting 935 // Registering an external capturer is currently the same as screen casting
935 // (update the test when this changes). 936 // (update the test when this changes).
936 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( 937 std::unique_ptr<cricket::FakeVideoCapturer> capturer(
937 CreateFakeVideoCapturer()); 938 CreateFakeVideoCapturer());
938 capturer->SetScreencast(true); 939 capturer->SetScreencast(true);
939 const std::vector<cricket::VideoFormat>* formats = 940 const std::vector<cricket::VideoFormat>* formats =
940 capturer->GetSupportedFormats(); 941 capturer->GetSupportedFormats();
941 cricket::VideoFormat capture_format = (*formats)[0]; 942 cricket::VideoFormat capture_format = (*formats)[0];
942 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(capture_format)); 943 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(capture_format));
943 // Capture frame to not get same frame timestamps as previous capturer. 944 // Capture frame to not get same frame timestamps as previous capturer.
944 capturer->CaptureFrame(); 945 capturer->CaptureFrame();
945 EXPECT_TRUE(channel_->SetCapturer(kSsrc, capturer.get())); 946 EXPECT_TRUE(channel_->SetCapturer(kSsrc, capturer.get()));
946 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30)); 947 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 cricket::VideoCodec codec(DefaultCodec()); 1001 cricket::VideoCodec codec(DefaultCodec());
1001 int frame_count = 0; 1002 int frame_count = 0;
1002 // The capturer runs at 30 fps. The channel requires 30 fps. 1003 // The capturer runs at 30 fps. The channel requires 30 fps.
1003 EXPECT_TRUE(SetOneCodec(codec)); 1004 EXPECT_TRUE(SetOneCodec(codec));
1004 EXPECT_TRUE(SetSend(true)); 1005 EXPECT_TRUE(SetSend(true));
1005 EXPECT_EQ(frame_count, renderer_.num_rendered_frames()); 1006 EXPECT_EQ(frame_count, renderer_.num_rendered_frames());
1006 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered. 1007 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
1007 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered. 1008 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
1008 frame_count += 2; 1009 frame_count += 2;
1009 EXPECT_FRAME_WAIT(frame_count, codec.width, codec.height, kTimeout); 1010 EXPECT_FRAME_WAIT(frame_count, codec.width, codec.height, kTimeout);
1010 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); 1011 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
1011 EXPECT_EQ(codec.id, GetPayloadType(p.get())); 1012 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
1012 1013
1013 // The channel requires 15 fps. 1014 // The channel requires 15 fps.
1014 codec.framerate = 15; 1015 codec.framerate = 15;
1015 EXPECT_TRUE(SetOneCodec(codec)); 1016 EXPECT_TRUE(SetOneCodec(codec));
1016 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered. 1017 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
1017 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped. 1018 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
1018 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered. 1019 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
1019 frame_count += 2; 1020 frame_count += 2;
1020 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); 1021 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 EXPECT_FALSE(channel_->AddRecvStream( 1169 EXPECT_FALSE(channel_->AddRecvStream(
1169 cricket::StreamParams::CreateLegacy(new_ssrc))); 1170 cricket::StreamParams::CreateLegacy(new_ssrc)));
1170 1171
1171 EXPECT_TRUE(channel_->SetCapturer(new_ssrc, video_capturer_.get())); 1172 EXPECT_TRUE(channel_->SetCapturer(new_ssrc, video_capturer_.get()));
1172 1173
1173 SendAndReceive(codec); 1174 SendAndReceive(codec);
1174 EXPECT_TRUE(channel_->RemoveSendStream(new_ssrc)); 1175 EXPECT_TRUE(channel_->RemoveSendStream(new_ssrc));
1175 EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc()); 1176 EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc());
1176 } 1177 }
1177 1178
1178 const rtc::scoped_ptr<webrtc::Call> call_; 1179 const std::unique_ptr<webrtc::Call> call_;
1179 VideoEngineOverride<E> engine_; 1180 VideoEngineOverride<E> engine_;
1180 rtc::scoped_ptr<cricket::FakeVideoCapturer> video_capturer_; 1181 std::unique_ptr<cricket::FakeVideoCapturer> video_capturer_;
1181 rtc::scoped_ptr<cricket::FakeVideoCapturer> video_capturer_2_; 1182 std::unique_ptr<cricket::FakeVideoCapturer> video_capturer_2_;
1182 rtc::scoped_ptr<C> channel_; 1183 std::unique_ptr<C> channel_;
1183 cricket::FakeNetworkInterface network_interface_; 1184 cricket::FakeNetworkInterface network_interface_;
1184 cricket::FakeVideoRenderer renderer_; 1185 cricket::FakeVideoRenderer renderer_;
1185 cricket::VideoMediaChannel::Error media_error_; 1186 cricket::VideoMediaChannel::Error media_error_;
1186 1187
1187 // Used by test cases where 2 streams are run on the same channel. 1188 // Used by test cases where 2 streams are run on the same channel.
1188 cricket::FakeVideoRenderer renderer2_; 1189 cricket::FakeVideoRenderer renderer2_;
1189 }; 1190 };
1190 1191
1191 #endif // WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT 1192 #endif // WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT
OLDNEW
« no previous file with comments | « webrtc/media/base/videocapturer.cc ('k') | webrtc/media/base/videoframe_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698