| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_SYSTEM_H_ | 5 #ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_SYSTEM_H_ |
| 6 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_SYSTEM_H_ | 6 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_SYSTEM_H_ |
| 7 | 7 |
| 8 #include "media/capture/video/video_capture_device_factory.h" | 8 #include "media/capture/video/video_capture_device_factory.h" |
| 9 #include "media/capture/video/video_capture_device_info.h" | 9 #include "media/capture/video/video_capture_device_info.h" |
| 10 | 10 |
| 11 namespace media { | 11 namespace media { |
| 12 | 12 |
| 13 // Layer on top of VideoCaptureDeviceFactory that translates device descriptors | |
| 14 // to string identifiers and consolidates and caches device descriptors and | |
| 15 // supported formats into VideoCaptureDeviceInfos. | |
| 16 class CAPTURE_EXPORT VideoCaptureSystem { | 13 class CAPTURE_EXPORT VideoCaptureSystem { |
| 17 public: | 14 public: |
| 18 using DeviceInfoCallback = | 15 using DeviceInfoCallback = |
| 19 base::Callback<void(const std::vector<VideoCaptureDeviceInfo>&)>; | 16 base::Callback<void(const std::vector<VideoCaptureDeviceInfo>&)>; |
| 20 | 17 |
| 21 explicit VideoCaptureSystem( | 18 virtual ~VideoCaptureSystem() {} |
| 22 std::unique_ptr<VideoCaptureDeviceFactory> factory); | |
| 23 ~VideoCaptureSystem(); | |
| 24 | 19 |
| 25 // The passed-in |result_callback| must have ownership of the called | 20 // The passed-in |result_callback| must have ownership of the called |
| 26 // VideoCaptureSystem instance to guarantee that it stays alive during the | 21 // VideoCaptureSystem instance to guarantee that it stays alive during the |
| 27 // asynchronous operation. | 22 // asynchronous operation. |
| 28 void GetDeviceInfosAsync(const DeviceInfoCallback& result_callback); | 23 virtual void GetDeviceInfosAsync( |
| 24 const DeviceInfoCallback& result_callback) = 0; |
| 29 | 25 |
| 30 // Creates a VideoCaptureDevice object. Returns nullptr if something goes | 26 // Creates a VideoCaptureDevice object. Returns nullptr if something goes |
| 31 // wrong. | 27 // wrong. |
| 32 std::unique_ptr<VideoCaptureDevice> CreateDevice( | 28 virtual std::unique_ptr<VideoCaptureDevice> CreateDevice( |
| 33 const std::string& device_id); | 29 const std::string& device_id) = 0; |
| 34 | |
| 35 media::VideoCaptureDeviceFactory* video_capture_device_factory() const { | |
| 36 return factory_.get(); | |
| 37 } | |
| 38 | |
| 39 private: | |
| 40 void OnDescriptorsReceived( | |
| 41 const DeviceInfoCallback& result_callback, | |
| 42 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors); | |
| 43 | |
| 44 // Returns nullptr if no descriptor found. | |
| 45 const VideoCaptureDeviceInfo* LookupDeviceInfoFromId( | |
| 46 const std::string& device_id); | |
| 47 | |
| 48 const std::unique_ptr<VideoCaptureDeviceFactory> factory_; | |
| 49 std::vector<VideoCaptureDeviceInfo> devices_info_cache_; | |
| 50 | |
| 51 base::ThreadChecker thread_checker_; | |
| 52 }; | 30 }; |
| 53 | 31 |
| 54 } // namespace media | 32 } // namespace media |
| 55 | 33 |
| 56 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_FACTORY_H_ | 34 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_SYSTEM_H_ |
| OLD | NEW |