1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_CAMERA_CAPTURE_INPUT_H 17 #define OHOS_CAMERA_CAPTURE_INPUT_H 18 19 #include <memory> 20 #include <refbase.h> 21 22 #include "camera_device.h" 23 #include "camera_info.h" 24 25 namespace OHOS { 26 namespace CameraStandard { 27 class MetadataResultProcessor { 28 public: 29 MetadataResultProcessor() = default; 30 virtual ~MetadataResultProcessor() = default; 31 virtual void ProcessCallbacks( 32 const uint64_t timestamp, const std::shared_ptr<OHOS::Camera::CameraMetadata>& result); 33 }; 34 35 class CaptureInput : public RefBase { 36 public: 37 CaptureInput() = default; 38 virtual ~CaptureInput() = default; 39 40 /** 41 * @brief open camera. 42 */ 43 virtual int Open() = 0; 44 45 /** 46 * @brief open camera. 47 */ 48 virtual int Open(bool isEnableSecureCamera, uint64_t* secureSeqId) = 0; 49 50 /** 51 * @brief close camera. 52 */ 53 virtual int Close() = 0; 54 55 /** 56 * @brief Release camera input. 57 */ 58 virtual int Release() = 0; 59 60 /** 61 * @brief get the camera info associated with the device. 62 * 63 * @return Returns camera info. 64 */ 65 virtual sptr<CameraDevice> GetCameraDeviceInfo() = 0; 66 SetMetadataResultProcessor(std::shared_ptr<MetadataResultProcessor> metadataResultProcessor)67 inline void SetMetadataResultProcessor(std::shared_ptr<MetadataResultProcessor> metadataResultProcessor) 68 { 69 std::lock_guard<std::mutex> lock(metadataResultProcessorMutex_); 70 metadataResultProcessor_ = metadataResultProcessor; 71 } 72 GetMetadataResultProcessor()73 inline std::shared_ptr<MetadataResultProcessor> GetMetadataResultProcessor() 74 { 75 std::lock_guard<std::mutex> lock(metadataResultProcessorMutex_); 76 return metadataResultProcessor_.lock(); 77 } 78 79 private: 80 std::mutex metadataResultProcessorMutex_; 81 std::weak_ptr<MetadataResultProcessor> metadataResultProcessor_; 82 }; 83 } // namespace CameraStandard 84 } // namespace OHOS 85 #endif // OHOS_CAMERA_CAPTURE_INPUT_H 86