• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_H_STREAM_METADATA_H
17 #define OHOS_CAMERA_H_STREAM_METADATA_H
18 #define EXPORT_API __attribute__((visibility("default")))
19 
20 #include "camera_metadata_info.h"
21 #include "stream_metadata_stub.h"
22 #include "hstream_common.h"
23 #include "v1_0/istream_operator.h"
24 #include "icamera_ipc_checker.h"
25 
26 #include <refbase.h>
27 #include <iostream>
28 
29 namespace OHOS {
30 namespace CameraStandard {
31 static const std::unordered_map<MetadataObjectType, uint8_t> g_FwkToHALResultCameraMetaDetect_ = {
32     {MetadataObjectType::FACE, 0},
33     {MetadataObjectType::HUMAN_BODY, 1},
34     {MetadataObjectType::CAT_FACE, 2},
35     {MetadataObjectType::CAT_BODY, 3},
36     {MetadataObjectType::DOG_FACE, 4},
37     {MetadataObjectType::DOG_BODY, 5},
38     {MetadataObjectType::SALIENT_DETECTION, 6},
39     {MetadataObjectType::BAR_CODE_DETECTION, 7},
40     {MetadataObjectType::BASE_FACE_DETECTION, 8},
41     {MetadataObjectType::BASE_TRACKING_REGION, 9}
42 };
43 class EXPORT_API HStreamMetadata : public StreamMetadataStub, public HStreamCommon, public ICameraIpcChecker {
44 public:
45     HStreamMetadata(sptr<OHOS::IBufferProducer> producer, int32_t format, std::vector<int32_t> metadataTypes);
46     ~HStreamMetadata();
47 
48     int32_t LinkInput(wptr<OHOS::HDI::Camera::V1_0::IStreamOperator> streamOperator,
49         std::shared_ptr<OHOS::Camera::CameraMetadata> cameraAbility) override;
50     void SetStreamInfo(StreamInfo_V1_1& streamInfo) override;
51     int32_t ReleaseStream(bool isDelay) override;
52     int32_t Release() override;
53     int32_t Start() override;
54     int32_t Stop() override;
55     int32_t SetCallback(const sptr<IStreamMetadataCallback>& callback) override;
56     int32_t UnSetCallback() override;
57     int32_t EnableMetadataType(const std::vector<int32_t>& metadataTypes) override;
58     int32_t DisableMetadataType(const std::vector<int32_t>& metadataTypes) override;
59     void DumpStreamInfo(CameraInfoDumper& infoDumper) override;
60     int32_t OperatePermissionCheck(uint32_t interfaceCode) override;
61     int32_t OnMetaResult(int32_t streamId, std::shared_ptr<OHOS::Camera::CameraMetadata> result);
62     int32_t CallbackEnter([[maybe_unused]] uint32_t code) override;
63     int32_t CallbackExit([[maybe_unused]] uint32_t code, [[maybe_unused]] int32_t result) override;
64     std::vector<int32_t> GetMetadataObjectTypes();
65 
66 private:
67     int32_t EnableOrDisableMetadataType(const std::vector<int32_t>& metadataTypes, const bool enable);
68     void removeMetadataType(const std::vector<int32_t>& vec1, std::vector<int32_t>& vec2);
69     std::vector<int32_t> metadataObjectTypes_;
70     std::mutex metadataTypeMutex_;
71     std::atomic<bool> isStarted_ { false };
72     sptr<IStreamMetadataCallback> streamMetadataCallback_;
73     std::mutex callbackLock_;
74     uint32_t majorVer_ = 0;
75     uint32_t minorVer_ = 0;
76 };
77 } // namespace CameraStandard
78 } // namespace OHOS
79 #endif // OHOS_CAMERA_H_STREAM_METADATA_H
80