• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 "effect_context.h"
17 #include "effect_log.h"
18 
19 namespace OHOS {
20 namespace Media {
21 namespace Effect {
22 
GetExifMetadataFromPixelmap(PixelMap * pixelMap)23 std::shared_ptr<ExifMetadata> GetExifMetadataFromPixelmap(PixelMap *pixelMap)
24 {
25     CHECK_AND_RETURN_RET_LOG(pixelMap != nullptr, nullptr,
26         "EffectContext::GetExifMetadataFromPixelmap: pixelmap is null");
27 
28     return pixelMap->GetExifMetadata();
29 }
30 
GetExifMetadataFromPicture(Picture * picture)31 std::shared_ptr<ExifMetadata> GetExifMetadataFromPicture(Picture *picture)
32 {
33     CHECK_AND_RETURN_RET_LOG(picture != nullptr, nullptr,
34         "EffectContext::GetExifMetadataFromPicture: picture is null");
35 
36     return picture->GetExifMetadata();
37 }
38 
GetExifMetadata()39 std::shared_ptr<ExifMetadata> EffectContext::GetExifMetadata()
40 {
41     CHECK_AND_RETURN_RET_LOG(renderStrategy_ != nullptr, nullptr,
42         "EffectContext::GetExifMetadata: renderStrategy_ is null");
43 
44     EffectBuffer *src = renderStrategy_->GetInput();
45     if (src == nullptr) {
46         return exifMetadata_;
47     }
48 
49     std::shared_ptr<ExtraInfo> &extraInfo = src->extraInfo_;
50     std::shared_ptr<BufferInfo> &bufferInfo = src->bufferInfo_;
51     CHECK_AND_RETURN_RET_LOG(extraInfo != nullptr, nullptr, "EffectContext::GetExifMetadata: extraInfo is null");
52     CHECK_AND_RETURN_RET_LOG(bufferInfo != nullptr, nullptr, "EffectContext::GetExifMetadata: bufferInfo is null");
53 
54     switch (extraInfo->dataType) {
55         case DataType::PIXEL_MAP:
56             return GetExifMetadataFromPixelmap(bufferInfo->pixelMap_);
57         case DataType::PATH:
58         case DataType::URI:
59             return GetExifMetadataFromPicture(extraInfo->innerPicture.get());
60         case DataType::PICTURE:
61             return GetExifMetadataFromPicture(extraInfo->picture);
62         default:
63             EFFECT_LOGW("EffectContext::GetExifMetadata: dataType=%{public}d not contain exif!", extraInfo->dataType);
64             return nullptr;
65     }
66 }
67 
68 } // namespace Effect
69 } // namespace Media
70 } // namespace OHOS
71