Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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_LINUX_CAMERA_CHARACTERISTICS_H_ | |
| 6 #define MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 #include <string> | |
| 10 #include <unordered_map> | |
| 11 #include <vector> | |
| 12 | |
| 13 namespace media { | |
| 14 | |
| 15 // DeviceInfo can be found in /etc/camera/camera_characteristics.conf on device. | |
| 16 struct DeviceInfo { | |
|
kcwu
2016/11/21 07:59:25
s/DeviceInfo/CameraDeviceInfo/
DeviceInfo seems to
wuchengli
2016/11/22 03:47:06
+1
shenghao
2016/11/24 07:13:04
Done.
| |
| 17 static const int LENS_FACING_FRONT = 0; | |
| 18 static const int LENS_FACING_BACK = 1; | |
| 19 // USB vender id and product id in "pid:vid" format. | |
| 20 std::string vid_pid; | |
| 21 // Direction the camera faces relative to device screen. | |
| 22 uint32_t lens_facing; | |
| 23 }; | |
| 24 | |
| 25 typedef std::vector<DeviceInfo> DeviceInfos; | |
| 26 | |
| 27 // CameraCharacteristics reads the file /etc/camera/camera_characteristics.conf | |
| 28 // and stores the content in |device_infos_|. There are several assumptions of | |
| 29 // the config file: | |
|
kcwu
2016/11/21 07:59:24
Please relax these rules as possible as you can. O
wuchengli
2016/11/21 08:56:03
Why relaxing the rules? We don't need the flexibil
| |
| 30 // 1. Each line should be at most 256 characters long. | |
| 31 // 2. camera id should be in ascending order (i.e., 0, 1, 2, ...). | |
| 32 // 3. usb_vid_pid should be the first subkey. | |
| 33 // 4. All configs of a module should be put together. | |
| 34 // 5. lens_facing should be put before any modules for a camera | |
|
wuchengli
2016/11/22 07:59:34
As discussed offline, let's remove all these const
shenghao
2016/11/24 07:13:04
Done.
| |
| 35 // | |
| 36 // Example of the config file: | |
| 37 // camera0.lens_facing=0 | |
| 38 // camera0.sensor_orientation=0 | |
| 39 // camera0.module0.usb_vid_pid=0123:4567 | |
| 40 // camera0.module0.horizontal_view_angle=68.4 | |
| 41 // camera0.module0.lens_info_available_focal_lengths=1.64 | |
| 42 // camera0.module0.lens_info_minimum_focus_distance=0.22 | |
| 43 // camera0.module0.lens_info_optimal_focus_distance=0.5 | |
| 44 // camera0.module0.vertical_view_angle=41.6 | |
| 45 // camera0.module1.usb_vid_pid=89ab:cdef | |
| 46 // camera0.module1.lens_info_available_focal_lengths=1.69,2 | |
| 47 // camera1.lens_facing=1 | |
| 48 // camera1.sensor_orientation=180 | |
| 49 class CameraCharacteristics { | |
| 50 public: | |
| 51 CameraCharacteristics(); | |
| 52 ~CameraCharacteristics(); | |
| 53 | |
| 54 // Get camera facing by specifying vid and pid. |model_id| should be formatted | |
|
wuchengli
2016/11/22 03:47:06
s/vid/USB vid/
shenghao
2016/11/24 07:13:04
Done.
| |
| 55 // as "vid:pid". | |
| 56 // Returns DeviceInfo::LENS_FACING_FRONT or DeviceInfo::LENS_FACING_BACK. | |
| 57 // Default is DeviceInfo::LENS_FACING_FRONT. | |
| 58 int GetCameraFacing(const std::string& model_id); | |
| 59 | |
| 60 private: | |
| 61 std::unordered_map<std::string, DeviceInfo> GetDeviceInfoFromFile(); | |
| 62 }; | |
| 63 | |
| 64 } // namespace arc | |
| 65 | |
| 66 #endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_ | |
| OLD | NEW |