| 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 // Implementation of a fake VideoCaptureDevice class. Used for testing other | 5 // Implementation of a fake VideoCaptureDevice class. Used for testing other |
| 6 // video capture classes when no real hardware is available. | 6 // video capture classes when no real hardware is available. |
| 7 | 7 |
| 8 #ifndef MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_H_ | 8 #ifndef DEVICE_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_H_ |
| 9 #define MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_H_ | 9 #define DEVICE_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_H_ |
| 10 | 10 |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <string> | 14 #include <string> |
| 15 | 15 |
| 16 #include "base/atomicops.h" | 16 #include "base/atomicops.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "media/capture/video/video_capture_device.h" | 21 #include "device/capture/video/video_capture_device.h" |
| 22 | 22 |
| 23 namespace media { | 23 namespace device { |
| 24 | 24 |
| 25 class CAPTURE_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice { | 25 class CAPTURE_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice { |
| 26 public: | 26 public: |
| 27 enum class BufferOwnership { | 27 enum class BufferOwnership { |
| 28 OWN_BUFFERS, | 28 OWN_BUFFERS, |
| 29 CLIENT_BUFFERS, | 29 CLIENT_BUFFERS, |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 FakeVideoCaptureDevice(BufferOwnership buffer_ownership, | 32 FakeVideoCaptureDevice(BufferOwnership buffer_ownership, |
| 33 float fake_capture_rate); | 33 float fake_capture_rate); |
| 34 ~FakeVideoCaptureDevice() override; | 34 ~FakeVideoCaptureDevice() override; |
| 35 | 35 |
| 36 // VideoCaptureDevice implementation. | 36 // VideoCaptureDevice implementation. |
| 37 void AllocateAndStart(const VideoCaptureParams& params, | 37 void AllocateAndStart(const VideoCaptureParams& params, |
| 38 std::unique_ptr<Client> client) override; | 38 std::unique_ptr<Client> client) override; |
| 39 void StopAndDeAllocate() override; | 39 void StopAndDeAllocate() override; |
| 40 void GetPhotoCapabilities(GetPhotoCapabilitiesCallback callback) override; | 40 void GetPhotoCapabilities(GetPhotoCapabilitiesCallback callback) override; |
| 41 void SetPhotoOptions(mojom::PhotoSettingsPtr settings, | 41 void SetPhotoOptions(media::mojom::PhotoSettingsPtr settings, |
| 42 SetPhotoOptionsCallback callback) override; | 42 SetPhotoOptionsCallback callback) override; |
| 43 void TakePhoto(TakePhotoCallback callback) override; | 43 void TakePhoto(TakePhotoCallback callback) override; |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 void CaptureUsingOwnBuffers(base::TimeTicks expected_execution_time); | 46 void CaptureUsingOwnBuffers(base::TimeTicks expected_execution_time); |
| 47 void CaptureUsingClientBuffers(base::TimeTicks expected_execution_time); | 47 void CaptureUsingClientBuffers(base::TimeTicks expected_execution_time); |
| 48 void BeepAndScheduleNextCapture( | 48 void BeepAndScheduleNextCapture( |
| 49 base::TimeTicks expected_execution_time, | 49 base::TimeTicks expected_execution_time, |
| 50 const base::Callback<void(base::TimeTicks)>& next_capture); | 50 const base::Callback<void(base::TimeTicks)>& next_capture); |
| 51 | 51 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 70 | 70 |
| 71 // The system time when we receive the first frame. | 71 // The system time when we receive the first frame. |
| 72 base::TimeTicks first_ref_time_; | 72 base::TimeTicks first_ref_time_; |
| 73 // FakeVideoCaptureDevice post tasks to itself for frame construction and | 73 // FakeVideoCaptureDevice post tasks to itself for frame construction and |
| 74 // needs to deal with asynchronous StopAndDeallocate(). | 74 // needs to deal with asynchronous StopAndDeallocate(). |
| 75 base::WeakPtrFactory<FakeVideoCaptureDevice> weak_factory_; | 75 base::WeakPtrFactory<FakeVideoCaptureDevice> weak_factory_; |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice); | 77 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace media | 80 } // namespace device |
| 81 | 81 |
| 82 #endif // MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_H_ | 82 #endif // DEVICE_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_H_ |
| OLD | NEW |