1 /*
2 * Copyright (c) 2025-2025 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 #include <cstdint>
17 #include "camera_log.h"
18 #include "camera_metadata.h"
19
20 namespace OHOS {
21 namespace CameraStandard {
22
CopyMetadata(const std::shared_ptr<OHOS::Camera::CameraMetadata> srcMetadata)23 std::shared_ptr<OHOS::Camera::CameraMetadata> CopyMetadata(
24 const std::shared_ptr<OHOS::Camera::CameraMetadata> srcMetadata)
25 {
26 CHECK_RETURN_RET_ELOG(srcMetadata == nullptr, nullptr, "CopyMetadata fail,src is null");
27 auto oldMetadata = srcMetadata->get();
28 CHECK_RETURN_RET(oldMetadata == nullptr, nullptr);
29 std::shared_ptr<OHOS::Camera::CameraMetadata> result =
30 std::make_shared<OHOS::Camera::CameraMetadata>(oldMetadata->item_capacity, oldMetadata->data_capacity);
31 auto newMetadata = result->get();
32 int32_t ret = OHOS::Camera::CopyCameraMetadataItems(newMetadata, oldMetadata);
33 CHECK_PRINT_ELOG(ret != CAM_META_SUCCESS, "CopyCameraMetadataItems failed ret:%{public}d", ret);
34 return result;
35 }
36
GetMetadataItem(const common_metadata_header_t * src,uint32_t tag)37 std::shared_ptr<camera_metadata_item_t> GetMetadataItem(const common_metadata_header_t* src, uint32_t tag)
38 {
39 CHECK_RETURN_RET(src == nullptr, nullptr);
40 auto item = std::make_shared<camera_metadata_item_t>();
41 int32_t ret = OHOS::Camera::CameraMetadata::FindCameraMetadataItem(src, tag, item.get());
42 CHECK_RETURN_RET(ret != CAM_META_SUCCESS, nullptr);
43 return item;
44 }
45
46 } // namespace CameraStandard
47 } // namespace OHOS
48