Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: media/capture/video/linux/camera_facing_chromeos.h

Issue 2508803002: Rotate frames correctly for back camera (Closed)
Patch Set: remove copy target Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/capture/BUILD.gn ('k') | media/capture/video/linux/camera_facing_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_FACING_CHROMEOS_H_
6 #define MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_FACING_CHROMEOS_H_
7
8 #include <stddef.h>
9
10 #include <string>
11 #include <unordered_map>
12
13 #include <base/strings/string_piece.h>
14
15 namespace media {
16
17 // CameraFacingChromeOS reads the file /etc/camera/camera_characteristics.conf
18 // and populates |camera_id_to_facing_|, |usb_id_to_camera_id_| and
19 // |model_id_to_camera_id_|.
20 //
21 // Each line in the config file can be:
22 // 1. Empty line
23 // 2. Line starts with '#': comments
24 // 3. Line follows the format:
25 // camera[camera_id].[root_level_attribute]=[value] OR
26 // camera[camera_id].module[module_id].[module_level_attribute]=[value]
27 //
28 // There are several assumptions of the config file:
29 // 1. One camera ID has exactly one lens_facing attribute, at root level.
30 // 2. usb_path is specified at module level. usb_path may not present at all,
31 // but if it presents, the same usb_path does not appear accross different
32 // camera IDs.
33 // 3. usb_vid_pid is specified at module level. If usb_path does not present,
34 // each module needs to have one unique usb_vid_pid.
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 CameraFacingChromeOS {
50 public:
51 enum LensFacing { FRONT = 0, BACK = 1 };
52
53 CameraFacingChromeOS();
54 CameraFacingChromeOS(const std::string& config_file_path);
55 ~CameraFacingChromeOS();
56
57 // Get camera facing by specifying USB vid and pid and device path. |model_id|
58 // should be formatted as "vid:pid". |device_id| is something like
59 // "/dev/video2". It first tries to match usb path, obtained from |device_id|.
60 // If fails, |model_id| is then used.
61 // Returns LensFacing::FRONT or LensFacing::BACK.
62 // Default is LensFacing::FRONT.
63 LensFacing GetCameraFacing(const std::string& device_id,
64 const std::string& model_id) const;
65
66 static const LensFacing kLensFacingDefault = LensFacing::FRONT;
67
68 private:
69 std::string GetUsbId(const std::string& device_id) const;
70 // Read file content and populate |camera_id_to_facing_|,
71 // |usb_id_to_camera_id_| and |model_id_to_camera_id_|.
72 void InitializeDeviceInfo(const std::string& config_file_path);
73
74 std::unordered_map<int, LensFacing> camera_id_to_facing_;
75 std::unordered_map<std::string, int> usb_id_to_camera_id_;
76 std::unordered_map<std::string, int> model_id_to_camera_id_;
77 };
78
79 } // namespace media
80
81 #endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_FACING_CHROMEOS_H_
OLDNEW
« no previous file with comments | « media/capture/BUILD.gn ('k') | media/capture/video/linux/camera_facing_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698