1 /* 2 * Copyright (C) 2021-2023 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_NATIVE_INCLUDE_FILE_ASSET_H_ 17 #define INTERFACES_INNERKITS_NATIVE_INCLUDE_FILE_ASSET_H_ 18 19 #include <memory> 20 #include <mutex> 21 #include <string> 22 #include <variant> 23 #include <unordered_map> 24 #include "medialibrary_type_const.h" 25 26 namespace OHOS { 27 namespace Media { 28 #define EXPORT __attribute__ ((visibility ("default"))) 29 30 constexpr int MEMBER_TYPE_INT32 = 0; 31 constexpr int MEMBER_TYPE_INT64 = 1; 32 constexpr int MEMBER_TYPE_STRING = 2; 33 constexpr int MEMBER_TYPE_DOUBLE = 3; 34 35 constexpr int OPEN_TYPE_READONLY = 0; 36 constexpr int OPEN_TYPE_WRITE = 1; 37 38 /** 39 * @brief Class for filling all file asset parameters 40 * 41 * @since 1.0 42 * @version 1.0 43 */ 44 class FileAsset { 45 public: 46 EXPORT FileAsset(); 47 EXPORT virtual ~FileAsset() = default; 48 49 EXPORT int32_t GetId() const; 50 EXPORT void SetId(int32_t id); 51 52 EXPORT int32_t GetCount() const; 53 EXPORT void SetCount(int32_t count); 54 55 EXPORT const std::string &GetUri() const; 56 EXPORT void SetUri(const std::string &uri); 57 58 EXPORT const std::string &GetPath() const; 59 EXPORT void SetPath(const std::string &path); 60 61 EXPORT const std::string &GetRelativePath() const; 62 EXPORT void SetRelativePath(const std::string &relativePath); 63 64 EXPORT const std::string &GetMimeType() const; 65 EXPORT void SetMimeType(const std::string &mimeType); 66 67 EXPORT MediaType GetMediaType() const; 68 EXPORT void SetMediaType(MediaType mediaType); 69 70 EXPORT const std::string &GetDisplayName() const; 71 EXPORT void SetDisplayName(const std::string &displayName); 72 73 EXPORT int64_t GetSize() const; 74 EXPORT void SetSize(int64_t size); 75 76 EXPORT int64_t GetDateAdded() const; 77 EXPORT void SetDateAdded(int64_t dataAdded); 78 79 EXPORT int64_t GetDateModified() const; 80 EXPORT void SetDateModified(int64_t dateModified); 81 82 EXPORT const std::string &GetTitle() const; 83 EXPORT void SetTitle(const std::string &title); 84 85 EXPORT const std::string &GetArtist() const; 86 EXPORT void SetArtist(const std::string &artist); 87 88 EXPORT const std::string &GetAlbum() const; 89 EXPORT void SetAlbum(const std::string &album); 90 91 EXPORT int32_t GetPosition() const; 92 EXPORT void SetPosition(int32_t position); 93 94 EXPORT int32_t GetWidth() const; 95 EXPORT void SetWidth(int32_t width); 96 97 EXPORT int32_t GetHeight() const; 98 EXPORT void SetHeight(int32_t height); 99 100 EXPORT int32_t GetDuration() const; 101 EXPORT void SetDuration(int32_t duration); 102 103 EXPORT int32_t GetOrientation() const; 104 EXPORT void SetOrientation(int32_t orientation); 105 106 EXPORT int32_t GetAlbumId() const; 107 EXPORT void SetAlbumId(int32_t albumId); 108 109 EXPORT const std::string &GetAlbumName() const; 110 EXPORT void SetAlbumName(const std::string &albumName); 111 112 EXPORT int32_t GetParent() const; 113 EXPORT void SetParent(int32_t parent); 114 EXPORT const std::string &GetAlbumUri() const; 115 EXPORT void SetAlbumUri(const std::string &albumUri); 116 EXPORT int64_t GetDateTaken() const; 117 EXPORT void SetDateTaken(int64_t dataTaken); 118 119 EXPORT int64_t GetTimePending() const; 120 EXPORT void SetTimePending(int64_t timePending); 121 122 EXPORT bool IsFavorite() const; 123 EXPORT void SetFavorite(bool isFavorite); 124 EXPORT int64_t GetDateTrashed() const; 125 EXPORT void SetDateTrashed(int64_t dateTrashed); 126 127 EXPORT std::string GetPhotoId() const; 128 EXPORT void SetPhotoId(const std::string &photoId); 129 130 EXPORT std::pair<std::string, int> GetPhotoIdAndQuality() const; 131 EXPORT void SetPhotoIdAndQuality(const std::string &photoId, int photoQuality); 132 133 EXPORT void SetLatitude(double latitude); 134 EXPORT double GetLatitude(); 135 EXPORT void SetLongitude(double longitude); 136 EXPORT double GetLongitude(); 137 138 EXPORT const std::string &GetSelfId() const; 139 EXPORT void SetSelfId(const std::string &selfId); 140 EXPORT int32_t GetIsTrash() const; 141 EXPORT void SetIsTrash(int32_t isTrash); 142 EXPORT const std::string GetOwnerPackage() const; 143 EXPORT void SetOwnerPackage(const std::string &ownerPackage); 144 EXPORT const std::string GetOwnerAppId() const; 145 EXPORT void SetOwnerAppId(const std::string &ownerAppId); 146 EXPORT const std::string GetPackageName() const; 147 EXPORT void SetPackageName(const std::string &packageName); 148 149 EXPORT const std::string &GetRecyclePath() const; 150 EXPORT void SetRecyclePath(const std::string &recyclePath); 151 152 EXPORT ResultNapiType GetResultNapiType() const; 153 EXPORT void SetResultNapiType(const ResultNapiType type); 154 155 EXPORT int32_t GetPhotoSubType() const; 156 EXPORT void SetPhotoSubType(int32_t photoSubType); 157 158 EXPORT int32_t GetPhotoIndex() const; 159 160 EXPORT int32_t GetOriginalSubType() const; 161 162 EXPORT const std::string &GetCameraShotKey() const; 163 EXPORT void SetCameraShotKey(const std::string &cameraShotKey); 164 165 EXPORT bool IsHidden() const; 166 EXPORT void SetHidden(bool isHidden); 167 168 EXPORT void SetOpenStatus(int32_t fd, int32_t openStatus); 169 EXPORT void RemoveOpenStatus(int32_t fd); 170 EXPORT int32_t GetOpenStatus(int32_t fd); 171 172 EXPORT std::unordered_map<std::string, std::variant<int32_t, int64_t, std::string, double>> &GetMemberMap(); 173 EXPORT std::variant<int32_t, int64_t, std::string, double> &GetMemberValue(const std::string &name); 174 175 EXPORT std::string GetAssetJson(); 176 EXPORT void SetResultTypeMap(const std::string &colName, ResultSetDataType type); 177 178 EXPORT const std::string &GetAllExif() const; 179 EXPORT void SetAllExif(const std::string &allExif); 180 181 EXPORT const std::string &GetFrontCamera() const; 182 EXPORT void SetFrontCamera(const std::string &frontCamera); 183 184 EXPORT const std::string &GetUserComment() const; 185 EXPORT void SetUserComment(const std::string &userComment); 186 187 EXPORT const std::string &GetFilePath() const; 188 EXPORT void SetFilePath(const std::string &filePath); 189 190 EXPORT int64_t GetPhotoEditTime() const; 191 EXPORT void SetPhotoEditTime(int64_t photoEditTime); 192 193 EXPORT int32_t GetMovingPhotoEffectMode() const; 194 EXPORT void SetMovingPhotoEffectMode(int32_t effectMode); 195 196 EXPORT int64_t GetCoverPosition() const; 197 EXPORT void SetCoverPosition(int64_t coverPosition); 198 199 EXPORT const std::string &GetBurstKey() const; 200 EXPORT void SetBurstKey(const std::string &burstKey); 201 202 EXPORT int32_t GetBurstCoverLevel() const; 203 EXPORT void SetBurstCoverLevel(int32_t burstCoverLevel); 204 205 EXPORT int32_t GetCEAvailable() const; 206 EXPORT void SetCEAvailable(int32_t ceAvailable); 207 208 EXPORT const std::string &GetDetailTime() const; 209 EXPORT void SetDetailTime(const std::string &detailTime); 210 EXPORT const std::string &GetStrMember(const std::string &name) const; 211 212 EXPORT int32_t GetSupportedWatermarkType() const; 213 EXPORT void SetSupportedWatermarkType(int32_t watermarkType); 214 private: 215 int32_t GetInt32Member(const std::string &name) const; 216 int64_t GetInt64Member(const std::string &name) const; 217 double GetDoubleMember(const std::string &name) const; 218 219 std::string albumUri_; 220 ResultNapiType resultNapiType_; 221 std::unordered_map<std::string, std::variant<int32_t, int64_t, std::string, double>> member_; 222 std::mutex openStatusMapMutex_; 223 std::shared_ptr<std::unordered_map<int32_t, int32_t>> openStatusMap_; 224 std::unordered_map<std::string, ResultSetDataType> resultTypeMap_; 225 }; 226 } // namespace Media 227 } // namespace OHOS 228 229 #endif // INTERFACES_INNERKITS_NATIVE_INCLUDE_FILE_ASSET_H_ 230