Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

hardware-libcamera: Commit

hardware/libcamera


Commit MetaInfo

Révisionbbbfb37e9ab96a03d91d439a9a5aeae7251ee1e6 (tree)
l'heure2013-07-07 01:23:53
AuteurAlberto Panizzo <alberto@amar...>
CommiterAlberto Panizzo

Message de Log

Allow to set camera orientation (not facing) from cfg file

Signed-off-by: Alberto Panizzo <alberto@amarulasolutions.com>

Change Summary

Modification

--- a/CameraFactory.cpp
+++ b/CameraFactory.cpp
@@ -43,6 +43,7 @@ CameraFactory::CameraFactory()
4343 ALOGD("CameraFactory::CameraFactory");
4444 mCamera = NULL;
4545 mCameraDevices = NULL;
46+ mCameraFacing = NULL;
4647 mCameraOrientation = NULL;
4748 parseConfig(CONFIG_FILE);
4849 }
@@ -99,7 +100,8 @@ int CameraFactory::getCameraInfo(int camera_id, struct camera_info* info)
99100 return -EINVAL;
100101 }
101102
102- return CameraHardware::getCameraInfo(info, mCameraOrientation[camera_id]);
103+ return CameraHardware::getCameraInfo(info, mCameraFacing[camera_id],
104+ mCameraOrientation[camera_id]);
103105 }
104106
105107 // Parse a simple configuration file
@@ -112,6 +114,7 @@ void CameraFactory::parseConfig(const char* configFile)
112114 char line[128];
113115 char arg1[128];
114116 char arg2[128];
117+ int arg3;
115118
116119 while (fgets(line, sizeof line, config) != NULL) {
117120 int lineStart = strspn(line, " \t\n\v" );
@@ -119,12 +122,14 @@ void CameraFactory::parseConfig(const char* configFile)
119122 if (line[lineStart] == '#')
120123 continue;
121124
122- sscanf(line, "%s %s", arg1, arg2);
125+ sscanf(line, "%s %s %d", arg1, arg2, &arg3);
126+ if (arg3 != 0 && arg3 != 90 && arg3 != 180 && arg3 != 270)
127+ arg3 = 0;
123128
124129 if (strcmp(arg1, "front")) {
125- newCameraConfig(CAMERA_FACING_FRONT, arg2);
130+ newCameraConfig(CAMERA_FACING_FRONT, arg2, arg3);
126131 } else if (strcmp(arg1, "back")) {
127- newCameraConfig(CAMERA_FACING_BACK, arg2);
132+ newCameraConfig(CAMERA_FACING_BACK, arg2, arg3);
128133 } else {
129134 ALOGD("CameraFactory::parseConfig: Unrecognized config line '%s'", line);
130135 }
@@ -133,17 +138,17 @@ void CameraFactory::parseConfig(const char* configFile)
133138 ALOGD("%s not found, using camera configuration defaults", CONFIG_FILE);
134139 if (access(DEFAULT_DEVICE_BACK, F_OK) != -1){
135140 ALOGD("Found device %s", DEFAULT_DEVICE_BACK);
136- newCameraConfig(CAMERA_FACING_BACK, DEFAULT_DEVICE_BACK);
141+ newCameraConfig(CAMERA_FACING_BACK, DEFAULT_DEVICE_BACK, 0);
137142 }
138143 if (access(DEFAULT_DEVICE_FRONT, F_OK) != -1){
139144 ALOGD("Found device %s", DEFAULT_DEVICE_FRONT);
140- newCameraConfig(CAMERA_FACING_FRONT, DEFAULT_DEVICE_FRONT);
145+ newCameraConfig(CAMERA_FACING_FRONT, DEFAULT_DEVICE_FRONT, 0);
141146 }
142147 }
143148 }
144149
145150 // Although realloc could be a costly operation, we only execute this function usually 2 times
146-void CameraFactory::newCameraConfig(int facing, const char* location)
151+void CameraFactory::newCameraConfig(int facing, const char* location, int orientation)
147152 {
148153 // Keep track of cameras
149154 mCameraNum++;
@@ -151,13 +156,17 @@ void CameraFactory::newCameraConfig(int facing, const char* location)
151156 // Grow the information arrays
152157 mCamera = (CameraHardware**) realloc(mCamera, mCameraNum * sizeof(CameraHardware*));
153158 mCameraDevices = (char**) realloc(mCameraDevices, mCameraNum * sizeof(char*));
159+ mCameraFacing = (int*) realloc(mCameraFacing, mCameraNum * sizeof(int));
154160 mCameraOrientation = (int*) realloc(mCameraOrientation, mCameraNum * sizeof(int));
155161
156162 // Store the values for each camera_id
157163 mCamera[mCameraNum - 1] = NULL;
158164 mCameraDevices[mCameraNum - 1] = strdup(location);
159- mCameraOrientation[mCameraNum - 1] = facing;
160- ALOGD("CameraFactory::newCameraConfig: %d -> %s", mCameraOrientation[mCameraNum - 1], mCameraDevices[mCameraNum - 1]);
165+ mCameraFacing[mCameraNum - 1] = facing;
166+ mCameraOrientation[mCameraNum - 1] = orientation;
167+ ALOGD("CameraFactory::newCameraConfig: %d -> %s (%d)",
168+ mCameraFacing[mCameraNum - 1], mCameraDevices[mCameraNum - 1],
169+ mCameraOrientation[mCameraNum - 1]);
161170 }
162171
163172 /****************************************************************************
--- a/CameraFactory.h
+++ b/CameraFactory.h
@@ -95,13 +95,14 @@ private:
9595 hw_device_t** device);
9696
9797 void parseConfig(const char* configFile);
98- void newCameraConfig(int facing, const char* location);
98+ void newCameraConfig(int facing, const char* location, int orientation);
9999
100100 private:
101101
102102 /* Camera hardware */
103103 CameraHardware** mCamera;
104104 char** mCameraDevices;
105+ int* mCameraFacing;
105106 int* mCameraOrientation;
106107 int mCameraNum;
107108
--- a/CameraHardware.cpp
+++ b/CameraHardware.cpp
@@ -321,12 +321,13 @@ status_t CameraHardware::closeCamera()
321321 return NO_ERROR;
322322 }
323323
324-status_t CameraHardware::getCameraInfo(struct camera_info* info, int facing)
324+status_t CameraHardware::getCameraInfo(struct camera_info* info, int facing,
325+ int orientation)
325326 {
326327 ALOGD("CameraHardware::getCameraInfo");
327328
328329 info->facing = facing;
329- info->orientation = 0;
330+ info->orientation = orientation;
330331
331332 return NO_ERROR;
332333 }
--- a/CameraHardware.h
+++ b/CameraHardware.h
@@ -212,7 +212,8 @@ public:
212212 * NOTE: When this method is called the object is locked.
213213 * Note that failures in this method are reported as negave EXXX statuses.
214214 */
215- static status_t getCameraInfo(struct camera_info* info, int facing);
215+ static status_t getCameraInfo(struct camera_info* info, int facing,
216+ int orientation);
216217
217218 private:
218219
Afficher sur ancien navigateur de dépôt.