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