1 /* 2 * Copyright (C) 2024-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 OHOS_MEDIA_BURST_KEY_GENERATOR_H 17 #define OHOS_MEDIA_BURST_KEY_GENERATOR_H 18 19 #include <mutex> 20 21 #include "backup_const.h" 22 23 namespace OHOS::Media { 24 class BurstKeyGenerator { 25 public: 26 std::string FindBurstKey(const FileInfo &fileInfo); 27 28 private: 29 std::string FindTitlePrefix(const FileInfo &fileInfo); 30 std::string FindGroupHash(const FileInfo &fileInfo); 31 int32_t FindGroupIndex(const FileInfo &fileInfo); 32 std::string FindObjectHash(const FileInfo &fileInfo); 33 std::string GenerateUuid(); 34 std::string ToString(const FileInfo &fileInfo); 35 36 private: 37 const std::string TITLE_KEY_WORDS_OF_BURST = "_BURST"; 38 enum { BURST_COVER_TYPE = 1, BURST_MEMBER_TYPE = 2, UUID_STR_LENGTH = 37, DISPLAY_NAME_PREFIX_LENGTH = 20 }; 39 std::unordered_map<std::string, std::string> groupHashMap_; 40 std::unordered_map<std::string, int32_t> objectHashMap_; 41 std::mutex burstKeyLock_; 42 }; 43 } // namespace OHOS::Media 44 45 #endif // OHOS_MEDIA_BURST_KEY_GENERATOR_H