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 bool Marshalling(Parcel &parcel) const override; 43 static ExifMetadata *Unmarshalling(Parcel &parcel); 44 static ExifMetadata *Unmarshalling(Parcel &parcel, PICTURE_ERR &error); 45 void GetFilterArea(const std::vector<std::string> &exifKeys, std::vector<std::pair<uint32_t, uint32_t>> &ranges); GetType()46 MetadataType GetType() const override 47 { 48 return MetadataType::EXIF; 49 } 50 51 private: 52 ExifEntry* CreateEntry(const std::string &key, const ExifTag &tag, const size_t len); 53 MnoteHuaweiEntry* CreateHwEntry(const std::string &key); 54 ExifEntry* GetEntry(const std::string &key, const size_t len); 55 ExifEntry* GetEntry(const std::string &key) const; 56 ExifMnoteData* GetHwMnoteData(bool &isNewMaker); 57 int HandleMakerNote(std::string &value) const; 58 int HandleHwMnote(const std::string &key, std::string &value) const; 59 void ReallocEntry(ExifEntry *ptrEntry, const size_t len); 60 bool SetShort(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value); 61 bool SetSShort(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value); 62 bool SetLong(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value); 63 bool SetSLong(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value); 64 bool SetRational(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value); 65 bool SetSRational(ExifEntry *ptrEntry, const ExifByteOrder &o, const std::string &value); 66 bool SetByte(ExifEntry *ptrEntry, const std::string &value); 67 bool SetMem(ExifEntry *ptrEntry, const std::string &value, const size_t len); 68 bool SetHwMoteValue(const std::string &key, const std::string &value); 69 bool RemoveHwEntry(const std::string &key); 70 bool SetCommonValue(const std::string &key, const std::string &value); 71 bool IsSpecialHwKey(const std::string &key) const; 72 void FindRanges(const ExifTag &tag, std::vector<std::pair<uint32_t, uint32_t>> &ranges); 73 ExifData *exifData_; 74 }; 75 } // namespace Media 76 } // namespace OHOS 77 78 #endif // INTERFACES_INNERKITS_INCLUDE_EXIF_METADATA_H 79