| 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 #ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_FACTORY_H_ | 5 #ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_FACTORY_H_ |
| 6 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_FACTORY_H_ | 6 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/threading/thread_checker.h" | 9 #include "base/threading/thread_checker.h" |
| 10 #include "media/capture/video/video_capture_device.h" | 10 #include "media/capture/video/video_capture_device.h" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 | 13 |
| 14 // VideoCaptureDeviceFactory is the base class for creation of video capture | 14 // VideoCaptureDeviceFactory is the base class for creation of video capture |
| 15 // devices in the different platforms. VCDFs are created by MediaStreamManager | 15 // devices in the different platforms. VCDFs are created by MediaStreamManager |
| 16 // on IO thread and plugged into VideoCaptureManager, who owns and operates them | 16 // on IO thread and plugged into VideoCaptureManager, who owns and operates them |
| 17 // in Device Thread (a.k.a. Audio Thread). | 17 // in Device Thread (a.k.a. Audio Thread). |
| 18 // Typical operation is to first call EnumerateDeviceDescriptors() to obtain | 18 // Typical operation is to first call GetDeviceDescriptors() to obtain |
| 19 // information about available devices. The obtained descriptors can then be | 19 // information about available devices. The obtained descriptors can then be |
| 20 // used to either obtain the supported formats of a device using | 20 // used to either obtain the supported formats of a device using |
| 21 // GetSupportedFormats(), or to create an instance of VideoCaptureDevice for | 21 // GetSupportedFormats(), or to create an instance of VideoCaptureDevice for |
| 22 // the device using CreateDevice(). | 22 // the device using CreateDevice(). |
| 23 // TODO(chfremer): Add a layer on top of the platform-specific implementations | 23 // TODO(chfremer): Add a layer on top of the platform-specific implementations |
| 24 // that uses strings instead of descriptors as keys for accessing devices. | 24 // that uses strings instead of descriptors as keys for accessing devices. |
| 25 // crbug.com/665065 | 25 // crbug.com/665065 |
| 26 class CAPTURE_EXPORT VideoCaptureDeviceFactory { | 26 class CAPTURE_EXPORT VideoCaptureDeviceFactory { |
| 27 public: | 27 public: |
| 28 static std::unique_ptr<VideoCaptureDeviceFactory> CreateFactory( | 28 static std::unique_ptr<VideoCaptureDeviceFactory> CreateFactory( |
| 29 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 29 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
| 30 | 30 |
| 31 VideoCaptureDeviceFactory(); | 31 VideoCaptureDeviceFactory(); |
| 32 virtual ~VideoCaptureDeviceFactory(); | 32 virtual ~VideoCaptureDeviceFactory(); |
| 33 | 33 |
| 34 // Creates a VideoCaptureDevice object. Returns NULL if something goes wrong. | 34 // Creates a VideoCaptureDevice object. Returns NULL if something goes wrong. |
| 35 virtual std::unique_ptr<VideoCaptureDevice> CreateDevice( | 35 virtual std::unique_ptr<VideoCaptureDevice> CreateDevice( |
| 36 const VideoCaptureDeviceDescriptor& device_descriptor) = 0; | 36 const VideoCaptureDeviceDescriptor& device_descriptor) = 0; |
| 37 | 37 |
| 38 // Asynchronous version of GetDeviceDescriptors calling back to |callback|. | |
| 39 virtual void EnumerateDeviceDescriptors( | |
| 40 const base::Callback< | |
| 41 void(std::unique_ptr<VideoCaptureDeviceDescriptors>)>& callback); | |
| 42 | |
| 43 // Obtains the supported formats of a device. | 38 // Obtains the supported formats of a device. |
| 44 // This method should be called before allocating or starting a device. In | 39 // This method should be called before allocating or starting a device. In |
| 45 // case format enumeration is not supported, or there was a problem | 40 // case format enumeration is not supported, or there was a problem |
| 46 // |supported_formats| will be empty. | 41 // |supported_formats| will be empty. |
| 47 virtual void GetSupportedFormats( | 42 virtual void GetSupportedFormats( |
| 48 const VideoCaptureDeviceDescriptor& device_descriptor, | 43 const VideoCaptureDeviceDescriptor& device_descriptor, |
| 49 VideoCaptureFormats* supported_formats) = 0; | 44 VideoCaptureFormats* supported_formats) = 0; |
| 50 | 45 |
| 51 // Gets descriptors of all video capture devices connected. | 46 // Gets descriptors of all video capture devices connected. |
| 52 // Used by the default implementation of EnumerateDevices(). | 47 // Used by the default implementation of EnumerateDevices(). |
| 53 // Note: The same physical device may appear more than once if it is | 48 // Note: The same physical device may appear more than once if it is |
| 54 // accessible through different APIs. | 49 // accessible through different APIs. |
| 55 virtual void GetDeviceDescriptors( | 50 virtual void GetDeviceDescriptors( |
| 56 VideoCaptureDeviceDescriptors* device_descriptors) = 0; | 51 VideoCaptureDeviceDescriptors* device_descriptors) = 0; |
| 57 | 52 |
| 58 protected: | 53 protected: |
| 59 base::ThreadChecker thread_checker_; | 54 base::ThreadChecker thread_checker_; |
| 60 | 55 |
| 61 private: | 56 private: |
| 62 static VideoCaptureDeviceFactory* CreateVideoCaptureDeviceFactory( | 57 static VideoCaptureDeviceFactory* CreateVideoCaptureDeviceFactory( |
| 63 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 58 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
| 64 | 59 |
| 65 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceFactory); | 60 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceFactory); |
| 66 }; | 61 }; |
| 67 | 62 |
| 68 } // namespace media | 63 } // namespace media |
| 69 | 64 |
| 70 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_FACTORY_H_ | 65 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_FACTORY_H_ |
| OLD | NEW |