• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "media_file_uri.h"
23 #include "pixel_map.h"
24 #include "rdb_helper.h"
25 #include "result_set_bridge.h"
26 #include "single_kvstore.h"
27 #include "userfile_manager_types.h"
28 #include "thumbnail_const.h"
29 
30 #define THUMBNAIL_API_EXPORT __attribute__ ((visibility ("default")))
31 namespace OHOS {
32 namespace Media {
33 class ThumbnailService {
34 public:
35     virtual ~ThumbnailService() = default;
36     THUMBNAIL_API_EXPORT static std::shared_ptr<ThumbnailService> GetInstance();
37     THUMBNAIL_API_EXPORT void ReleaseService();
38 
39     THUMBNAIL_API_EXPORT int GetThumbnailFd(const std::string &uri);
40     THUMBNAIL_API_EXPORT int32_t LcdAging();
41 #ifdef DISTRIBUTED
42     THUMBNAIL_API_EXPORT int32_t LcdDistributeAging(const std::string &udid);
43 #endif
44     THUMBNAIL_API_EXPORT int32_t GenerateThumbnails();
45     THUMBNAIL_API_EXPORT void InterruptBgworker();
46     THUMBNAIL_API_EXPORT void StopAllWorker();
47 #ifdef DISTRIBUTED
48     THUMBNAIL_API_EXPORT int32_t InvalidateDistributeThumbnail(const std::string &udid);
49 #endif
50     THUMBNAIL_API_EXPORT int32_t CreateThumbnail(const std::string &uri, const std::string &path,
51         bool isSync = false);
52     THUMBNAIL_API_EXPORT void InvalidateThumbnail(const std::string &id, const std::string &tableName,
53         const std::string &path = "");
54     THUMBNAIL_API_EXPORT int32_t Init(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
55         const std::shared_ptr<DistributedKv::SingleKvStore> &kvStore,
56         const std::shared_ptr<OHOS::AbilityRuntime::Context> &context);
57 private:
58     ThumbnailService();
59 
60     static std::shared_ptr<ThumbnailService> thumbnailServiceInstance_;
61     static std::mutex instanceLock_;
62     std::shared_ptr<DistributedKv::SingleKvStore> kvStorePtr_;
63     std::shared_ptr<NativeRdb::RdbStore> rdbStorePtr_;
64     std::shared_ptr<OHOS::AbilityRuntime::Context> context_;
65     Size screenSize_;
66 };
67 } // namespace Media
68 } // namespace OHOS
69 
70 #endif  // FRAMEWORKS_SERVICES_THUMBNAIL_SERVICE_INCLUDE_THUMBNAIL_SERVICE_H_
71