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 PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HEIF_PARSER_ITEM_INFO_BOX_H
17 #define PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HEIF_PARSER_ITEM_INFO_BOX_H
18 
19 #include "box/heif_box.h"
20 
21 namespace OHOS {
22 namespace ImagePlugin {
23 class HeifIinfBox : public HeifFullBox {
24 public:
HeifIinfBox()25     HeifIinfBox() : HeifFullBox(BOX_TYPE_IINF) {}
26 
27     void InferFullBoxVersion() override;
28 
29     heif_error Write(HeifStreamWriter &writer) const override;
30 protected:
31     heif_error ParseContentChildren(HeifStreamReader &reader, uint32_t &recursionCount) override;
32 };
33 
34 class HeifInfeBox : public HeifFullBox {
35 public:
HeifInfeBox()36     HeifInfeBox() : HeifFullBox(BOX_TYPE_INFE) {}
37 
HeifInfeBox(heif_item_id id,const char * itemType,bool isHidden)38     HeifInfeBox(heif_item_id id, const char *itemType, bool isHidden) : HeifFullBox(BOX_TYPE_INFE),
39                                                                         itemId_(id), itemType_(itemType),
40                                                                         isHidden_(isHidden) {};
41 
IsHidden()42     bool IsHidden() const { return isHidden_; }
43 
44     void SetHidden(bool hidden);
45 
GetItemId()46     heif_item_id GetItemId() const { return itemId_; }
47 
SetItemId(heif_item_id id)48     void SetItemId(heif_item_id id) { itemId_ = id; }
49 
GetItemType()50     const std::string &GetItemType() const { return itemType_; }
51 
SetItemType(const std::string & type)52     void SetItemType(const std::string &type) { itemType_ = type; }
53 
SetItemName(const std::string & name)54     void SetItemName(const std::string &name) { itemName_ = name; }
55 
GetContentType()56     const std::string &GetContentType() const { return contentType_; }
57 
GetContentEncoding()58     const std::string &GetContentEncoding() const { return contentEncoding_; }
59 
SetContentType(const std::string & content_type)60     void SetContentType(const std::string &content_type) { contentType_ = content_type; }
61 
SetContentEncoding(const std::string & content_encoding)62     void SetContentEncoding(const std::string &content_encoding) { contentEncoding_ = content_encoding; }
63 
64     void InferFullBoxVersion() override;
65 
66     heif_error Write(HeifStreamWriter &writer) const override;
67 
GetItemUriType()68     const std::string &GetItemUriType() const { return itemUriType_; }
69 protected:
70     heif_error ParseContent(HeifStreamReader &reader) override;
71 
72 private:
73     heif_item_id itemId_ = 0;
74     uint16_t itemProtectionIndex_ = 0;
75 
76     std::string itemType_;
77     std::string itemName_;
78     std::string contentType_;
79     std::string contentEncoding_;
80     std::string itemUriType_;
81 
82     bool isHidden_ = false;
83 };
84 
85 class HeifPtimBox : public HeifFullBox {
86 public:
HeifPtimBox()87     HeifPtimBox() : HeifFullBox(BOX_TYPE_PTIM) {}
88 
GetItemId()89     heif_item_id GetItemId() const { return itemId_; }
90 
SetItemId(heif_item_id id)91     void SetItemId(heif_item_id id) { itemId_ = id; }
92 
93     void InferFullBoxVersion() override;
94 
95     heif_error Write(HeifStreamWriter &writer) const override;
96 
97 protected:
98     heif_error ParseContent(HeifStreamReader &reader) override;
99 
100 private:
101     heif_item_id itemId_ = 0;
102 };
103 } // namespace ImagePlugin
104 } // namespace OHOS
105 
106 #endif // PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HEIF_PARSER_ITEM_INFO_BOX_H
107