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 const std::string &GetCloudId() const; 77 EXPORT void SetCloudId(const std::string &cloudId); 78 79 EXPORT int64_t GetDateAdded() const; 80 EXPORT void SetDateAdded(int64_t dataAdded); 81 82 EXPORT int64_t GetDateModified() const; 83 EXPORT void SetDateModified(int64_t dateModified); 84 85 EXPORT const std::string &GetTitle() const; 86 EXPORT void SetTitle(const std::string &title); 87 88 EXPORT const std::string &GetArtist() const; 89 EXPORT void SetArtist(const std::string &artist); 90 91 EXPORT const std::string &GetAlbum() const; 92 EXPORT void SetAlbum(const std::string &album); 93 94 EXPORT int32_t GetPosition() const; 95 EXPORT void SetPosition(int32_t position); 96 97 EXPORT int32_t GetWidth() const; 98 EXPORT void SetWidth(int32_t width); 99 100 EXPORT int32_t GetHeight() const; 101 EXPORT void SetHeight(int32_t height); 102 103 EXPORT int32_t GetDuration() const; 104 EXPORT void SetDuration(int32_t duration); 105 106 EXPORT int32_t GetOrientation() const; 107 EXPORT void SetOrientation(int32_t orientation); 108 109 EXPORT int32_t GetAlbumId() const; 110 EXPORT void SetAlbumId(int32_t albumId); 111 112 EXPORT int32_t GetOwnerAlbumId() const; 113 EXPORT void SetOwnerAlbumId(int32_t albumId); 114 115 EXPORT const std::string &GetAlbumName() const; 116 EXPORT void SetAlbumName(const std::string &albumName); 117 118 EXPORT int32_t GetParent() const; 119 EXPORT void SetParent(int32_t parent); 120 EXPORT const std::string &GetAlbumUri() const; 121 EXPORT void SetAlbumUri(const std::string &albumUri); 122 EXPORT int64_t GetDateTaken() const; 123 EXPORT void SetDateTaken(int64_t dataTaken); 124 125 EXPORT int64_t GetTimePending() const; 126 EXPORT void SetTimePending(int64_t timePending); 127 128 EXPORT int32_t GetVisitCount() const; 129 EXPORT void SetVisitCount(int32_t visitCount); 130 EXPORT int32_t GetLcdVisitCount() const; 131 EXPORT void SetLcdVisitCount(int32_t lcdVisitCount); 132 EXPORT bool IsFavorite() const; 133 EXPORT void SetFavorite(bool isFavorite); 134 EXPORT bool IsRecentShow() const; 135 EXPORT void SetRecentShow(bool isRecentShow); 136 EXPORT int64_t GetDateTrashed() const; 137 EXPORT void SetDateTrashed(int64_t dateTrashed); 138 139 EXPORT std::string GetPhotoId() const; 140 EXPORT void SetPhotoId(const std::string &photoId); 141 142 EXPORT std::pair<std::string, int> GetPhotoIdAndQuality() const; 143 EXPORT void SetPhotoIdAndQuality(const std::string &photoId, int photoQuality); 144 145 EXPORT void SetLatitude(double latitude); 146 EXPORT double GetLatitude(); 147 EXPORT void SetLongitude(double longitude); 148 EXPORT double GetLongitude(); 149 150 EXPORT const std::string &GetSelfId() const; 151 EXPORT void SetSelfId(const std::string &selfId); 152 EXPORT int32_t GetIsTrash() const; 153 EXPORT void SetIsTrash(int32_t isTrash); 154 EXPORT const std::string GetOwnerPackage() const; 155 EXPORT void SetOwnerPackage(const std::string &ownerPackage); 156 EXPORT const std::string GetOwnerAppId() const; 157 EXPORT void SetOwnerAppId(const std::string &ownerAppId); 158 EXPORT const std::string GetPackageName() const; 159 EXPORT void SetPackageName(const std::string &packageName); 160 161 EXPORT const std::string &GetRecyclePath() const; 162 EXPORT void SetRecyclePath(const std::string &recyclePath); 163 164 EXPORT ResultNapiType GetResultNapiType() const; 165 EXPORT void SetResultNapiType(const ResultNapiType type); 166 167 EXPORT int32_t GetPhotoSubType() const; 168 EXPORT void SetPhotoSubType(int32_t photoSubType); 169 170 EXPORT int32_t GetPhotoIndex() const; 171 172 EXPORT int32_t GetOriginalSubType() const; 173 174 EXPORT const std::string &GetCameraShotKey() const; 175 EXPORT void SetCameraShotKey(const std::string &cameraShotKey); 176 177 EXPORT bool IsHidden() const; 178 EXPORT void SetHidden(bool isHidden); 179 180 EXPORT void SetOpenStatus(int32_t fd, int32_t openStatus); 181 EXPORT void RemoveOpenStatus(int32_t fd); 182 EXPORT int32_t GetOpenStatus(int32_t fd); 183 184 EXPORT std::unordered_map<std::string, std::variant<int32_t, int64_t, std::string, double>> &GetMemberMap(); 185 EXPORT std::variant<int32_t, int64_t, std::string, double> &GetMemberValue(const std::string &name); 186 187 EXPORT std::string GetAssetJson(); 188 EXPORT void SetResultTypeMap(const std::string &colName, ResultSetDataType type); 189 190 EXPORT const std::string &GetAllExif() const; 191 EXPORT void SetAllExif(const std::string &allExif); 192 193 EXPORT const std::string &GetFrontCamera() const; 194 EXPORT void SetFrontCamera(const std::string &frontCamera); 195 196 EXPORT const std::string &GetUserComment() const; 197 EXPORT void SetUserComment(const std::string &userComment); 198 199 EXPORT const std::string &GetFilePath() const; 200 EXPORT void SetFilePath(const std::string &filePath); 201 202 EXPORT int64_t GetPhotoEditTime() const; 203 EXPORT void SetPhotoEditTime(int64_t photoEditTime); 204 205 EXPORT int32_t GetMovingPhotoEffectMode() const; 206 EXPORT void SetMovingPhotoEffectMode(int32_t effectMode); 207 208 EXPORT int64_t GetCoverPosition() const; 209 EXPORT void SetCoverPosition(int64_t coverPosition); 210 211 EXPORT const std::string &GetBurstKey() const; 212 EXPORT void SetBurstKey(const std::string &burstKey); 213 214 EXPORT int32_t GetBurstCoverLevel() const; 215 EXPORT void SetBurstCoverLevel(int32_t burstCoverLevel); 216 217 EXPORT const std::string &GetDetailTime() const; 218 EXPORT void SetDetailTime(const std::string &detailTime); 219 220 EXPORT int32_t GetCEAvailable() const; 221 EXPORT void SetCEAvailable(int32_t ceAvailable); 222 223 EXPORT int32_t GetSupportedWatermarkType() const; 224 EXPORT void SetSupportedWatermarkType(int32_t watermarkType); 225 226 EXPORT int32_t GetIsAuto() const; 227 EXPORT void SetIsAuto(int32_t isAuto); 228 229 EXPORT const std::string &GetStrMember(const std::string &name) const; 230 EXPORT int32_t GetInt32Member(const std::string &name) const; 231 EXPORT int64_t GetInt64Member(const std::string &name) const; 232 EXPORT double GetDoubleMember(const std::string &name) const; SetMemberValue(const std::string & name,const std::variant<int32_t,int64_t,std::string,double> & value)233 EXPORT void SetMemberValue(const std::string &name, 234 const std::variant<int32_t, int64_t, std::string, double> &value) 235 { 236 member_[name] = value; 237 } 238 239 EXPORT void SetUserId(int32_t userId); 240 EXPORT int32_t GetUserId(); 241 242 EXPORT void SetStageVideoTaskStatus(int32_t stageVideoTaskStatus); 243 EXPORT int32_t GetStageVideoTaskStatus() const; 244 245 EXPORT void SetExifRotate(int32_t exifRotate); 246 EXPORT int32_t GetExifRotate() const; 247 248 private: 249 int32_t userId_ = -1; 250 std::string albumUri_; 251 ResultNapiType resultNapiType_; 252 std::unordered_map<std::string, std::variant<int32_t, int64_t, std::string, double>> member_; 253 std::mutex openStatusMapMutex_; 254 std::shared_ptr<std::unordered_map<int32_t, int32_t>> openStatusMap_; 255 std::mutex resultTypeMapMutex_; 256 std::unordered_map<std::string, ResultSetDataType> resultTypeMap_; 257 }; 258 } // namespace Media 259 } // namespace OHOS 260 261 #endif // INTERFACES_INNERKITS_NATIVE_INCLUDE_FILE_ASSET_H_ 262