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