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..f906a0d4956e015d9222a81d30e79da8939aa3b0 |
| --- /dev/null |
| +++ b/media/capture/video/linux/camera_characteristics.h |
| @@ -0,0 +1,96 @@ |
| +// Copyright (c) 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 <vector> |
| + |
| +namespace media { |
| + |
| +// DeviceInfo can be found in /etc/camera/camera_characteristics.conf on device. |
| +struct DeviceInfo { |
| + static const int LENS_FACING_UNKNOWN = -1; |
|
wuchengli
2016/11/17 09:26:04
There's no LENS_FACING_UNKNOWN. This has to be con
shenghao
2016/11/17 10:15:55
Done.
|
| + static const int LENS_FACING_FRONT = 0; |
| + static const int LENS_FACING_BACK = 1; |
| + |
| + std::string device_path; // Ex. "/dev/video2" |
| + std::string usb_vid; // USB vender id |
| + std::string usb_pid; // USB product id |
| + uint32_t |
| + lens_facing; // Direction the camera faces relative to device screen. |
| + // Clockwise angle through which the output image needs to be rotated to be |
| + // upright on the device screen in its native orientation. |
| + int32_t sensor_orientation; |
| + // There might be some corrupted frames at the beginning after stream on. We |
| + // need to skip them. |
| + uint32_t frames_to_skip_after_streamon; |
| + float horizontal_view_angle_16_9; |
| + float horizontal_view_angle_4_3; |
| + std::vector<float> lens_info_available_focal_lengths; |
| + float lens_info_minimum_focus_distance; |
| + float lens_info_optimal_focus_distance; |
| + float vertical_view_angle_16_9; |
| + float vertical_view_angle_4_3; |
| +}; |
| + |
| +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: |
| +// 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. |
| +// |
| +// 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(); |
| + |
| + // Parses /etc/camera/camera_characteristics.conf. |
| + // Returns DeviceInfos with default characteristics if the config file doesn't |
| + // exist. |
| + const DeviceInfos GetCharacteristicsFromFile( |
| + const std::vector<std::string>& devices); |
| + |
| + // Get camera facing by specifying vid and pid. |model_id| should be formatted |
| + // as "vid:pid". |
| + // Returns DeviceInfo::LENS_FACING_FRONT, DeviceInfo::LENS_FACING_BACK or |
| + // DeviceInfo::UNKNOWN. |
| + int GetCameraFacing(const std::string& model_id); |
| + |
| + private: |
| + DeviceInfos device_infos_; |
| + |
| + void AddPerCameraCharacteristic(uint32_t camera_id, |
| + const char* characteristic, |
| + const char* value); |
| + void AddPerModuleCharacteristic(uint32_t camera_id, |
| + const char* characteristic, |
| + const char* value); |
| + void AddFloatValue(const char* value, |
| + const char* characteristic_name, |
| + float* characteristic); |
| +}; |
| + |
| +} // namespace arc |
| + |
| +#endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_ |