• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 open camera.
52      */
53     virtual int Open(int32_t cameraConcurrentType) = 0;
54 
55     /**
56      * @brief close camera.
57      */
58     virtual int Close() = 0;
59 
60     /**
61      * @brief Release camera input.
62      */
63     virtual int Release() = 0;
64 
65     /**
66      * @brief get the camera info associated with the device.
67      *
68      * @return Returns camera info.
69      */
70     virtual sptr<CameraDevice> GetCameraDeviceInfo() = 0;
71 
SetMetadataResultProcessor(std::shared_ptr<MetadataResultProcessor> metadataResultProcessor)72     inline void SetMetadataResultProcessor(std::shared_ptr<MetadataResultProcessor> metadataResultProcessor)
73     {
74         std::lock_guard<std::mutex> lock(metadataResultProcessorMutex_);
75         metadataResultProcessor_ = metadataResultProcessor;
76     }
77 
GetMetadataResultProcessor()78     inline std::shared_ptr<MetadataResultProcessor> GetMetadataResultProcessor()
79     {
80         std::lock_guard<std::mutex> lock(metadataResultProcessorMutex_);
81         return metadataResultProcessor_.lock();
82     }
83 
84 private:
85     std::mutex metadataResultProcessorMutex_;
86     std::weak_ptr<MetadataResultProcessor> metadataResultProcessor_;
87 };
88 } // namespace CameraStandard
89 } // namespace OHOS
90 #endif // OHOS_CAMERA_CAPTURE_INPUT_H
91