status_t CameraService::getCameraInfo(int cameraId, struct CameraInfo* cameraInfo) { if (cameraId < 0 || cameraId >= mNumberOfCameras) { return BAD_VALUE; } HAL_getCameraInfo(cameraId, cameraInfo); return OK; }
sp<ICamera> CameraService::connect( const sp<ICameraClient>& cameraClient, int cameraId) { int callingPid = getCallingPid(); LOG1("CameraService::connect E (pid %d, id %d)", callingPid, cameraId); sp<Client> client; if (cameraId < 0 || cameraId >= mNumberOfCameras) { LOGE("CameraService::connect X (pid %d) rejected (invalid cameraId %d).", callingPid, cameraId); return NULL; } Mutex::Autolock lock(mServiceLock); if (mClient[cameraId] != 0) { client = mClient[cameraId].promote(); if (client != 0) { if (cameraClient->asBinder() == client->getCameraClient()->asBinder()) { LOG1("CameraService::connect X (pid %d) (the same client)", callingPid); return client; } else { LOGW("CameraService::connect X (pid %d) rejected (existing client).", callingPid); return NULL; } } mClient[cameraId].clear(); } if (mBusy[cameraId]) { LOGW("CameraService::connect X (pid %d) rejected" " (camera %d is still busy).", callingPid, cameraId); return NULL; } sp<CameraHardwareInterface> hardware = HAL_openCameraHardware(cameraId); if (hardware == NULL) { LOGE("Fail to open camera hardware (id=%d)", cameraId); return NULL; } CameraInfo info; HAL_getCameraInfo(cameraId, &info); client = new Client(this, cameraClient, hardware, cameraId, info.facing, callingPid); mClient[cameraId] = client; #ifdef USE_OVERLAY_FORMAT_YCbCr_420_SP if (client->mHardware == NULL) { client = NULL; mClient[cameraId] = NULL; return client; } #endif LOG1("CameraService::connect X"); return client; }
extern "C" int get_camera_info(int camera_id, struct camera_info *info) { int rc = -1; ALOGV("Q%s: E", __func__); if(info) { struct CameraInfo camInfo; memset(&camInfo, -1, sizeof (struct CameraInfo)); HAL_getCameraInfo(camera_id, &camInfo); if (camInfo.facing >= 0) { rc = 0; info->facing = camInfo.facing; info->orientation = camInfo.orientation; } } ALOGV("Q%s: X", __func__); return rc; }