Chromium Code Reviews| Index: media/capture/video/linux/camera_characteristics.h |
| diff --git a/media/capture/video/linux/camera_characteristics.h b/media/capture/video/linux/camera_characteristics.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bca94c8da59482e734b48b54c72ebb2a84ea6726 |
| --- /dev/null |
| +++ b/media/capture/video/linux/camera_characteristics.h |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_ |
| +#define MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_ |
| + |
| +#include <stddef.h> |
| +#include <string> |
| +#include <unordered_map> |
| +#include <vector> |
| + |
| +namespace media { |
| + |
| +// DeviceInfo can be found in /etc/camera/camera_characteristics.conf on device. |
| +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.
|
| + static const int LENS_FACING_FRONT = 0; |
| + static const int LENS_FACING_BACK = 1; |
| + // USB vender id and product id in "pid:vid" format. |
| + std::string vid_pid; |
| + // Direction the camera faces relative to device screen. |
| + uint32_t lens_facing; |
| +}; |
| + |
| +typedef std::vector<DeviceInfo> DeviceInfos; |
| + |
| +// CameraCharacteristics reads the file /etc/camera/camera_characteristics.conf |
| +// and stores the content in |device_infos_|. There are several assumptions of |
| +// 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
|
| +// 1. Each line should be at most 256 characters long. |
| +// 2. camera id should be in ascending order (i.e., 0, 1, 2, ...). |
| +// 3. usb_vid_pid should be the first subkey. |
| +// 4. All configs of a module should be put together. |
| +// 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.
|
| +// |
| +// Example of the config file: |
| +// camera0.lens_facing=0 |
| +// camera0.sensor_orientation=0 |
| +// camera0.module0.usb_vid_pid=0123:4567 |
| +// camera0.module0.horizontal_view_angle=68.4 |
| +// camera0.module0.lens_info_available_focal_lengths=1.64 |
| +// camera0.module0.lens_info_minimum_focus_distance=0.22 |
| +// camera0.module0.lens_info_optimal_focus_distance=0.5 |
| +// camera0.module0.vertical_view_angle=41.6 |
| +// camera0.module1.usb_vid_pid=89ab:cdef |
| +// camera0.module1.lens_info_available_focal_lengths=1.69,2 |
| +// camera1.lens_facing=1 |
| +// camera1.sensor_orientation=180 |
| +class CameraCharacteristics { |
| + public: |
| + CameraCharacteristics(); |
| + ~CameraCharacteristics(); |
| + |
| + // 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.
|
| + // as "vid:pid". |
| + // Returns DeviceInfo::LENS_FACING_FRONT or DeviceInfo::LENS_FACING_BACK. |
| + // Default is DeviceInfo::LENS_FACING_FRONT. |
| + int GetCameraFacing(const std::string& model_id); |
| + |
| + private: |
| + std::unordered_map<std::string, DeviceInfo> GetDeviceInfoFromFile(); |
| +}; |
| + |
| +} // namespace arc |
| + |
| +#endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_ |