Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "content/child/child_process.h" | 9 #include "content/child/child_process.h" |
| 10 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" | 10 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" |
| 11 #include "gpu/command_buffer/common/mailbox_holder.h" | 11 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 12 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 static void ReleaseMailboxCB(const gpu::SyncToken& sync_token) {} | 16 static void ReleaseMailboxCB(const gpu::SyncToken& sync_token) {} |
| 17 } // anonymous namespace | 17 } // anonymous namespace |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 class WebRtcVideoCapturerAdapterTest | 21 class WebRtcVideoCapturerAdapterTest |
| 22 : public rtc::VideoSinkInterface<cricket::VideoFrame>, | 22 : public rtc::VideoSinkInterface<webrtc::VideoFrame>, |
| 23 public ::testing::Test { | 23 public ::testing::Test { |
| 24 public: | 24 public: |
| 25 WebRtcVideoCapturerAdapterTest() | 25 WebRtcVideoCapturerAdapterTest() |
| 26 : adapter_(false), | 26 : adapter_(false), |
| 27 output_frame_width_(0), | 27 output_frame_width_(0), |
| 28 output_frame_height_(0) { | 28 output_frame_height_(0) { |
| 29 adapter_.AddOrUpdateSink(this, rtc::VideoSinkWants()); | 29 adapter_.AddOrUpdateSink(this, rtc::VideoSinkWants()); |
| 30 } | 30 } |
| 31 ~WebRtcVideoCapturerAdapterTest() override { | 31 ~WebRtcVideoCapturerAdapterTest() override { |
| 32 adapter_.RemoveSink(this); | 32 adapter_.RemoveSink(this); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 | 70 |
| 71 rtc::scoped_refptr<webrtc::VideoFrameBuffer> copied_frame = | 71 rtc::scoped_refptr<webrtc::VideoFrameBuffer> copied_frame = |
| 72 texture_frame->NativeToI420Buffer(); | 72 texture_frame->NativeToI420Buffer(); |
| 73 EXPECT_TRUE(copied_frame); | 73 EXPECT_TRUE(copied_frame); |
| 74 EXPECT_TRUE(copied_frame->DataY()); | 74 EXPECT_TRUE(copied_frame->DataY()); |
| 75 EXPECT_TRUE(copied_frame->DataU()); | 75 EXPECT_TRUE(copied_frame->DataU()); |
| 76 EXPECT_TRUE(copied_frame->DataV()); | 76 EXPECT_TRUE(copied_frame->DataV()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 // rtc::VideoSinkInterface | 79 // rtc::VideoSinkInterface |
| 80 void OnFrame(const cricket::VideoFrame& frame) override { | 80 void OnFrame(const webrtc::VideoFrame& frame) override { |
| 81 output_frame_ = frame; | 81 output_frame_ = frame; |
| 82 output_frame_width_ = frame.width(); | 82 output_frame_width_ = frame.width(); |
| 83 output_frame_height_ = frame.height(); | 83 output_frame_height_ = frame.height(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 const base::MessageLoopForIO message_loop_; | 87 const base::MessageLoopForIO message_loop_; |
| 88 const ChildProcess child_process_; | 88 const ChildProcess child_process_; |
| 89 | 89 |
| 90 WebRtcVideoCapturerAdapter adapter_; | 90 WebRtcVideoCapturerAdapter adapter_; |
| 91 cricket::VideoFrame output_frame_; | 91 // TODO(nisse): Default constructor is deprecated. Use std::optional? |
|
Sergey Ulanov
2016/11/02 19:33:59
std::optional is C++17. But this code could use ba
nisse-chromium (ooo August 14)
2016/11/07 09:58:19
I figured there's something similar to std::Option
| |
| 92 webrtc::VideoFrame output_frame_; | |
| 92 int output_frame_width_; | 93 int output_frame_width_; |
| 93 int output_frame_height_; | 94 int output_frame_height_; |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo640360) { | 97 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo640360) { |
| 97 TestSourceCropFrame(640, 480, 640, 360, 640, 360); | 98 TestSourceCropFrame(640, 480, 640, 360, 640, 360); |
| 98 } | 99 } |
| 99 | 100 |
| 100 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo320320) { | 101 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo320320) { |
| 101 TestSourceCropFrame(640, 480, 480, 480, 320, 320); | 102 TestSourceCropFrame(640, 480, 480, 480, 320, 320); |
| 102 } | 103 } |
| 103 | 104 |
| 104 TEST_F(WebRtcVideoCapturerAdapterTest, Scale720To640360) { | 105 TEST_F(WebRtcVideoCapturerAdapterTest, Scale720To640360) { |
| 105 TestSourceCropFrame(1280, 720, 1280, 720, 640, 360); | 106 TestSourceCropFrame(1280, 720, 1280, 720, 640, 360); |
| 106 } | 107 } |
| 107 | 108 |
| 108 TEST_F(WebRtcVideoCapturerAdapterTest, SendsWithCopyTextureFrameCallback) { | 109 TEST_F(WebRtcVideoCapturerAdapterTest, SendsWithCopyTextureFrameCallback) { |
| 109 TestSourceTextureFrame(); | 110 TestSourceTextureFrame(); |
| 110 } | 111 } |
| 111 | 112 |
| 112 } // namespace content | 113 } // namespace content |
| OLD | NEW |