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); | 19 virtual void GetDeviceInfosAsync( |
23 ~VideoCaptureSystem(); | 20 const DeviceInfoCallback& result_callback) = 0; |
24 | |
25 void GetDeviceInfosAsync(const DeviceInfoCallback& result_callback); | |
26 | 21 |
27 // Creates a VideoCaptureDevice object. Returns nullptr if something goes | 22 // Creates a VideoCaptureDevice object. Returns nullptr if something goes |
28 // wrong. | 23 // wrong. |
24 virtual std::unique_ptr<VideoCaptureDevice> CreateDevice( | |
25 const std::string& device_id) = 0; | |
26 }; | |
27 | |
28 // Layer on top of VideoCaptureDeviceFactory that translates device descriptors | |
29 // to string identifiers and consolidates and caches device descriptors and | |
30 // supported formats into VideoCaptureDeviceInfos. | |
31 class CAPTURE_EXPORT VideoCaptureSystemImpl : public VideoCaptureSystem { | |
miu
2017/04/03 21:31:24
Should this be in a separate video_capture_system_
chfremer
2017/04/04 21:59:32
Done.
| |
32 public: | |
33 explicit VideoCaptureSystemImpl( | |
34 std::unique_ptr<VideoCaptureDeviceFactory> factory); | |
35 ~VideoCaptureSystemImpl() override; | |
36 | |
37 void GetDeviceInfosAsync(const DeviceInfoCallback& result_callback) override; | |
29 std::unique_ptr<VideoCaptureDevice> CreateDevice( | 38 std::unique_ptr<VideoCaptureDevice> CreateDevice( |
30 const std::string& device_id); | 39 const std::string& device_id) override; |
31 | |
32 media::VideoCaptureDeviceFactory* video_capture_device_factory() const { | |
33 return factory_.get(); | |
34 } | |
35 | 40 |
36 private: | 41 private: |
37 void OnDescriptorsReceived( | 42 void OnDescriptorsReceived( |
38 const DeviceInfoCallback& result_callback, | 43 const DeviceInfoCallback& result_callback, |
39 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors); | 44 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors); |
40 | 45 |
41 // Returns nullptr if no descriptor found. | 46 // Returns nullptr if no descriptor found. |
42 const VideoCaptureDeviceInfo* LookupDeviceInfoFromId( | 47 const VideoCaptureDeviceInfo* LookupDeviceInfoFromId( |
43 const std::string& device_id); | 48 const std::string& device_id); |
44 | 49 |
45 const std::unique_ptr<VideoCaptureDeviceFactory> factory_; | 50 const std::unique_ptr<VideoCaptureDeviceFactory> factory_; |
46 std::vector<VideoCaptureDeviceInfo> devices_info_cache_; | 51 std::vector<VideoCaptureDeviceInfo> devices_info_cache_; |
47 }; | 52 }; |
48 | 53 |
49 } // namespace media | 54 } // namespace media |
50 | 55 |
51 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_FACTORY_H_ | 56 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_FACTORY_H_ |
OLD | NEW |