1 /* 2 * Copyright 2015 The Chromium OS Authors. All rights reserved. 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 */ 6 7 #ifndef COMMON_TYPES_H_ 8 #define COMMON_TYPES_H_ 9 10 #include <string> 11 #include <vector> 12 13 #include <base/logging.h> 14 15 #define LOGF(level) LOG(level) << __FUNCTION__ << "(): " 16 #define VLOGF(level) VLOG(level) << __FUNCTION__ << "(): " 17 18 // The definition should match camera_metadata_enum_android_lens_facing_t 19 // in camera_metadata_tags.h. 20 enum lens_facing { 21 FACING_FRONT, 22 FACING_BACK, 23 }; 24 25 // The types in this file should match Android camera HAL. 26 27 struct DeviceInfo { 28 int camera_id; 29 30 // TODO(shik): Change this to base::FilePath. 31 // ex: /dev/video0 32 std::string device_path; 33 34 // USB vendor id, the emulated vivid devices do not have this field. 35 std::string usb_vid; 36 37 // USB product id, the emulated vivid devices do not have this field. 38 std::string usb_pid; 39 40 // Some cameras need to wait several frames to output correct images. 41 uint32_t frames_to_skip_after_streamon = 0; 42 43 // The camera doesn't support constant frame rate. That means HAL cannot set 44 // V4L2_CID_EXPOSURE_AUTO_PRIORITY to 0 to have constant frame rate in low 45 // light environment. 46 bool constant_framerate_unsupported = false; 47 48 // Member definitions can be found in https://developer.android.com/ 49 // reference/android/hardware/camera2/CameraCharacteristics.html 50 uint32_t lens_facing = FACING_FRONT; 51 int32_t sensor_orientation = 0; 52 53 // These fields are not available for external cameras. 54 std::vector<float> lens_info_available_apertures; 55 std::vector<float> lens_info_available_focal_lengths; 56 float lens_info_minimum_focus_distance; 57 float lens_info_optimal_focus_distance; 58 int32_t sensor_info_pixel_array_size_width; 59 int32_t sensor_info_pixel_array_size_height; 60 float sensor_info_physical_size_width; 61 float sensor_info_physical_size_height; 62 63 // FOV parameters for HAL v1. 64 float horizontal_view_angle_16_9; 65 float horizontal_view_angle_4_3; 66 float vertical_view_angle_16_9; 67 float vertical_view_angle_4_3; 68 }; 69 70 typedef std::vector<DeviceInfo> DeviceInfos; 71 72 struct SupportedFormat { SupportedFormatSupportedFormat73 SupportedFormat() {} SupportedFormatSupportedFormat74 SupportedFormat(uint32_t w, uint32_t h, uint32_t fmt, uint32_t fps) 75 : width(w), height(h), fourcc(fmt) { 76 frame_rates.push_back(fps); 77 } 78 uint32_t width; 79 uint32_t height; 80 uint32_t fourcc; 81 // All the supported frame rates in fps with given width, height, and 82 // pixelformat. This is not sorted. For example, suppose width, height, and 83 // fourcc are 640x480 YUYV. If frameRates are 15.0 and 30.0, the camera 84 // supports outputting 640X480 YUYV in 15fps or 30fps. 85 std::vector<float> frame_rates; 86 }; 87 88 typedef std::vector<SupportedFormat> SupportedFormats; 89 90 #endif 91