OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_LINUX_CAMERA_FACING_CHROMEOS_H_ | 5 #ifndef MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_FACING_CHROMEOS_H_ |
6 #define MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_FACING_CHROMEOS_H_ | 6 #define MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_FACING_CHROMEOS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <unordered_map> | 11 #include <unordered_map> |
12 | 12 |
13 #include <base/strings/string_piece.h> | 13 #include <base/strings/string_piece.h> |
| 14 #include "media/base/video_facing.h" |
14 #include "media/capture/capture_export.h" | 15 #include "media/capture/capture_export.h" |
15 | 16 |
16 namespace media { | 17 namespace media { |
17 | 18 |
18 // CameraFacingChromeOS reads the file /etc/camera/camera_characteristics.conf | 19 // CameraFacingChromeOS reads the file /etc/camera/camera_characteristics.conf |
19 // and populates |camera_id_to_facing_|, |usb_id_to_camera_id_| and | 20 // and populates |camera_id_to_facing_|, |usb_id_to_camera_id_| and |
20 // |model_id_to_camera_id_|. | 21 // |model_id_to_camera_id_|. |
21 // | 22 // |
22 // Each line in the config file can be: | 23 // Each line in the config file can be: |
23 // 1. Empty line | 24 // 1. Empty line |
(...skipping 18 matching lines...) Expand all Loading... |
42 // camera0.module0.lens_info_available_focal_lengths=1.64 | 43 // camera0.module0.lens_info_available_focal_lengths=1.64 |
43 // camera0.module0.lens_info_minimum_focus_distance=0.22 | 44 // camera0.module0.lens_info_minimum_focus_distance=0.22 |
44 // camera0.module0.lens_info_optimal_focus_distance=0.5 | 45 // camera0.module0.lens_info_optimal_focus_distance=0.5 |
45 // camera0.module0.vertical_view_angle=41.6 | 46 // camera0.module0.vertical_view_angle=41.6 |
46 // camera0.module1.usb_vid_pid=89ab:cdef | 47 // camera0.module1.usb_vid_pid=89ab:cdef |
47 // camera0.module1.lens_info_available_focal_lengths=1.69,2 | 48 // camera0.module1.lens_info_available_focal_lengths=1.69,2 |
48 // camera1.lens_facing=1 | 49 // camera1.lens_facing=1 |
49 // camera1.sensor_orientation=180 | 50 // camera1.sensor_orientation=180 |
50 class CAPTURE_EXPORT CameraFacingChromeOS { | 51 class CAPTURE_EXPORT CameraFacingChromeOS { |
51 public: | 52 public: |
52 enum LensFacing { FRONT = 0, BACK = 1 }; | |
53 | |
54 CameraFacingChromeOS(); | 53 CameraFacingChromeOS(); |
55 CAPTURE_EXPORT CameraFacingChromeOS(const std::string& config_file_path); | 54 CAPTURE_EXPORT CameraFacingChromeOS(const std::string& config_file_path); |
56 CAPTURE_EXPORT ~CameraFacingChromeOS(); | 55 CAPTURE_EXPORT ~CameraFacingChromeOS(); |
57 | 56 |
58 // Get camera facing by specifying USB vid and pid and device path. |model_id| | 57 // Get camera facing by specifying USB vid and pid and device path. |model_id| |
59 // should be formatted as "vid:pid". |device_id| is something like | 58 // should be formatted as "vid:pid". |device_id| is something like |
60 // "/dev/video2". It first tries to match usb path, obtained from |device_id|. | 59 // "/dev/video2". It first tries to match usb path, obtained from |device_id|. |
61 // If fails, |model_id| is then used. | 60 // If fails, |model_id| is then used. |
62 // Returns LensFacing::FRONT or LensFacing::BACK. | 61 CAPTURE_EXPORT VideoFacingMode |
63 // Default is LensFacing::FRONT. | 62 GetCameraFacing(const std::string& device_id, |
64 CAPTURE_EXPORT LensFacing GetCameraFacing(const std::string& device_id, | 63 const std::string& model_id) const; |
65 const std::string& model_id) const; | |
66 | 64 |
67 static const LensFacing kLensFacingDefault = LensFacing::FRONT; | 65 static const VideoFacingMode kLensFacingDefault = |
| 66 VideoFacingMode::MEDIA_VIDEO_FACING_NONE; |
68 | 67 |
69 private: | 68 private: |
70 std::string GetUsbId(const std::string& device_id) const; | 69 std::string GetUsbId(const std::string& device_id) const; |
71 // Read file content and populate |camera_id_to_facing_|, | 70 // Read file content and populate |camera_id_to_facing_|, |
72 // |usb_id_to_camera_id_| and |model_id_to_camera_id_|. | 71 // |usb_id_to_camera_id_| and |model_id_to_camera_id_|. |
73 void InitializeDeviceInfo(const std::string& config_file_path); | 72 void InitializeDeviceInfo(const std::string& config_file_path); |
74 | 73 |
75 std::unordered_map<int, LensFacing> camera_id_to_facing_; | 74 std::unordered_map<int, VideoFacingMode> camera_id_to_facing_; |
76 std::unordered_map<std::string, int> usb_id_to_camera_id_; | 75 std::unordered_map<std::string, int> usb_id_to_camera_id_; |
77 std::unordered_map<std::string, int> model_id_to_camera_id_; | 76 std::unordered_map<std::string, int> model_id_to_camera_id_; |
78 }; | 77 }; |
79 | 78 |
80 } // namespace media | 79 } // namespace media |
81 | 80 |
82 #endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_FACING_CHROMEOS_H_ | 81 #endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_FACING_CHROMEOS_H_ |
OLD | NEW |