| OLD | NEW |
| 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 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 channel_->SetRecvParameters(parameters); | 121 channel_->SetRecvParameters(parameters); |
| 122 EXPECT_TRUE(channel_->AddSendStream(DefaultSendStreamParams())); | 122 EXPECT_TRUE(channel_->AddSendStream(DefaultSendStreamParams())); |
| 123 video_capturer_.reset(CreateFakeVideoCapturer()); | 123 video_capturer_.reset(CreateFakeVideoCapturer()); |
| 124 cricket::VideoFormat format(640, 480, | 124 cricket::VideoFormat format(640, 480, |
| 125 cricket::VideoFormat::FpsToInterval(30), | 125 cricket::VideoFormat::FpsToInterval(30), |
| 126 cricket::FOURCC_I420); | 126 cricket::FOURCC_I420); |
| 127 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(format)); | 127 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(format)); |
| 128 EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get())); | 128 EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get())); |
| 129 } | 129 } |
| 130 | 130 |
| 131 virtual cricket::FakeVideoCapturer* CreateFakeVideoCapturer( |
| 132 bool is_screencast) { |
| 133 return new cricket::FakeVideoCapturer(is_screencast); |
| 134 } |
| 131 virtual cricket::FakeVideoCapturer* CreateFakeVideoCapturer() { | 135 virtual cricket::FakeVideoCapturer* CreateFakeVideoCapturer() { |
| 132 return new cricket::FakeVideoCapturer(); | 136 return CreateFakeVideoCapturer(false); |
| 133 } | 137 } |
| 134 | 138 |
| 135 // Utility method to setup an additional stream to send and receive video. | 139 // Utility method to setup an additional stream to send and receive video. |
| 136 // Used to test send and recv between two streams. | 140 // Used to test send and recv between two streams. |
| 137 void SetUpSecondStream() { | 141 void SetUpSecondStream() { |
| 138 SetUpSecondStreamWithNoRecv(); | 142 SetUpSecondStreamWithNoRecv(); |
| 139 // Setup recv for second stream. | 143 // Setup recv for second stream. |
| 140 EXPECT_TRUE(channel_->AddRecvStream( | 144 EXPECT_TRUE(channel_->AddRecvStream( |
| 141 cricket::StreamParams::CreateLegacy(kSsrc + 2))); | 145 cricket::StreamParams::CreateLegacy(kSsrc + 2))); |
| 142 // Make the second renderer available for use by a new stream. | 146 // Make the second renderer available for use by a new stream. |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 cricket::StreamParams::CreateLegacy(kSsrc))); | 555 cricket::StreamParams::CreateLegacy(kSsrc))); |
| 552 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_)); | 556 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_)); |
| 553 EXPECT_TRUE(SetSend(true)); | 557 EXPECT_TRUE(SetSend(true)); |
| 554 EXPECT_TRUE(SendFrame()); | 558 EXPECT_TRUE(SendFrame()); |
| 555 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); | 559 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); |
| 556 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); | 560 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); |
| 557 | 561 |
| 558 // Add an additional capturer, and hook up a renderer to receive it. | 562 // Add an additional capturer, and hook up a renderer to receive it. |
| 559 cricket::FakeVideoRenderer renderer2; | 563 cricket::FakeVideoRenderer renderer2; |
| 560 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( | 564 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( |
| 561 CreateFakeVideoCapturer()); | 565 CreateFakeVideoCapturer(true)); |
| 562 capturer->SetScreencast(true); | |
| 563 const int kTestWidth = 160; | 566 const int kTestWidth = 160; |
| 564 const int kTestHeight = 120; | 567 const int kTestHeight = 120; |
| 565 cricket::VideoFormat format(kTestWidth, kTestHeight, | 568 cricket::VideoFormat format(kTestWidth, kTestHeight, |
| 566 cricket::VideoFormat::FpsToInterval(5), | 569 cricket::VideoFormat::FpsToInterval(5), |
| 567 cricket::FOURCC_I420); | 570 cricket::FOURCC_I420); |
| 568 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format)); | 571 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format)); |
| 569 EXPECT_TRUE(channel_->AddSendStream( | 572 EXPECT_TRUE(channel_->AddSendStream( |
| 570 cricket::StreamParams::CreateLegacy(5678))); | 573 cricket::StreamParams::CreateLegacy(5678))); |
| 571 EXPECT_TRUE(channel_->SetCapturer(5678, capturer.get())); | 574 EXPECT_TRUE(channel_->SetCapturer(5678, capturer.get())); |
| 572 EXPECT_TRUE(channel_->AddRecvStream( | 575 EXPECT_TRUE(channel_->AddRecvStream( |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 codec.width = 320; | 765 codec.width = 320; |
| 763 codec.height = 240; | 766 codec.height = 240; |
| 764 const int time_between_send = TimeBetweenSend(codec); | 767 const int time_between_send = TimeBetweenSend(codec); |
| 765 EXPECT_TRUE(SetOneCodec(codec)); | 768 EXPECT_TRUE(SetOneCodec(codec)); |
| 766 EXPECT_TRUE(SetSend(true)); | 769 EXPECT_TRUE(SetSend(true)); |
| 767 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); | 770 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); |
| 768 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 771 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
| 769 EXPECT_TRUE(SendFrame()); | 772 EXPECT_TRUE(SendFrame()); |
| 770 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); | 773 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); |
| 771 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( | 774 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( |
| 772 CreateFakeVideoCapturer()); | 775 CreateFakeVideoCapturer(true)); |
| 773 capturer->SetScreencast(true); | 776 |
| 777 cricket::VideoOptions video_options; |
| 778 video_options.is_screencast = rtc::Optional<bool>(true); |
| 779 channel_->SetVideoSend(kSsrc, true, &video_options); |
| 780 |
| 774 cricket::VideoFormat format(480, 360, | 781 cricket::VideoFormat format(480, 360, |
| 775 cricket::VideoFormat::FpsToInterval(30), | 782 cricket::VideoFormat::FpsToInterval(30), |
| 776 cricket::FOURCC_I420); | 783 cricket::FOURCC_I420); |
| 777 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format)); | 784 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format)); |
| 778 // All capturers start generating frames with the same timestamp. ViE does | 785 // All capturers start generating frames with the same timestamp. ViE does |
| 779 // not allow the same timestamp to be used. Capture one frame before | 786 // not allow the same timestamp to be used. Capture one frame before |
| 780 // associating the capturer with the channel. | 787 // associating the capturer with the channel. |
| 781 EXPECT_TRUE(capturer->CaptureCustomFrame(format.width, format.height, | 788 EXPECT_TRUE(capturer->CaptureCustomFrame(format.width, format.height, |
| 782 cricket::FOURCC_I420)); | 789 cricket::FOURCC_I420)); |
| 783 | 790 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 capture_format.interval = cricket::VideoFormat::FpsToInterval(30); | 866 capture_format.interval = cricket::VideoFormat::FpsToInterval(30); |
| 860 // Set up additional stream 1. | 867 // Set up additional stream 1. |
| 861 cricket::FakeVideoRenderer renderer1; | 868 cricket::FakeVideoRenderer renderer1; |
| 862 EXPECT_FALSE(channel_->SetSink(1, &renderer1)); | 869 EXPECT_FALSE(channel_->SetSink(1, &renderer1)); |
| 863 EXPECT_TRUE(channel_->AddRecvStream( | 870 EXPECT_TRUE(channel_->AddRecvStream( |
| 864 cricket::StreamParams::CreateLegacy(1))); | 871 cricket::StreamParams::CreateLegacy(1))); |
| 865 EXPECT_TRUE(channel_->SetSink(1, &renderer1)); | 872 EXPECT_TRUE(channel_->SetSink(1, &renderer1)); |
| 866 EXPECT_TRUE(channel_->AddSendStream( | 873 EXPECT_TRUE(channel_->AddSendStream( |
| 867 cricket::StreamParams::CreateLegacy(1))); | 874 cricket::StreamParams::CreateLegacy(1))); |
| 868 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer1( | 875 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer1( |
| 869 CreateFakeVideoCapturer()); | 876 CreateFakeVideoCapturer(true)); |
| 870 capturer1->SetScreencast(true); | |
| 871 EXPECT_EQ(cricket::CS_RUNNING, capturer1->Start(capture_format)); | 877 EXPECT_EQ(cricket::CS_RUNNING, capturer1->Start(capture_format)); |
| 872 // Set up additional stream 2. | 878 // Set up additional stream 2. |
| 873 cricket::FakeVideoRenderer renderer2; | 879 cricket::FakeVideoRenderer renderer2; |
| 874 EXPECT_FALSE(channel_->SetSink(2, &renderer2)); | 880 EXPECT_FALSE(channel_->SetSink(2, &renderer2)); |
| 875 EXPECT_TRUE(channel_->AddRecvStream( | 881 EXPECT_TRUE(channel_->AddRecvStream( |
| 876 cricket::StreamParams::CreateLegacy(2))); | 882 cricket::StreamParams::CreateLegacy(2))); |
| 877 EXPECT_TRUE(channel_->SetSink(2, &renderer2)); | 883 EXPECT_TRUE(channel_->SetSink(2, &renderer2)); |
| 878 EXPECT_TRUE(channel_->AddSendStream( | 884 EXPECT_TRUE(channel_->AddSendStream( |
| 879 cricket::StreamParams::CreateLegacy(2))); | 885 cricket::StreamParams::CreateLegacy(2))); |
| 880 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer2( | 886 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer2( |
| 881 CreateFakeVideoCapturer()); | 887 CreateFakeVideoCapturer(true)); |
| 882 capturer2->SetScreencast(true); | |
| 883 EXPECT_EQ(cricket::CS_RUNNING, capturer2->Start(capture_format)); | 888 EXPECT_EQ(cricket::CS_RUNNING, capturer2->Start(capture_format)); |
| 884 // State for all the streams. | 889 // State for all the streams. |
| 885 EXPECT_TRUE(SetOneCodec(DefaultCodec())); | 890 EXPECT_TRUE(SetOneCodec(DefaultCodec())); |
| 886 // A limitation in the lmi implementation requires that SetCapturer() is | 891 // A limitation in the lmi implementation requires that SetCapturer() is |
| 887 // called after SetOneCodec(). | 892 // called after SetOneCodec(). |
| 888 // TODO(hellner): this seems like an unnecessary constraint, fix it. | 893 // TODO(hellner): this seems like an unnecessary constraint, fix it. |
| 889 EXPECT_TRUE(channel_->SetCapturer(1, capturer1.get())); | 894 EXPECT_TRUE(channel_->SetCapturer(1, capturer1.get())); |
| 890 EXPECT_TRUE(channel_->SetCapturer(2, capturer2.get())); | 895 EXPECT_TRUE(channel_->SetCapturer(2, capturer2.get())); |
| 891 EXPECT_TRUE(SetSend(true)); | 896 EXPECT_TRUE(SetSend(true)); |
| 892 // Test capturer associated with engine. | 897 // Test capturer associated with engine. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer)); | 932 EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer)); |
| 928 EXPECT_EQ(0, renderer.num_rendered_frames()); | 933 EXPECT_EQ(0, renderer.num_rendered_frames()); |
| 929 | 934 |
| 930 EXPECT_TRUE(SendFrame()); | 935 EXPECT_TRUE(SendFrame()); |
| 931 EXPECT_GT_FRAME_ON_RENDERER_WAIT( | 936 EXPECT_GT_FRAME_ON_RENDERER_WAIT( |
| 932 renderer, 1, codec.width, codec.height, kTimeout); | 937 renderer, 1, codec.width, codec.height, kTimeout); |
| 933 | 938 |
| 934 // Registering an external capturer is currently the same as screen casting | 939 // Registering an external capturer is currently the same as screen casting |
| 935 // (update the test when this changes). | 940 // (update the test when this changes). |
| 936 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( | 941 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer( |
| 937 CreateFakeVideoCapturer()); | 942 CreateFakeVideoCapturer(true)); |
| 938 capturer->SetScreencast(true); | |
| 939 const std::vector<cricket::VideoFormat>* formats = | 943 const std::vector<cricket::VideoFormat>* formats = |
| 940 capturer->GetSupportedFormats(); | 944 capturer->GetSupportedFormats(); |
| 941 cricket::VideoFormat capture_format = (*formats)[0]; | 945 cricket::VideoFormat capture_format = (*formats)[0]; |
| 942 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(capture_format)); | 946 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(capture_format)); |
| 943 // Capture frame to not get same frame timestamps as previous capturer. | 947 // Capture frame to not get same frame timestamps as previous capturer. |
| 944 capturer->CaptureFrame(); | 948 capturer->CaptureFrame(); |
| 945 EXPECT_TRUE(channel_->SetCapturer(kSsrc, capturer.get())); | 949 EXPECT_TRUE(channel_->SetCapturer(kSsrc, capturer.get())); |
| 946 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30)); | 950 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30)); |
| 947 EXPECT_TRUE(capturer->CaptureCustomFrame(kWidth, kHeight, | 951 EXPECT_TRUE(capturer->CaptureCustomFrame(kWidth, kHeight, |
| 948 cricket::FOURCC_ARGB)); | 952 cricket::FOURCC_ARGB)); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 rtc::scoped_ptr<C> channel_; | 1186 rtc::scoped_ptr<C> channel_; |
| 1183 cricket::FakeNetworkInterface network_interface_; | 1187 cricket::FakeNetworkInterface network_interface_; |
| 1184 cricket::FakeVideoRenderer renderer_; | 1188 cricket::FakeVideoRenderer renderer_; |
| 1185 cricket::VideoMediaChannel::Error media_error_; | 1189 cricket::VideoMediaChannel::Error media_error_; |
| 1186 | 1190 |
| 1187 // Used by test cases where 2 streams are run on the same channel. | 1191 // Used by test cases where 2 streams are run on the same channel. |
| 1188 cricket::FakeVideoRenderer renderer2_; | 1192 cricket::FakeVideoRenderer renderer2_; |
| 1189 }; | 1193 }; |
| 1190 | 1194 |
| 1191 #endif // WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT | 1195 #endif // WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT |
| OLD | NEW |