1 /* 2 * Copyright (C) 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 FRAMEWORKS_ANI_SRC_INCLUDE_THUMBNAIL_MANAGER_H 17 #define FRAMEWORKS_ANI_SRC_INCLUDE_THUMBNAIL_MANAGER_H 18 19 #include <condition_variable> 20 #include <list> 21 #include <memory> 22 #include <mutex> 23 #include <string> 24 #include <thread> 25 26 #include "image_type.h" 27 #include "nocopyable.h" 28 #include "safe_map.h" 29 #include "safe_queue.h" 30 #include "pixel_map.h" 31 #include "unique_fd.h" 32 #include "userfile_manager_types.h" 33 34 namespace OHOS { 35 namespace Media { 36 #define EXPORT __attribute__ ((visibility ("default"))) 37 38 using PixelMapPtr = std::unique_ptr<PixelMap>; 39 40 class MMapFdPtr { 41 public: 42 explicit MMapFdPtr(int32_t fd, bool isNeedRelease); 43 ~MMapFdPtr(); 44 void* GetFdPtr(); 45 off_t GetFdSize(); 46 bool IsValid(); 47 private: 48 void* fdPtr_ = nullptr; 49 off_t size_ = 0; 50 bool isValid_ = false; 51 bool isNeedRelease_ = false; 52 }; 53 54 class ThumbnailManagerAni : NoCopyable { 55 public: 56 virtual ~ThumbnailManagerAni() = default; 57 static std::shared_ptr<ThumbnailManagerAni> GetInstance(); 58 59 EXPORT static std::unique_ptr<PixelMap> QueryThumbnail(const std::string &uriStr, 60 const Size &size, const std::string &path); 61 62 private: 63 ThumbnailManagerAni() = default; 64 }; 65 } // Media 66 } // OHOS 67 68 #endif // FRAMEWORKS_ANI_SRC_INCLUDE_THUMBNAIL_MANAGER_H 69