1 /* 2 * Copyright (C) 2021 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 FILE_ASSET_H 17 #define FILE_ASSET_H 18 19 #include <string> 20 #include <limits.h> 21 22 #include "media_lib_service_const.h" 23 #include "media_data_ability_const.h" 24 #include "media_file_utils.h" 25 26 #include "media_log.h" 27 28 namespace OHOS { 29 namespace Media { 30 /** 31 * @brief Class for filling all file asset parameters 32 * 33 * @since 1.0 34 * @version 1.0 35 */ 36 class FileAsset { 37 public: 38 FileAsset(); 39 virtual ~FileAsset() = default; 40 41 int32_t GetId() const; 42 void SetId(int32_t id); 43 44 const std::string &GetUri() const; 45 void SetUri(const std::string &uri); 46 47 const std::string &GetPath() const; 48 void SetPath(const std::string &path); 49 50 const std::string &GetRelativePath() const; 51 void SetRelativePath(const std::string &relativePath); 52 53 const std::string &GetMimeType() const; 54 void SetMimeType(const std::string &mimeType); 55 56 MediaType GetMediaType() const; 57 void SetMediaType(MediaType mediaType); 58 59 const std::string &GetDisplayName() const; 60 void SetDisplayName(const std::string &displayName); 61 62 int64_t GetSize() const; 63 void SetSize(int64_t size); 64 65 int64_t GetDateAdded() const; 66 void SetDateAdded(int64_t dataAdded); 67 68 int64_t GetDateModified() const; 69 void SetDateModified(int64_t dateModified); 70 71 const std::string &GetTitle() const; 72 void SetTitle(const std::string &title); 73 74 const std::string &GetArtist() const; 75 void SetArtist(const std::string &artist); 76 77 const std::string &GetAlbum() const; 78 void SetAlbum(const std::string &album); 79 80 int32_t GetWidth() const; 81 void SetWidth(int32_t width); 82 83 int32_t GetHeight() const; 84 void SetHeight(int32_t height); 85 86 int32_t GetDuration() const; 87 void SetDuration(int32_t duration); 88 89 int32_t GetOrientation() const; 90 void SetOrientation(int32_t orientation); 91 92 int32_t GetAlbumId() const; 93 void SetAlbumId(int32_t albumId); 94 95 const std::string &GetAlbumName() const; 96 void SetAlbumName(const std::string &albumName); 97 98 int32_t GetParent() const; 99 void SetParent(int32_t parent); 100 const std::string &GetAlbumUri() const; 101 void SetAlbumUri(const std::string &albumUri); 102 int64_t GetDateTaken() const; 103 void SetDateTaken(int64_t dataTaken); 104 105 bool IsPending() const; 106 void SetPending(bool isPending); 107 int64_t GetTimePending() const; 108 void SetTimePending(int64_t timePending); 109 110 bool IsFavorite() const; 111 void SetFavorite(bool isFavorite); 112 int64_t GetDateTrashed() const; 113 void SetDateTrashed(int64_t dateTrashed); 114 115 const std::string &GetSelfId() const; 116 void SetSelfId(const std::string &selfId); 117 118 int32_t CreateAsset(const std::string &filePath); 119 int32_t ModifyAsset(const std::string& oldPath, const std::string &newPath); 120 int32_t DeleteAsset(const std::string &filePath); 121 int32_t OpenAsset(const std::string &filePath, const std::string &mode); 122 int32_t CloseAsset(int32_t fd); 123 bool IsFileExists(const std::string &filePath); 124 private: 125 int32_t id_; 126 std::string uri_; 127 std::string path_; 128 std::string relativePath_; 129 std::string mimeType_; 130 MediaType mediaType_; 131 std::string displayName_; 132 int64_t size_; 133 int64_t dateAdded_; 134 int64_t dateModified_; 135 136 // audio 137 std::string title_; 138 std::string artist_; 139 std::string album_; 140 141 // image,video 142 int32_t width_; 143 int32_t height_; 144 int32_t duration_; 145 int32_t orientation_; 146 147 // album 148 int32_t albumId_; 149 std::string albumName_; 150 int32_t parent_; 151 std::string albumUri_; 152 int64_t dateTaken_; 153 154 bool isPending_; 155 int64_t timePending_; 156 157 bool isFavorite_; 158 int64_t dateTrashed_; 159 160 std::string selfId_; 161 }; 162 } // namespace Media 163 } // namespace OHOS 164 #endif // FILE_ASSET_H