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:
@@ -22,6 +22,7 @@
|
|||||||
#define LOG_NDEBUG 0
|
#define LOG_NDEBUG 0
|
||||||
#define LOG_TAG "EmulatedCamera_Factory"
|
#define LOG_TAG "EmulatedCamera_Factory"
|
||||||
#include <cutils/log.h>
|
#include <cutils/log.h>
|
||||||
|
#include <cutils/properties.h>
|
||||||
#include "EmulatedQemuCamera.h"
|
#include "EmulatedQemuCamera.h"
|
||||||
#include "EmulatedFakeCamera.h"
|
#include "EmulatedFakeCamera.h"
|
||||||
#include "EmulatedCameraFactory.h"
|
#include "EmulatedCameraFactory.h"
|
||||||
@@ -43,9 +44,8 @@ EmulatedCameraFactory::EmulatedCameraFactory()
|
|||||||
mConstructedOK(false)
|
mConstructedOK(false)
|
||||||
|
|
||||||
{
|
{
|
||||||
/* If qemu camera emulation is on, try to connect to the factory service in
|
/* Connect to the factory service in the emulator, and create Qemu cameras. */
|
||||||
* the emulator. */
|
if (mQemuClient.connectClient(NULL) == NO_ERROR) {
|
||||||
if (isQemuCameraEmulationOn() && mQemuClient.connectClient(NULL) == NO_ERROR) {
|
|
||||||
/* Connection has succeeded. Create emulated cameras for each camera
|
/* Connection has succeeded. Create emulated cameras for each camera
|
||||||
* device, reported by the service. */
|
* device, reported by the service. */
|
||||||
createQemuCameras();
|
createQemuCameras();
|
||||||
@@ -82,6 +82,8 @@ EmulatedCameraFactory::EmulatedCameraFactory()
|
|||||||
mFakeCameraID = -1;
|
mFakeCameraID = -1;
|
||||||
LOGE("%s: Unable to instantiate fake camera class", __FUNCTION__);
|
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",
|
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=";
|
static const char lListNameToken[] = "name=";
|
||||||
/* Frame dimensions token. */
|
/* Frame dimensions token. */
|
||||||
static const char lListDimsToken[] = "framedims=";
|
static const char lListDimsToken[] = "framedims=";
|
||||||
|
/* Facing direction token. */
|
||||||
|
static const char lListDirToken[] = "dir=";
|
||||||
|
|
||||||
void EmulatedCameraFactory::createQemuCameras()
|
void EmulatedCameraFactory::createQemuCameras()
|
||||||
{
|
{
|
||||||
@@ -252,13 +256,15 @@ void EmulatedCameraFactory::createQemuCameras()
|
|||||||
next_entry++; // Start of the next entry.
|
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* name_start = strstr(cur_entry, lListNameToken);
|
||||||
char* dim_start = strstr(cur_entry, lListDimsToken);
|
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. */
|
/* Advance to the token values. */
|
||||||
name_start += strlen(lListNameToken);
|
name_start += strlen(lListNameToken);
|
||||||
dim_start += strlen(lListDimsToken);
|
dim_start += strlen(lListDimsToken);
|
||||||
|
dir_start += strlen(lListDirToken);
|
||||||
|
|
||||||
/* Terminate token values with zero. */
|
/* Terminate token values with zero. */
|
||||||
char* s = strchr(name_start, ' ');
|
char* s = strchr(name_start, ' ');
|
||||||
@@ -269,12 +275,16 @@ void EmulatedCameraFactory::createQemuCameras()
|
|||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
}
|
}
|
||||||
|
s = strchr(dir_start, ' ');
|
||||||
|
if (s != NULL) {
|
||||||
|
*s = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
/* Create and initialize qemu camera. */
|
/* Create and initialize qemu camera. */
|
||||||
EmulatedQemuCamera* qemu_cam =
|
EmulatedQemuCamera* qemu_cam =
|
||||||
new EmulatedQemuCamera(index, &HAL_MODULE_INFO_SYM.common);
|
new EmulatedQemuCamera(index, &HAL_MODULE_INFO_SYM.common);
|
||||||
if (NULL != qemu_cam) {
|
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) {
|
if (res == NO_ERROR) {
|
||||||
mEmulatedCameras[index] = qemu_cam;
|
mEmulatedCameras[index] = qemu_cam;
|
||||||
index++;
|
index++;
|
||||||
@@ -295,16 +305,17 @@ void EmulatedCameraFactory::createQemuCameras()
|
|||||||
mEmulatedCameraNum = index;
|
mEmulatedCameraNum = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EmulatedCameraFactory::isQemuCameraEmulationOn()
|
|
||||||
{
|
|
||||||
/* TODO: Have a boot property that controls that! */
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EmulatedCameraFactory::isFakeCameraEmulationOn()
|
bool EmulatedCameraFactory::isFakeCameraEmulationOn()
|
||||||
{
|
{
|
||||||
/* TODO: Have a boot property that controls that! */
|
/* Defined by 'qemu.sf.fake_camera' boot property: If property is there
|
||||||
return true;
|
* 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
|
|||||||
@@ -94,11 +94,6 @@ private:
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* Gets fake camera facing. */
|
|
||||||
int getFakeCameraFacing() {
|
|
||||||
/* TODO: Have a boot property that controls that. */
|
|
||||||
return CAMERA_FACING_BACK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Gets fake camera orientation. */
|
/* Gets fake camera orientation. */
|
||||||
int getFakeCameraOrientation() {
|
int getFakeCameraOrientation() {
|
||||||
@@ -106,12 +101,6 @@ public:
|
|||||||
return 90;
|
return 90;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Gets qemu camera facing. */
|
|
||||||
int getQemuCameraFacing() {
|
|
||||||
/* TODO: Have a boot property that controls that. */
|
|
||||||
return CAMERA_FACING_FRONT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Gets qemu camera orientation. */
|
/* Gets qemu camera orientation. */
|
||||||
int getQemuCameraOrientation() {
|
int getQemuCameraOrientation() {
|
||||||
/* TODO: Have a boot property that controls that. */
|
/* TODO: Have a boot property that controls that. */
|
||||||
@@ -142,9 +131,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
void createQemuCameras();
|
void createQemuCameras();
|
||||||
|
|
||||||
/* Checks if qemu camera emulation is on. */
|
|
||||||
bool isQemuCameraEmulationOn();
|
|
||||||
|
|
||||||
/* Checks if fake camera emulation is on. */
|
/* Checks if fake camera emulation is on. */
|
||||||
bool isFakeCameraEmulationOn();
|
bool isFakeCameraEmulationOn();
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#define LOG_NDEBUG 0
|
#define LOG_NDEBUG 0
|
||||||
#define LOG_TAG "EmulatedCamera_FakeCamera"
|
#define LOG_TAG "EmulatedCamera_FakeCamera"
|
||||||
#include <cutils/log.h>
|
#include <cutils/log.h>
|
||||||
|
#include <cutils/properties.h>
|
||||||
#include "EmulatedFakeCamera.h"
|
#include "EmulatedFakeCamera.h"
|
||||||
#include "EmulatedCameraFactory.h"
|
#include "EmulatedCameraFactory.h"
|
||||||
|
|
||||||
@@ -48,11 +49,14 @@ status_t EmulatedFakeCamera::Initialize()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Fake camera facing is defined by the qemu.sf.fake_camera boot property. */
|
||||||
const char* facing = EmulatedCamera::FACING_BACK;
|
const char* facing = EmulatedCamera::FACING_BACK;
|
||||||
if (gEmulatedCameraFactory.getFakeCameraOrientation() == CAMERA_FACING_FRONT) {
|
char prop[PROPERTY_VALUE_MAX];
|
||||||
facing = EmulatedCamera::FACING_FRONT;
|
if (property_get("qemu.sf.fake_camera", prop, NULL) > 0) {
|
||||||
|
facing = prop;
|
||||||
}
|
}
|
||||||
mParameters.set(EmulatedCamera::FACING_KEY, facing);
|
mParameters.set(EmulatedCamera::FACING_KEY, facing);
|
||||||
|
LOGD("%s: Fake camera is facing %s", __FUNCTION__, facing);
|
||||||
|
|
||||||
mParameters.set(EmulatedCamera::ORIENTATION_KEY,
|
mParameters.set(EmulatedCamera::ORIENTATION_KEY,
|
||||||
gEmulatedCameraFactory.getFakeCameraOrientation());
|
gEmulatedCameraFactory.getFakeCameraOrientation());
|
||||||
|
|||||||
@@ -42,8 +42,11 @@ EmulatedQemuCamera::~EmulatedQemuCamera()
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
status_t EmulatedQemuCamera::Initialize(const char* device_name,
|
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. */
|
/* Save dimensions. */
|
||||||
mFrameDims = frame_dims;
|
mFrameDims = frame_dims;
|
||||||
|
|
||||||
@@ -63,11 +66,7 @@ status_t EmulatedQemuCamera::Initialize(const char* device_name,
|
|||||||
* Set customizable parameters.
|
* Set customizable parameters.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char* facing = EmulatedCamera::FACING_FRONT;
|
mParameters.set(EmulatedCamera::FACING_KEY, facing_dir);
|
||||||
if (gEmulatedCameraFactory.getQemuCameraOrientation() == CAMERA_FACING_BACK) {
|
|
||||||
facing = EmulatedCamera::FACING_BACK;
|
|
||||||
}
|
|
||||||
mParameters.set(EmulatedCamera::FACING_KEY, facing);
|
|
||||||
mParameters.set(EmulatedCamera::ORIENTATION_KEY,
|
mParameters.set(EmulatedCamera::ORIENTATION_KEY,
|
||||||
gEmulatedCameraFactory.getQemuCameraOrientation());
|
gEmulatedCameraFactory.getQemuCameraOrientation());
|
||||||
mParameters.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, frame_dims);
|
mParameters.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, frame_dims);
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/* Initializes EmulatedQemuCamera instance. */
|
/* 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.
|
* EmulatedCamera abstract API implementation.
|
||||||
|
|||||||
Reference in New Issue
Block a user