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" | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 void TestSourceTextureFrame() { | 55 void TestSourceTextureFrame() { | 
| 56 EXPECT_TRUE(message_loop_.IsCurrent()); | 56 EXPECT_TRUE(message_loop_.IsCurrent()); | 
| 57 gpu::MailboxHolder holders[media::VideoFrame::kMaxPlanes] = { | 57 gpu::MailboxHolder holders[media::VideoFrame::kMaxPlanes] = { | 
| 58 gpu::MailboxHolder(gpu::Mailbox::Generate(), gpu::SyncToken(), 5)}; | 58 gpu::MailboxHolder(gpu::Mailbox::Generate(), gpu::SyncToken(), 5)}; | 
| 59 scoped_refptr<media::VideoFrame> frame = | 59 scoped_refptr<media::VideoFrame> frame = | 
| 60 media::VideoFrame::WrapNativeTextures( | 60 media::VideoFrame::WrapNativeTextures( | 
| 61 media::PIXEL_FORMAT_ARGB, holders, base::Bind(&ReleaseMailboxCB), | 61 media::PIXEL_FORMAT_ARGB, holders, base::Bind(&ReleaseMailboxCB), | 
| 62 gfx::Size(10, 10), gfx::Rect(10, 10), gfx::Size(10, 10), | 62 gfx::Size(10, 10), gfx::Rect(10, 10), gfx::Size(10, 10), | 
| 63 base::TimeDelta()); | 63 base::TimeDelta()); | 
| 64 adapter_.OnFrameCaptured(frame); | 64 adapter_.OnFrameCaptured(frame); | 
| 65 ASSERT_TRUE(output_frame_); | |
| 65 rtc::scoped_refptr<webrtc::VideoFrameBuffer> texture_frame = | 66 rtc::scoped_refptr<webrtc::VideoFrameBuffer> texture_frame = | 
| 66 output_frame_.video_frame_buffer(); | 67 output_frame_->video_frame_buffer(); | 
| 67 EXPECT_EQ(media::VideoFrame::STORAGE_OPAQUE, | 68 EXPECT_EQ(media::VideoFrame::STORAGE_OPAQUE, | 
| 68 static_cast<media::VideoFrame*>(texture_frame->native_handle()) | 69 static_cast<media::VideoFrame*>(texture_frame->native_handle()) | 
| 69 ->storage_type()); | 70 ->storage_type()); | 
| 70 | 71 | 
| 71 rtc::scoped_refptr<webrtc::VideoFrameBuffer> copied_frame = | 72 rtc::scoped_refptr<webrtc::VideoFrameBuffer> copied_frame = | 
| 72 texture_frame->NativeToI420Buffer(); | 73 texture_frame->NativeToI420Buffer(); | 
| 73 EXPECT_TRUE(copied_frame); | 74 EXPECT_TRUE(copied_frame); | 
| 74 EXPECT_TRUE(copied_frame->DataY()); | 75 EXPECT_TRUE(copied_frame->DataY()); | 
| 75 EXPECT_TRUE(copied_frame->DataU()); | 76 EXPECT_TRUE(copied_frame->DataU()); | 
| 76 EXPECT_TRUE(copied_frame->DataV()); | 77 EXPECT_TRUE(copied_frame->DataV()); | 
| 77 } | 78 } | 
| 78 | 79 | 
| 79 // rtc::VideoSinkInterface | 80 // rtc::VideoSinkInterface | 
| 80 void OnFrame(const webrtc::VideoFrame& frame) override { | 81 void OnFrame(const webrtc::VideoFrame& frame) override { | 
| 81 output_frame_ = frame; | 82 output_frame_ = rtc::Optional<webrtc::VideoFrame>(frame); | 
| 82 output_frame_width_ = frame.width(); | 83 output_frame_width_ = frame.width(); | 
| 83 output_frame_height_ = frame.height(); | 84 output_frame_height_ = frame.height(); | 
| 84 } | 85 } | 
| 85 | 86 | 
| 86 private: | 87 private: | 
| 87 const base::MessageLoopForIO message_loop_; | 88 const base::MessageLoopForIO message_loop_; | 
| 88 const ChildProcess child_process_; | 89 const ChildProcess child_process_; | 
| 89 | 90 | 
| 90 WebRtcVideoCapturerAdapter adapter_; | 91 WebRtcVideoCapturerAdapter adapter_; | 
| 91 // TODO(nisse): Default constructor is deprecated. Use std::optional? | 92 rtc::Optional<webrtc::VideoFrame> output_frame_; | 
| 
 
Sergey Ulanov
2016/12/02 18:24:05
This this test is in chromium I think it's better
 
nisse-chromium (ooo August 14)
2016/12/05 09:54:35
Done.
 
 | |
| 92 webrtc::VideoFrame output_frame_; | |
| 93 int output_frame_width_; | 93 int output_frame_width_; | 
| 94 int output_frame_height_; | 94 int output_frame_height_; | 
| 95 }; | 95 }; | 
| 96 | 96 | 
| 97 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo640360) { | 97 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo640360) { | 
| 98 TestSourceCropFrame(640, 480, 640, 360, 640, 360); | 98 TestSourceCropFrame(640, 480, 640, 360, 640, 360); | 
| 99 } | 99 } | 
| 100 | 100 | 
| 101 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo320320) { | 101 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo320320) { | 
| 102 TestSourceCropFrame(640, 480, 480, 480, 320, 320); | 102 TestSourceCropFrame(640, 480, 480, 480, 320, 320); | 
| 103 } | 103 } | 
| 104 | 104 | 
| 105 TEST_F(WebRtcVideoCapturerAdapterTest, Scale720To640360) { | 105 TEST_F(WebRtcVideoCapturerAdapterTest, Scale720To640360) { | 
| 106 TestSourceCropFrame(1280, 720, 1280, 720, 640, 360); | 106 TestSourceCropFrame(1280, 720, 1280, 720, 640, 360); | 
| 107 } | 107 } | 
| 108 | 108 | 
| 109 TEST_F(WebRtcVideoCapturerAdapterTest, SendsWithCopyTextureFrameCallback) { | 109 TEST_F(WebRtcVideoCapturerAdapterTest, SendsWithCopyTextureFrameCallback) { | 
| 110 TestSourceTextureFrame(); | 110 TestSourceTextureFrame(); | 
| 111 } | 111 } | 
| 112 | 112 | 
| 113 } // namespace content | 113 } // namespace content | 
| OLD | NEW |