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 #ifndef CAMERASERVER_CONVERT_HIDL 18 #define CAMERASERVER_CONVERT_HIDL 19 20 #include <vector> 21 22 #include <android/frameworks/cameraservice/service/2.0/ICameraService.h> 23 #include <android/frameworks/cameraservice/device/2.0/ICameraDeviceUser.h> 24 #include <android/frameworks/cameraservice/common/2.0/types.h> 25 #include <android/frameworks/cameraservice/service/2.0/types.h> 26 #include <android/frameworks/cameraservice/service/2.1/types.h> 27 #include <android/frameworks/cameraservice/device/2.0/types.h> 28 #include <android/hardware/camera/common/1.0/types.h> 29 #include <android/hardware/camera2/ICameraDeviceUser.h> 30 #include <android/hardware/graphics/bufferqueue/1.0/IGraphicBufferProducer.h> 31 #include <android/hardware/ICameraService.h> 32 #include <camera/CameraMetadata.h> 33 #include <fmq/MessageQueue.h> 34 #include <hardware/camera.h> 35 #include <hidl/MQDescriptor.h> 36 37 namespace android { 38 namespace hardware { 39 namespace cameraservice { 40 namespace utils { 41 namespace conversion { 42 43 using hardware::camera2::impl::CaptureResultExtras; 44 using hardware::camera2::impl::PhysicalCaptureResultInfo; 45 46 using CaptureResultMetadataQueue = MessageQueue<uint8_t, kSynchronizedReadWrite>; 47 using HCameraMetadata = frameworks::cameraservice::service::V2_0::CameraMetadata; 48 using HCameraDeviceStatus = frameworks::cameraservice::service::V2_0::CameraDeviceStatus; 49 using HCameraStatusAndId = frameworks::cameraservice::service::V2_0::CameraStatusAndId; 50 using HCameraDeviceUser = frameworks::cameraservice::device::V2_0::ICameraDeviceUser; 51 using HCaptureResultExtras = frameworks::cameraservice::device::V2_0::CaptureResultExtras; 52 using HCaptureRequest = frameworks::cameraservice::device::V2_0::CaptureRequest; 53 using HErrorCode = frameworks::cameraservice::device::V2_0::ErrorCode; 54 using HGraphicBufferProducer = hardware::graphics::bufferqueue::V1_0::IGraphicBufferProducer; 55 using HOutputConfiguration = frameworks::cameraservice::device::V2_0::OutputConfiguration; 56 using HPhysicalCameraSettings = frameworks::cameraservice::device::V2_0::PhysicalCameraSettings; 57 using HPhysicalCaptureResultInfo = frameworks::cameraservice::device::V2_0::PhysicalCaptureResultInfo; 58 using HSessionConfiguration = frameworks::cameraservice::device::V2_0::SessionConfiguration; 59 using HSubmitInfo = frameworks::cameraservice::device::V2_0::SubmitInfo; 60 using HStatus = frameworks::cameraservice::common::V2_0::Status; 61 using HStreamConfigurationMode = frameworks::cameraservice::device::V2_0::StreamConfigurationMode; 62 using HTemplateId = frameworks::cameraservice::device::V2_0::TemplateId; 63 64 // Note: existing data in dst will be gone. Caller still owns the memory of src 65 void convertToHidl(const camera_metadata_t *src, HCameraMetadata* dst); 66 67 int32_t convertFromHidl(HStreamConfigurationMode streamConfigurationMode); 68 69 int32_t convertFromHidl(HTemplateId templateId); 70 71 bool convertFromHidl(const HCameraMetadata &src, CameraMetadata *dst); 72 73 hardware::camera2::params::OutputConfiguration convertFromHidl( 74 const HOutputConfiguration &hOutputConfiguration); 75 76 hardware::camera2::params::SessionConfiguration convertFromHidl( 77 const HSessionConfiguration &hSessionConfiguration); 78 79 HCameraDeviceStatus convertToHidlCameraDeviceStatus(int32_t status); 80 81 void convertToHidl(const std::vector<hardware::CameraStatus> &src, 82 hidl_vec<HCameraStatusAndId>* dst); 83 84 void convertToHidl(const std::vector<hardware::CameraStatus> &src, 85 hidl_vec<frameworks::cameraservice::service::V2_1::CameraStatusAndId>* dst); 86 87 void convertToHidl(const hardware::camera2::utils::SubmitInfo &submitInfo, 88 HSubmitInfo *hSubmitInfo); 89 90 HErrorCode convertToHidl(int32_t errorCode); 91 92 HCaptureResultExtras convertToHidl(const CaptureResultExtras &captureResultExtras); 93 94 hidl_vec<HPhysicalCaptureResultInfo> convertToHidl( 95 const std::vector<PhysicalCaptureResultInfo> &physicalCaptureResultInfos, 96 std::shared_ptr<CaptureResultMetadataQueue> &captureResultMetadataQueue); 97 98 HStatus B2HStatus(const binder::Status &bStatus); 99 100 } // conversion 101 } // utils 102 } // cameraservice 103 } // hardware 104 } //android 105 106 #endif //CAMERASERVER_CONVERT_TO_HIDL 107