Shuzhen Wang | d3feb3d | 2018-08-17 13:52:40 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "CamDev@3.5-impl" |
| 18 | #include <log/log.h> |
| 19 | |
| 20 | #include "CameraModule.h" |
| 21 | #include "CameraDevice_3_5.h" |
| 22 | |
| 23 | namespace android { |
| 24 | namespace hardware { |
| 25 | namespace camera { |
| 26 | namespace device { |
| 27 | namespace V3_5 { |
| 28 | namespace implementation { |
| 29 | |
| 30 | using namespace ::android::hardware::camera::device; |
| 31 | using ::android::hardware::camera::common::V1_0::Status; |
| 32 | using ::android::hardware::camera::device::V3_2::CameraMetadata; |
| 33 | |
| 34 | CameraDevice::CameraDevice(sp<CameraModule> module, const std::string& cameraId, |
| 35 | const SortedVector<std::pair<std::string, std::string>>& cameraDeviceNames) : |
| 36 | V3_4::implementation::CameraDevice(module, cameraId, cameraDeviceNames) { |
| 37 | } |
| 38 | |
| 39 | CameraDevice::~CameraDevice() { |
| 40 | } |
| 41 | |
Yin-Chia Yeh | 6a6fe0f | 2018-09-06 15:38:34 -0700 | [diff] [blame] | 42 | sp<V3_2::implementation::CameraDeviceSession> CameraDevice::createSession(camera3_device_t* device, |
| 43 | const camera_metadata_t* deviceInfo, |
| 44 | const sp<V3_2::ICameraDeviceCallback>& callback) { |
| 45 | sp<CameraDeviceSession> session = new CameraDeviceSession(device, deviceInfo, callback); |
| 46 | IF_ALOGV() { |
| 47 | session->getInterface()->interfaceChain([]( |
| 48 | ::android::hardware::hidl_vec<::android::hardware::hidl_string> interfaceChain) { |
| 49 | ALOGV("Session interface chain:"); |
| 50 | for (auto iface : interfaceChain) { |
| 51 | ALOGV(" %s", iface.c_str()); |
| 52 | } |
| 53 | }); |
| 54 | } |
| 55 | return session; |
| 56 | } |
| 57 | |
Shuzhen Wang | d3feb3d | 2018-08-17 13:52:40 -0700 | [diff] [blame] | 58 | Return<void> CameraDevice::getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId, |
| 59 | V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) { |
| 60 | Status status = initStatus(); |
| 61 | CameraMetadata cameraCharacteristics; |
| 62 | if (status == Status::OK) { |
| 63 | // Require module 2.5+ version. |
| 64 | if (mModule->getModuleApiVersion() < CAMERA_MODULE_API_VERSION_2_5) { |
| 65 | ALOGE("%s: get_physical_camera_info must be called on camera module 2.5 or newer", |
| 66 | __FUNCTION__); |
| 67 | status = Status::INTERNAL_ERROR; |
| 68 | } else { |
| 69 | char *end; |
| 70 | errno = 0; |
| 71 | long id = strtol(physicalCameraId.c_str(), &end, 0); |
| 72 | if (id > INT_MAX || (errno == ERANGE && id == LONG_MAX) || |
| 73 | id < INT_MIN || (errno == ERANGE && id == LONG_MIN) || |
| 74 | *end != '\0') { |
| 75 | ALOGE("%s: Invalid physicalCameraId %s", __FUNCTION__, physicalCameraId.c_str()); |
| 76 | status = Status::ILLEGAL_ARGUMENT; |
| 77 | } else { |
| 78 | camera_metadata_t *physicalInfo = nullptr; |
| 79 | int ret = mModule->getPhysicalCameraInfo((int)id, &physicalInfo); |
| 80 | if (ret == OK) { |
| 81 | V3_2::implementation::convertToHidl(physicalInfo, &cameraCharacteristics); |
| 82 | } else { |
| 83 | ALOGE("%s: Failed to get physical camera %s info: %s (%d)!", __FUNCTION__, |
| 84 | physicalCameraId.c_str(), strerror(-ret), ret); |
| 85 | status = Status::INTERNAL_ERROR; |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | _hidl_cb(status, cameraCharacteristics); |
| 91 | return Void(); |
| 92 | } |
| 93 | |
| 94 | // End of methods from ::android::hardware::camera::device::V3_2::ICameraDevice. |
| 95 | |
| 96 | } // namespace implementation |
| 97 | } // namespace V3_5 |
| 98 | } // namespace device |
| 99 | } // namespace camera |
| 100 | } // namespace hardware |
| 101 | } // namespace android |
| 102 | |