diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2019-07-02 07:41:24 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-07-02 07:41:24 +0000 |
| commit | 26f1b51bfbd5e8d2d2e55247a8bae49ccd52872d (patch) | |
| tree | 0d99225e22e2956cf075fcf48527d0e17e872c0f /camera/device/3.4/default/ExternalCameraDevice.cpp | |
| parent | 3adfddb29552dbf79387c23e10a9960d1f9c2f79 (diff) | |
| parent | 8b76f6692c718c21272d3585541b72fed7ac93f0 (diff) | |
Merge "DO NOT MERGE - Merge qt-dev-plus-aosp-without-vendor (5699924) into stage-aosp-master" into stage-aosp-master
Diffstat (limited to 'camera/device/3.4/default/ExternalCameraDevice.cpp')
| -rw-r--r-- | camera/device/3.4/default/ExternalCameraDevice.cpp | 105 |
1 files changed, 42 insertions, 63 deletions
diff --git a/camera/device/3.4/default/ExternalCameraDevice.cpp b/camera/device/3.4/default/ExternalCameraDevice.cpp index 38a78e070c..9a2fddff88 100644 --- a/camera/device/3.4/default/ExternalCameraDevice.cpp +++ b/camera/device/3.4/default/ExternalCameraDevice.cpp @@ -47,24 +47,31 @@ constexpr int OPEN_RETRY_SLEEP_US = 100000; // 100ms * MAX_RETRY = 0.5 seconds } // anonymous namespace ExternalCameraDevice::ExternalCameraDevice( - const std::string& cameraId, const ExternalCameraConfig& cfg) : + const std::string& cameraId, const ExternalCameraConfig& cfg) : mCameraId(cameraId), - mCfg(cfg) { - - status_t ret = initCameraCharacteristics(); - if (ret != OK) { - ALOGE("%s: init camera characteristics failed: errorno %d", __FUNCTION__, ret); - mInitFailed = true; - } -} + mCfg(cfg) {} ExternalCameraDevice::~ExternalCameraDevice() {} bool ExternalCameraDevice::isInitFailed() { + Mutex::Autolock _l(mLock); + return isInitFailedLocked(); +} + +bool ExternalCameraDevice::isInitFailedLocked() { + if (!mInitialized) { + status_t ret = initCameraCharacteristics(); + if (ret != OK) { + ALOGE("%s: init camera characteristics failed: errorno %d", __FUNCTION__, ret); + mInitFailed = true; + } + mInitialized = true; + } return mInitFailed; } -Return<void> ExternalCameraDevice::getResourceCost(getResourceCost_cb _hidl_cb) { +Return<void> ExternalCameraDevice::getResourceCost( + ICameraDevice::getResourceCost_cb _hidl_cb) { CameraResourceCost resCost; resCost.resourceCost = 100; _hidl_cb(Status::OK, resCost); @@ -72,11 +79,11 @@ Return<void> ExternalCameraDevice::getResourceCost(getResourceCost_cb _hidl_cb) } Return<void> ExternalCameraDevice::getCameraCharacteristics( - getCameraCharacteristics_cb _hidl_cb) { + ICameraDevice::getCameraCharacteristics_cb _hidl_cb) { Mutex::Autolock _l(mLock); V3_2::CameraMetadata hidlChars; - if (isInitFailed()) { + if (isInitFailedLocked()) { _hidl_cb(Status::INTERNAL_ERROR, hidlChars); return Void(); } @@ -93,7 +100,7 @@ Return<Status> ExternalCameraDevice::setTorchMode(TorchMode) { } Return<void> ExternalCameraDevice::open( - const sp<ICameraDeviceCallback>& callback, open_cb _hidl_cb) { + const sp<ICameraDeviceCallback>& callback, ICameraDevice::open_cb _hidl_cb) { Status status = Status::OK; sp<ExternalCameraDeviceSession> session = nullptr; @@ -142,7 +149,7 @@ Return<void> ExternalCameraDevice::open( } } - session = new ExternalCameraDeviceSession( + session = createSession( callback, mCfg, mSupportedFormats, mCroppingType, mCameraCharacteristics, mCameraId, std::move(fd)); if (session == nullptr) { @@ -335,8 +342,7 @@ status_t ExternalCameraDevice::initDefaultCharsKeys( 256, 144, 240, 160, 256, 154, - 240, 240, - 320, 240}; + 240, 180}; UPDATE(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, jpegAvailableThumbnailSizes, ARRAY_SIZE(jpegAvailableThumbnailSizes)); @@ -404,8 +410,12 @@ status_t ExternalCameraDevice::initDefaultCharsKeys( const uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN; UPDATE(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, ×tampSource, 1); - // Orientation probably isn't useful for external facing camera? - const int32_t orientation = 0; + // Orientation is a bit odd for external camera, but consider it as the orientation + // between the external camera sensor (which is usually landscape) and the device's + // natural display orientation. For devices with natural landscape display (ex: tablet/TV), the + // orientation should be 0. For devices with natural portrait display (phone), the orientation + // should be 270. + const int32_t orientation = mCfg.orientation; UPDATE(ANDROID_SENSOR_ORIENTATION, &orientation, 1); // android.shading @@ -512,52 +522,9 @@ status_t ExternalCameraDevice::initDefaultCharsKeys( UPDATE(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, availableResultKeys, ARRAY_SIZE(availableResultKeys)); - const int32_t availableCharacteristicsKeys[] = { - ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, - ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, - ANDROID_CONTROL_AE_AVAILABLE_MODES, - ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, - ANDROID_CONTROL_AE_COMPENSATION_RANGE, - ANDROID_CONTROL_AE_COMPENSATION_STEP, - ANDROID_CONTROL_AE_LOCK_AVAILABLE, - ANDROID_CONTROL_AF_AVAILABLE_MODES, - ANDROID_CONTROL_AVAILABLE_EFFECTS, - ANDROID_CONTROL_AVAILABLE_MODES, - ANDROID_CONTROL_AVAILABLE_SCENE_MODES, - ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, - ANDROID_CONTROL_AWB_AVAILABLE_MODES, - ANDROID_CONTROL_AWB_LOCK_AVAILABLE, - ANDROID_CONTROL_MAX_REGIONS, - ANDROID_FLASH_INFO_AVAILABLE, - ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, - ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, - ANDROID_LENS_FACING, - ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION, - ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION, - ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, - ANDROID_REQUEST_AVAILABLE_CAPABILITIES, - ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS, - ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, - ANDROID_REQUEST_PARTIAL_RESULT_COUNT, - ANDROID_REQUEST_PIPELINE_MAX_DEPTH, - ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, - ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, - ANDROID_SCALER_CROPPING_TYPE, - ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, - ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, - ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, - ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE, - ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, - ANDROID_SENSOR_ORIENTATION, - ANDROID_SHADING_AVAILABLE_MODES, - ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, - ANDROID_STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES, - ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES, - ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, - ANDROID_SYNC_MAX_LATENCY}; UPDATE(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, - availableCharacteristicsKeys, - ARRAY_SIZE(availableCharacteristicsKeys)); + AVAILABLE_CHARACTERISTICS_KEYS_3_4.data(), + AVAILABLE_CHARACTERISTICS_KEYS_3_4.size()); return OK; } @@ -1030,6 +997,18 @@ void ExternalCameraDevice::initSupportedFormatsLocked(int fd) { } } +sp<ExternalCameraDeviceSession> ExternalCameraDevice::createSession( + const sp<ICameraDeviceCallback>& cb, + const ExternalCameraConfig& cfg, + const std::vector<SupportedV4L2Format>& sortedFormats, + const CroppingType& croppingType, + const common::V1_0::helper::CameraMetadata& chars, + const std::string& cameraId, + unique_fd v4l2Fd) { + return new ExternalCameraDeviceSession( + cb, cfg, sortedFormats, croppingType, chars, cameraId, std::move(v4l2Fd)); +} + } // namespace implementation } // namespace V3_4 } // namespace device |
