| 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 // VideoCaptureDevice is the abstract base class for realizing video capture | 5 // VideoCaptureDevice is the abstract base class for realizing video capture |
| 6 // device support in Chromium. It provides the interface for OS dependent | 6 // device support in Chromium. It provides the interface for OS dependent |
| 7 // implementations. | 7 // implementations. |
| 8 // The class is created and functions are invoked on a thread owned by | 8 // The class is created and functions are invoked on a thread owned by |
| 9 // VideoCaptureManager. Capturing is done on other threads, depending on the OS | 9 // VideoCaptureManager. Capturing is done on other threads, depending on the OS |
| 10 // specific implementation. | 10 // specific implementation. |
| 11 | 11 |
| 12 #ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_H_ | 12 #ifndef DEVICE_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_H_ |
| 13 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_H_ | 13 #define DEVICE_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_H_ |
| 14 | 14 |
| 15 #include <stddef.h> | 15 #include <stddef.h> |
| 16 #include <stdint.h> | 16 #include <stdint.h> |
| 17 | 17 |
| 18 #include <list> | 18 #include <list> |
| 19 #include <memory> | 19 #include <memory> |
| 20 #include <string> | 20 #include <string> |
| 21 | 21 |
| 22 #include "base/callback.h" | 22 #include "base/callback.h" |
| 23 #include "base/files/file.h" | 23 #include "base/files/file.h" |
| 24 #include "base/logging.h" | 24 #include "base/logging.h" |
| 25 #include "base/memory/ref_counted.h" | 25 #include "base/memory/ref_counted.h" |
| 26 #include "base/single_thread_task_runner.h" | 26 #include "base/single_thread_task_runner.h" |
| 27 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 28 #include "build/build_config.h" | 28 #include "build/build_config.h" |
| 29 #include "device/capture/capture_export.h" |
| 30 #include "device/capture/video/scoped_result_callback.h" |
| 31 #include "device/capture/video/video_capture_device_descriptor.h" |
| 29 #include "media/base/video_capture_types.h" | 32 #include "media/base/video_capture_types.h" |
| 30 #include "media/base/video_frame.h" | 33 #include "media/base/video_frame.h" |
| 31 #include "media/capture/capture_export.h" | |
| 32 #include "media/capture/video/scoped_result_callback.h" | |
| 33 #include "media/capture/video/video_capture_device_descriptor.h" | |
| 34 #include "media/mojo/interfaces/image_capture.mojom.h" | 34 #include "media/mojo/interfaces/image_capture.mojom.h" |
| 35 #include "mojo/public/cpp/bindings/array.h" | 35 #include "mojo/public/cpp/bindings/array.h" |
| 36 #include "ui/gfx/gpu_memory_buffer.h" | 36 #include "ui/gfx/gpu_memory_buffer.h" |
| 37 | 37 |
| 38 namespace tracked_objects { | 38 namespace tracked_objects { |
| 39 class Location; | 39 class Location; |
| 40 } // namespace tracked_objects | 40 } // namespace tracked_objects |
| 41 | 41 |
| 42 namespace media { | 42 namespace device { |
| 43 |
| 44 using media::VideoCaptureFormat; |
| 45 using media::VideoCaptureFormats; |
| 46 using media::VideoCaptureParams; |
| 47 using media::VideoFrame; |
| 48 using media::VideoFrameMetadata; |
| 49 using media::VideoPixelFormat; |
| 50 using media::VideoPixelStorage; |
| 43 | 51 |
| 44 class CAPTURE_EXPORT VideoCaptureDevice { | 52 class CAPTURE_EXPORT VideoCaptureDevice { |
| 45 public: | 53 public: |
| 46 | 54 |
| 47 // Interface defining the methods that clients of VideoCapture must have. It | 55 // Interface defining the methods that clients of VideoCapture must have. It |
| 48 // is actually two-in-one: clients may implement OnIncomingCapturedData() or | 56 // is actually two-in-one: clients may implement OnIncomingCapturedData() or |
| 49 // ReserveOutputBuffer() + OnIncomingCapturedVideoFrame(), or all of them. | 57 // ReserveOutputBuffer() + OnIncomingCapturedVideoFrame(), or all of them. |
| 50 // All clients must implement OnError(). | 58 // All clients must implement OnError(). |
| 51 class CAPTURE_EXPORT Client { | 59 class CAPTURE_EXPORT Client { |
| 52 public: | 60 public: |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // memory associated with capture, and delete the |client| pointer passed into | 182 // memory associated with capture, and delete the |client| pointer passed into |
| 175 // AllocateAndStart. | 183 // AllocateAndStart. |
| 176 // | 184 // |
| 177 // If deallocation is done asynchronously, then the device implementation must | 185 // If deallocation is done asynchronously, then the device implementation must |
| 178 // ensure that a subsequent AllocateAndStart() operation targeting the same ID | 186 // ensure that a subsequent AllocateAndStart() operation targeting the same ID |
| 179 // would be sequenced through the same task runner, so that deallocation | 187 // would be sequenced through the same task runner, so that deallocation |
| 180 // happens first. | 188 // happens first. |
| 181 virtual void StopAndDeAllocate() = 0; | 189 virtual void StopAndDeAllocate() = 0; |
| 182 | 190 |
| 183 // Retrieve the photo capabilities of the device (e.g. zoom levels etc). | 191 // Retrieve the photo capabilities of the device (e.g. zoom levels etc). |
| 184 using GetPhotoCapabilitiesCallback = | 192 using GetPhotoCapabilitiesCallback = ScopedResultCallback< |
| 185 ScopedResultCallback<base::Callback<void(mojom::PhotoCapabilitiesPtr)>>; | 193 base::Callback<void(media::mojom::PhotoCapabilitiesPtr)>>; |
| 186 virtual void GetPhotoCapabilities(GetPhotoCapabilitiesCallback callback); | 194 virtual void GetPhotoCapabilities(GetPhotoCapabilitiesCallback callback); |
| 187 | 195 |
| 188 using SetPhotoOptionsCallback = | 196 using SetPhotoOptionsCallback = |
| 189 ScopedResultCallback<base::Callback<void(bool)>>; | 197 ScopedResultCallback<base::Callback<void(bool)>>; |
| 190 virtual void SetPhotoOptions(mojom::PhotoSettingsPtr settings, | 198 virtual void SetPhotoOptions(media::mojom::PhotoSettingsPtr settings, |
| 191 SetPhotoOptionsCallback callback); | 199 SetPhotoOptionsCallback callback); |
| 192 | 200 |
| 193 // Asynchronously takes a photo, possibly reconfiguring the capture objects | 201 // Asynchronously takes a photo, possibly reconfiguring the capture objects |
| 194 // and/or interrupting the capture flow. Runs |callback| on the thread | 202 // and/or interrupting the capture flow. Runs |callback| on the thread |
| 195 // where TakePhoto() is called, if the photo was successfully taken. | 203 // where TakePhoto() is called, if the photo was successfully taken. |
| 196 using TakePhotoCallback = | 204 using TakePhotoCallback = |
| 197 ScopedResultCallback<base::Callback<void(mojom::BlobPtr blob)>>; | 205 ScopedResultCallback<base::Callback<void(media::mojom::BlobPtr blob)>>; |
| 198 virtual void TakePhoto(TakePhotoCallback callback); | 206 virtual void TakePhoto(TakePhotoCallback callback); |
| 199 | 207 |
| 200 // Gets the power line frequency, either from the params if specified by the | 208 // Gets the power line frequency, either from the params if specified by the |
| 201 // user or from the current system time zone. | 209 // user or from the current system time zone. |
| 202 PowerLineFrequency GetPowerLineFrequency( | 210 media::PowerLineFrequency GetPowerLineFrequency( |
| 203 const VideoCaptureParams& params) const; | 211 const VideoCaptureParams& params) const; |
| 204 | 212 |
| 205 private: | 213 private: |
| 206 // Gets the power line frequency from the current system time zone if this is | 214 // Gets the power line frequency from the current system time zone if this is |
| 207 // defined, otherwise returns 0. | 215 // defined, otherwise returns 0. |
| 208 PowerLineFrequency GetPowerLineFrequencyForLocation() const; | 216 media::PowerLineFrequency GetPowerLineFrequencyForLocation() const; |
| 209 }; | 217 }; |
| 210 | 218 |
| 211 } // namespace media | 219 } // namespace device |
| 212 | 220 |
| 213 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_H_ | 221 #endif // DEVICE_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_H_ |
| OLD | NEW |