Hookup to cmdline parameters in emulator

Use boot properties, and webcam facing parameters set up by the emulator's cmdline.

Change-Id: I2189e5f67b9d79ad330b5ee275ff30d8851fc326
This commit is contained in:
Vladimir Chtchetkine
2011-09-17 11:28:09 -07:00
parent d392797ecf
commit 4bc3b1f3b5
5 changed files with 39 additions and 37 deletions

View File

@@ -22,6 +22,7 @@
#define LOG_NDEBUG 0
#define LOG_TAG "EmulatedCamera_Factory"
#include <cutils/log.h>
#include <cutils/properties.h>
#include "EmulatedQemuCamera.h"
#include "EmulatedFakeCamera.h"
#include "EmulatedCameraFactory.h"
@@ -43,9 +44,8 @@ EmulatedCameraFactory::EmulatedCameraFactory()
mConstructedOK(false)
{
/* If qemu camera emulation is on, try to connect to the factory service in
* the emulator. */
if (isQemuCameraEmulationOn() && mQemuClient.connectClient(NULL) == NO_ERROR) {
/* Connect to the factory service in the emulator, and create Qemu cameras. */
if (mQemuClient.connectClient(NULL) == NO_ERROR) {
/* Connection has succeeded. Create emulated cameras for each camera
* device, reported by the service. */
createQemuCameras();
@@ -82,6 +82,8 @@ EmulatedCameraFactory::EmulatedCameraFactory()
mFakeCameraID = -1;
LOGE("%s: Unable to instantiate fake camera class", __FUNCTION__);
}
} else {
LOGD("Fake camera emulation is disabled.");
}
LOGV("%d cameras are being emulated. Fake camera ID is %d",
@@ -197,6 +199,8 @@ int EmulatedCameraFactory::get_camera_info(int camera_id,
static const char lListNameToken[] = "name=";
/* Frame dimensions token. */
static const char lListDimsToken[] = "framedims=";
/* Facing direction token. */
static const char lListDirToken[] = "dir=";
void EmulatedCameraFactory::createQemuCameras()
{
@@ -252,13 +256,15 @@ void EmulatedCameraFactory::createQemuCameras()
next_entry++; // Start of the next entry.
}
/* Find 'name', and 'framedims' tokens that are required here. */
/* Find 'name', 'framedims', and 'dir' tokens that are required here. */
char* name_start = strstr(cur_entry, lListNameToken);
char* dim_start = strstr(cur_entry, lListDimsToken);
if (name_start != NULL && dim_start != NULL) {
char* dir_start = strstr(cur_entry, lListDirToken);
if (name_start != NULL && dim_start != NULL && dir_start != NULL) {
/* Advance to the token values. */
name_start += strlen(lListNameToken);
dim_start += strlen(lListDimsToken);
dir_start += strlen(lListDirToken);
/* Terminate token values with zero. */
char* s = strchr(name_start, ' ');
@@ -269,12 +275,16 @@ void EmulatedCameraFactory::createQemuCameras()
if (s != NULL) {
*s = '\0';
}
s = strchr(dir_start, ' ');
if (s != NULL) {
*s = '\0';
}
/* Create and initialize qemu camera. */
EmulatedQemuCamera* qemu_cam =
new EmulatedQemuCamera(index, &HAL_MODULE_INFO_SYM.common);
if (NULL != qemu_cam) {
res = qemu_cam->Initialize(name_start, dim_start);
res = qemu_cam->Initialize(name_start, dim_start, dir_start);
if (res == NO_ERROR) {
mEmulatedCameras[index] = qemu_cam;
index++;
@@ -295,16 +305,17 @@ void EmulatedCameraFactory::createQemuCameras()
mEmulatedCameraNum = index;
}
bool EmulatedCameraFactory::isQemuCameraEmulationOn()
{
/* TODO: Have a boot property that controls that! */
return true;
}
bool EmulatedCameraFactory::isFakeCameraEmulationOn()
{
/* TODO: Have a boot property that controls that! */
return true;
/* Defined by 'qemu.sf.fake_camera' boot property: If property is there
* and contains 'off', fake camera emulation is disabled. */
char prop[PROPERTY_VALUE_MAX];
if (property_get("qemu.sf.fake_camera", prop, NULL) <= 0 ||
strcmp(prop, "off")) {
return true;
} else {
return false;
}
}
/********************************************************************************

View File

@@ -94,11 +94,6 @@ private:
***************************************************************************/
public:
/* Gets fake camera facing. */
int getFakeCameraFacing() {
/* TODO: Have a boot property that controls that. */
return CAMERA_FACING_BACK;
}
/* Gets fake camera orientation. */
int getFakeCameraOrientation() {
@@ -106,12 +101,6 @@ public:
return 90;
}
/* Gets qemu camera facing. */
int getQemuCameraFacing() {
/* TODO: Have a boot property that controls that. */
return CAMERA_FACING_FRONT;
}
/* Gets qemu camera orientation. */
int getQemuCameraOrientation() {
/* TODO: Have a boot property that controls that. */
@@ -142,9 +131,6 @@ private:
*/
void createQemuCameras();
/* Checks if qemu camera emulation is on. */
bool isQemuCameraEmulationOn();
/* Checks if fake camera emulation is on. */
bool isFakeCameraEmulationOn();

View File

@@ -22,6 +22,7 @@
#define LOG_NDEBUG 0
#define LOG_TAG "EmulatedCamera_FakeCamera"
#include <cutils/log.h>
#include <cutils/properties.h>
#include "EmulatedFakeCamera.h"
#include "EmulatedCameraFactory.h"
@@ -48,11 +49,14 @@ status_t EmulatedFakeCamera::Initialize()
return res;
}
/* Fake camera facing is defined by the qemu.sf.fake_camera boot property. */
const char* facing = EmulatedCamera::FACING_BACK;
if (gEmulatedCameraFactory.getFakeCameraOrientation() == CAMERA_FACING_FRONT) {
facing = EmulatedCamera::FACING_FRONT;
char prop[PROPERTY_VALUE_MAX];
if (property_get("qemu.sf.fake_camera", prop, NULL) > 0) {
facing = prop;
}
mParameters.set(EmulatedCamera::FACING_KEY, facing);
LOGD("%s: Fake camera is facing %s", __FUNCTION__, facing);
mParameters.set(EmulatedCamera::ORIENTATION_KEY,
gEmulatedCameraFactory.getFakeCameraOrientation());

View File

@@ -42,8 +42,11 @@ EmulatedQemuCamera::~EmulatedQemuCamera()
***************************************************************************/
status_t EmulatedQemuCamera::Initialize(const char* device_name,
const char* frame_dims)
const char* frame_dims,
const char* facing_dir)
{
LOGV("%s:\n Name=%s\n Facing '%s'\n Dimensions=%s",
__FUNCTION__, device_name, facing_dir, frame_dims);
/* Save dimensions. */
mFrameDims = frame_dims;
@@ -63,11 +66,7 @@ status_t EmulatedQemuCamera::Initialize(const char* device_name,
* Set customizable parameters.
*/
const char* facing = EmulatedCamera::FACING_FRONT;
if (gEmulatedCameraFactory.getQemuCameraOrientation() == CAMERA_FACING_BACK) {
facing = EmulatedCamera::FACING_BACK;
}
mParameters.set(EmulatedCamera::FACING_KEY, facing);
mParameters.set(EmulatedCamera::FACING_KEY, facing_dir);
mParameters.set(EmulatedCamera::ORIENTATION_KEY,
gEmulatedCameraFactory.getQemuCameraOrientation());
mParameters.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, frame_dims);

View File

@@ -43,7 +43,9 @@ public:
public:
/* Initializes EmulatedQemuCamera instance. */
status_t Initialize(const char* device_name, const char* frame_dims);
status_t Initialize(const char* device_name,
const char* frame_dims,
const char* facing_dir);
/***************************************************************************
* EmulatedCamera abstract API implementation.