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 16 #ifndef FRAMEWORKS_SERVICES_THUMBNAIL_SERVICE_INCLUDE_THUMBNAIL_SERVICE_H_ 17 #define FRAMEWORKS_SERVICES_THUMBNAIL_SERVICE_INCLUDE_THUMBNAIL_SERVICE_H_ 18 19 #include <mutex> 20 21 #include "ability_context.h" 22 #include "pixel_map.h" 23 #include "result_set_bridge.h" 24 #include "rdb_helper.h" 25 #include "single_kvstore.h" 26 #include "thumbnail_const.h" 27 28 #define THUMBNAIL_API_EXPORT __attribute__ ((visibility ("default"))) 29 namespace OHOS { 30 namespace Media { 31 class ThumbnailService { 32 public: 33 virtual ~ThumbnailService() = default; 34 THUMBNAIL_API_EXPORT static std::shared_ptr<ThumbnailService> GetInstance(); 35 THUMBNAIL_API_EXPORT void ReleaseService(); 36 37 THUMBNAIL_API_EXPORT std::shared_ptr<DataShare::ResultSetBridge> GetThumbnail(const std::string &uri); 38 THUMBNAIL_API_EXPORT int32_t LcdAging(); 39 THUMBNAIL_API_EXPORT int32_t LcdDistributeAging(const std::string &udid); 40 THUMBNAIL_API_EXPORT int32_t GenerateThumbnails(); 41 THUMBNAIL_API_EXPORT void InterruptBgworker(); 42 THUMBNAIL_API_EXPORT void StopAllWorker(); 43 THUMBNAIL_API_EXPORT int32_t InvalidateDistributeThumbnail(const std::string &udid); 44 THUMBNAIL_API_EXPORT int32_t CreateThumbnailAsync(const std::string &uri); 45 THUMBNAIL_API_EXPORT int32_t CreateThumbnail(const std::string &uri); 46 THUMBNAIL_API_EXPORT static bool ParseThumbnailInfo(const std::string &uriString); 47 THUMBNAIL_API_EXPORT void InvalidateThumbnail(const std::string &id); 48 THUMBNAIL_API_EXPORT int32_t Init(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore, 49 const std::shared_ptr<DistributedKv::SingleKvStore> &kvStore, 50 const std::shared_ptr<OHOS::AbilityRuntime::Context> &context); 51 private: 52 ThumbnailService(); 53 54 static std::shared_ptr<ThumbnailService> thumbnailServiceInstance_; 55 static std::mutex instanceLock_; 56 std::shared_ptr<DistributedKv::SingleKvStore> kvStorePtr_; 57 std::shared_ptr<NativeRdb::RdbStore> rdbStorePtr_; 58 std::shared_ptr<OHOS::AbilityRuntime::Context> context_; 59 int32_t windowSize_ = DEFAULT_LCD_SIZE; 60 }; 61 } // namespace Media 62 } // namespace OHOS 63 64 #endif // FRAMEWORKS_SERVICES_THUMBNAIL_SERVICE_INCLUDE_THUMBNAIL_SERVICE_H_ 65