| 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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/optional.h" | 9 #include "base/optional.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "content/child/child_process.h" | 11 #include "content/child/child_process.h" |
| 12 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" | 12 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" |
| 13 #include "content/renderer/media/webrtc/webrtc_video_frame_adapter.h" |
| 13 #include "gpu/command_buffer/common/mailbox_holder.h" | 14 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 14 #include "media/base/video_frame.h" | 15 #include "media/base/video_frame.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 static void ReleaseMailboxCB(const gpu::SyncToken& sync_token) {} | 19 static void ReleaseMailboxCB(const gpu::SyncToken& sync_token) {} |
| 19 } // anonymous namespace | 20 } // anonymous namespace |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 | 23 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 gpu::MailboxHolder(gpu::Mailbox::Generate(), gpu::SyncToken(), 5)}; | 61 gpu::MailboxHolder(gpu::Mailbox::Generate(), gpu::SyncToken(), 5)}; |
| 61 scoped_refptr<media::VideoFrame> frame = | 62 scoped_refptr<media::VideoFrame> frame = |
| 62 media::VideoFrame::WrapNativeTextures( | 63 media::VideoFrame::WrapNativeTextures( |
| 63 media::PIXEL_FORMAT_ARGB, holders, base::Bind(&ReleaseMailboxCB), | 64 media::PIXEL_FORMAT_ARGB, holders, base::Bind(&ReleaseMailboxCB), |
| 64 gfx::Size(10, 10), gfx::Rect(10, 10), gfx::Size(10, 10), | 65 gfx::Size(10, 10), gfx::Rect(10, 10), gfx::Size(10, 10), |
| 65 base::TimeDelta()); | 66 base::TimeDelta()); |
| 66 adapter_->OnFrameCaptured(frame); | 67 adapter_->OnFrameCaptured(frame); |
| 67 ASSERT_TRUE(output_frame_); | 68 ASSERT_TRUE(output_frame_); |
| 68 rtc::scoped_refptr<webrtc::VideoFrameBuffer> texture_frame = | 69 rtc::scoped_refptr<webrtc::VideoFrameBuffer> texture_frame = |
| 69 output_frame_->video_frame_buffer(); | 70 output_frame_->video_frame_buffer(); |
| 71 EXPECT_EQ(webrtc::VideoFrameBuffer::Type::kNative, texture_frame->type()); |
| 70 EXPECT_EQ(media::VideoFrame::STORAGE_OPAQUE, | 72 EXPECT_EQ(media::VideoFrame::STORAGE_OPAQUE, |
| 71 static_cast<media::VideoFrame*>(texture_frame->native_handle()) | 73 static_cast<WebRtcVideoFrameAdapter*>(texture_frame.get()) |
| 74 ->getMediaVideoFrame() |
| 72 ->storage_type()); | 75 ->storage_type()); |
| 73 | 76 |
| 74 rtc::scoped_refptr<webrtc::VideoFrameBuffer> copied_frame = | 77 rtc::scoped_refptr<webrtc::I420BufferInterface> copied_frame = |
| 75 texture_frame->NativeToI420Buffer(); | 78 texture_frame->ToI420(); |
| 76 EXPECT_TRUE(copied_frame); | 79 EXPECT_TRUE(copied_frame); |
| 77 EXPECT_TRUE(copied_frame->DataY()); | 80 EXPECT_TRUE(copied_frame->DataY()); |
| 78 EXPECT_TRUE(copied_frame->DataU()); | 81 EXPECT_TRUE(copied_frame->DataU()); |
| 79 EXPECT_TRUE(copied_frame->DataV()); | 82 EXPECT_TRUE(copied_frame->DataV()); |
| 80 } | 83 } |
| 81 | 84 |
| 82 // rtc::VideoSinkInterface | 85 // rtc::VideoSinkInterface |
| 83 void OnFrame(const webrtc::VideoFrame& frame) override { | 86 void OnFrame(const webrtc::VideoFrame& frame) override { |
| 84 output_frame_ = base::Optional<webrtc::VideoFrame>(frame); | 87 output_frame_ = base::Optional<webrtc::VideoFrame>(frame); |
| 85 output_frame_width_ = frame.width(); | 88 output_frame_width_ = frame.width(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 195 |
| 193 TEST_F(WebRtcVideoCapturerAdapterTest, RespectsConstructionTimeContentHint) { | 196 TEST_F(WebRtcVideoCapturerAdapterTest, RespectsConstructionTimeContentHint) { |
| 194 // Non-screenshare adapter constructed with detail content hint should not | 197 // Non-screenshare adapter constructed with detail content hint should not |
| 195 // adapt before SetContentHint is run. | 198 // adapt before SetContentHint is run. |
| 196 TestContentHintResolutionAdaptation( | 199 TestContentHintResolutionAdaptation( |
| 197 false, blink::WebMediaStreamTrack::ContentHintType::kVideoDetail, false, | 200 false, blink::WebMediaStreamTrack::ContentHintType::kVideoDetail, false, |
| 198 blink::WebMediaStreamTrack::ContentHintType::kVideoMotion, true); | 201 blink::WebMediaStreamTrack::ContentHintType::kVideoMotion, true); |
| 199 } | 202 } |
| 200 | 203 |
| 201 } // namespace content | 204 } // namespace content |
| OLD | NEW |