1 /* 2 * Copyright (C) 2022 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 #ifndef OHOS_FILEMANAGEMENT_USERFILEMGR_TYPES_H 16 #define OHOS_FILEMANAGEMENT_USERFILEMGR_TYPES_H 17 18 #include <string> 19 #include <vector> 20 #include <tuple> 21 22 namespace OHOS { 23 namespace Media { 24 enum class ResultNapiType { 25 TYPE_MEDIALIBRARY, 26 TYPE_USERFILE_MGR, 27 TYPE_NAPI_MAX 28 }; 29 30 enum MediaType { 31 MEDIA_TYPE_FILE, 32 MEDIA_TYPE_IMAGE, 33 MEDIA_TYPE_VIDEO, 34 MEDIA_TYPE_AUDIO, 35 MEDIA_TYPE_MEDIA, 36 MEDIA_TYPE_ALBUM_LIST, 37 MEDIA_TYPE_ALBUM_LIST_INFO, 38 MEDIA_TYPE_ALBUM, 39 MEDIA_TYPE_SMARTALBUM, 40 MEDIA_TYPE_DEVICE, 41 MEDIA_TYPE_REMOTEFILE, 42 MEDIA_TYPE_NOFILE, 43 MEDIA_TYPE_ALL, 44 }; 45 46 enum class MediaTypeMaskInteger: std::uint32_t { 47 BIT_IMAGEVIDEO = 0x01, 48 BIT_AUDIO = 0x02, 49 BIT_DOCUMENT = 0x04, 50 }; 51 52 /* Constant definitions about media type mask */ 53 constexpr size_t TYPE_MASK_STRING_SIZE = 3; 54 const std::string DEFAULT_TYPE_MASK = ""; 55 const std::string URI_PARAM_KEY_TYPE = "type"; 56 enum { 57 TYPE_MASK_BIT_DEFAULT = '0', 58 TYPE_MASK_BIT_SET = '1' 59 }; 60 61 /* 62 * The position in tuple is explained as below: 63 * @POS_MEDIA_TYPE: The same as enum MediaType 64 * @POS_TYPE_DESCRIPTION: Description of a MediaType in string, the same with interface "MediaType" in d.ts 65 * @POS_TYPE_MASK_INTEGER:Media type bit mask in integer 66 * @POS_TYPE_MASK_STRING_INDEX: Bit index of media type bit mask string 67 * 68 * A media type mask string is consist of three chars, as "000", each char stands one of MediaType. 69 * The char with TYPE_MASK_STRING_INDEX of 0 stands MEDIA_TYPE_FILE, 70 * 1 stands MEDIA_TYPE_AUDIO, 71 * 2 stands MEDIA_TYPE_IMAGE or MEDIA_TYPE_VIDEO. 72 * eg. If user specified a query condition with "MEDIA_TYPE_AUDIO", the type mask string would be "010", 73 */ 74 enum MEDIA_TYPE_TUPLE_INDEX { 75 POS_MEDIA_TYPE = 0, 76 POS_TYPE_DESCRIPTION, 77 POS_TYPE_MASK_INTEGER, 78 POS_TYPE_MASK_STRING_INDEX, 79 }; 80 const std::vector<std::tuple<MediaType, std::string, MediaTypeMaskInteger, size_t>> MEDIA_TYPE_TUPLE_VEC = { 81 std::make_tuple(MEDIA_TYPE_FILE, "FILE", MediaTypeMaskInteger::BIT_DOCUMENT, 0), 82 std::make_tuple(MEDIA_TYPE_IMAGE, "IMAGE", MediaTypeMaskInteger::BIT_IMAGEVIDEO, 2), 83 std::make_tuple(MEDIA_TYPE_VIDEO, "VIDEO", MediaTypeMaskInteger::BIT_IMAGEVIDEO, 2), 84 std::make_tuple(MEDIA_TYPE_AUDIO, "AUDIO", MediaTypeMaskInteger::BIT_AUDIO, 1) 85 }; 86 } // namespace Media 87 } // namespace OHOS 88 #endif // OHOS_FILEMANAGEMENT_USERFILEMGR_TYPES_H 89