| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/capture/video/video_capture_device.h" | 5 #include "media/capture/video/video_capture_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 int rotation, | 114 int rotation, |
| 115 base::TimeTicks reference_time, | 115 base::TimeTicks reference_time, |
| 116 base::TimeDelta timestamp, | 116 base::TimeDelta timestamp, |
| 117 int frame_feedback_id) override { | 117 int frame_feedback_id) override { |
| 118 ASSERT_GT(length, 0); | 118 ASSERT_GT(length, 0); |
| 119 ASSERT_TRUE(data); | 119 ASSERT_TRUE(data); |
| 120 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format)); | 120 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. | 123 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. |
| 124 std::unique_ptr<Buffer> ReserveOutputBuffer(const gfx::Size& dimensions, | 124 Buffer ReserveOutputBuffer(const gfx::Size& dimensions, |
| 125 media::VideoPixelFormat format, | 125 media::VideoPixelFormat format, |
| 126 media::VideoPixelStorage storage, | 126 media::VideoPixelStorage storage, |
| 127 int frame_feedback_id) override { | 127 int frame_feedback_id) override { |
| 128 DoReserveOutputBuffer(); | 128 DoReserveOutputBuffer(); |
| 129 NOTREACHED() << "This should never be called"; | 129 NOTREACHED() << "This should never be called"; |
| 130 return std::unique_ptr<Buffer>(); | 130 return Buffer(); |
| 131 } | 131 } |
| 132 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, | 132 void OnIncomingCapturedBuffer(Buffer buffer, |
| 133 const VideoCaptureFormat& format, | 133 const VideoCaptureFormat& format, |
| 134 base::TimeTicks reference_time, | 134 base::TimeTicks reference_time, |
| 135 base::TimeDelta timestamp) override { | 135 base::TimeDelta timestamp) override { |
| 136 DoOnIncomingCapturedBuffer(); | 136 DoOnIncomingCapturedBuffer(); |
| 137 } | 137 } |
| 138 void OnIncomingCapturedBufferExt( | 138 void OnIncomingCapturedBufferExt( |
| 139 std::unique_ptr<Buffer> buffer, | 139 Buffer buffer, |
| 140 const VideoCaptureFormat& format, | 140 const VideoCaptureFormat& format, |
| 141 base::TimeTicks reference_time, | 141 base::TimeTicks reference_time, |
| 142 base::TimeDelta timestamp, | 142 base::TimeDelta timestamp, |
| 143 gfx::Rect visible_rect, | 143 gfx::Rect visible_rect, |
| 144 const VideoFrameMetadata& additional_metadata) override { | 144 const VideoFrameMetadata& additional_metadata) override { |
| 145 DoOnIncomingCapturedVideoFrame(); | 145 DoOnIncomingCapturedVideoFrame(); |
| 146 } | 146 } |
| 147 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( | 147 Buffer ResurrectLastOutputBuffer(const gfx::Size& dimensions, |
| 148 const gfx::Size& dimensions, | 148 media::VideoPixelFormat format, |
| 149 media::VideoPixelFormat format, | 149 media::VideoPixelStorage storage, |
| 150 media::VideoPixelStorage storage, | 150 int frame_feedback_id) { |
| 151 int frame_feedback_id) { | |
| 152 DoResurrectLastOutputBuffer(); | 151 DoResurrectLastOutputBuffer(); |
| 153 NOTREACHED() << "This should never be called"; | 152 NOTREACHED() << "This should never be called"; |
| 154 return std::unique_ptr<Buffer>(); | 153 return Buffer(); |
| 155 } | 154 } |
| 156 | 155 |
| 157 private: | 156 private: |
| 158 scoped_refptr<base::SingleThreadTaskRunner> main_thread_; | 157 scoped_refptr<base::SingleThreadTaskRunner> main_thread_; |
| 159 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; | 158 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; |
| 160 }; | 159 }; |
| 161 | 160 |
| 162 class MockImageCaptureClient : public base::RefCounted<MockImageCaptureClient> { | 161 class MockImageCaptureClient : public base::RefCounted<MockImageCaptureClient> { |
| 163 public: | 162 public: |
| 164 // GMock doesn't support move-only arguments, so we use this forward method. | 163 // GMock doesn't support move-only arguments, so we use this forward method. |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 631 |
| 633 device->GetPhotoCapabilities(std::move(scoped_get_callback)); | 632 device->GetPhotoCapabilities(std::move(scoped_get_callback)); |
| 634 run_loop.Run(); | 633 run_loop.Run(); |
| 635 | 634 |
| 636 ASSERT_TRUE(image_capture_client_->capabilities()); | 635 ASSERT_TRUE(image_capture_client_->capabilities()); |
| 637 | 636 |
| 638 device->StopAndDeAllocate(); | 637 device->StopAndDeAllocate(); |
| 639 } | 638 } |
| 640 | 639 |
| 641 }; // namespace media | 640 }; // namespace media |
| OLD | NEW |