• 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 #ifndef INTERFACES_INNERKITS_INCLUDE_EXIF_METADATA_H
17 #define INTERFACES_INNERKITS_INCLUDE_EXIF_METADATA_H
18 
19 #include <libexif/exif-entry.h>
20 #include <libexif/exif-tag.h>
21 #include <libexif/huawei/exif-mnote-data-huawei.h>
22 
23 #include "image_type.h"
24 #include "metadata.h"
25 #include "parcel.h"
26 
27 namespace OHOS {
28 namespace Media {
29 class ExifMetadata : public ImageMetadata {
30 public:
31     ExifMetadata();
32     ExifMetadata(ExifData *exifData);
33     virtual ~ExifMetadata();
34     virtual int GetValue(const std::string &key, std::string &value) const override;
35     virtual bool SetValue(const std::string &key, const std::string &value) override;
36     virtual bool RemoveEntry(const std::string &key) override;
37     virtual const ImageMetadata::PropertyMapPtr GetAllProperties() override;
38     virtual std::shared_ptr<ImageMetadata> CloneMetadata() override;
39     ExifData* GetExifData();
40     bool CreateExifdata();
41     NATIVEEXPORT std::shared_ptr<ExifMetadata> Clone();
42     void GetFilterArea(const std::vector<std::string> &exifKeys, std::vector<std::pair<uint32_t, uint32_t>> &ranges);
43     bool Marshalling(Parcel &parcel) const override;
44     static ExifMetadata *Unmarshalling(Parcel &parcel);
45     static ExifMetadata *Unmarshalling(Parcel &parcel, PICTURE_ERR &error);
GetType()46     MetadataType GetType() const override
47     {
48         return MetadataType::EXIF;
49     }
50     bool RemoveExifThumbnail() override;
51 
52 private:
53     ExifEntry* CreateEntry(const std::string &key, const ExifTag &tag, const size_t len);
54     MnoteHuaweiEntry* CreateHwEntry(const std::string &key);
55     ExifEntry* GetEntry(const std::string &key, const size_t len);
56     ExifEntry* GetEntry(const std::string &key) const;
57     ExifMnoteData* GetHwMnoteData(bool &isNewMaker);
58     int HandleMakerNote(std::string &value) const;
59     int HandleHwMnote(const std::string &key, std::string &value) const;
60     void ReallocEntry(ExifEntry *ptrEntry, const size_t len);
61     bool SetShort(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value);
62     bool SetSShort(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value);
63     bool SetLong(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value);
64     bool SetSLong(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value);
65     bool SetRational(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value);
66     bool SetSRational(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value);
67     bool SetByte(ExifEntry *ptrEntry, const std::string &value);
68     bool SetMem(ExifEntry *ptrEntry, const std::string &value, const size_t len);
69     bool SetHwMoteValue(const std::string &key, const std::string &value);
70     bool RemoveHwEntry(const std::string &key);
71     bool SetCommonValue(const std::string &key, const std::string &value);
72     bool IsSpecialHwKey(const std::string &key) const;
73     void FindRationalRanges(ExifContent *content,
74         std::vector<std::pair<uint32_t, uint32_t>> &ranges, int index);
75     void FindRanges(const ExifTag &tag, std::vector<std::pair<uint32_t, uint32_t>> &ranges);
76     ExifData *exifData_;
77 };
78 } // namespace Media
79 } // namespace OHOS
80 
81 #endif // INTERFACES_INNERKITS_INCLUDE_EXIF_METADATA_H
82