• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_CLOUD_SYNC_CLOUD_MEDIA_DATA_CLIENT_HANDLER_H
17 #define OHOS_MEDIA_CLOUD_SYNC_CLOUD_MEDIA_DATA_CLIENT_HANDLER_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "i_cloud_media_data_client.h"
23 #include "get_aging_file_vo.h"
24 #include "cloud_media_define.h"
25 #include "on_download_thms_vo.h"
26 #include "cloud_media_data_client_handler_processor.h"
27 
28 namespace OHOS::Media::CloudSync {
29 class EXPORT CloudMediaDataClientHandler : public ICloudMediaDataClient {
30 public:  // constructors & destructors
31     CloudMediaDataClientHandler() = default;
32     virtual ~CloudMediaDataClientHandler() = default;
33 
34 public:  // getter & setter
35     void SetTraceId(const std::string &traceId) override;
36     std::string GetTraceId() const override;
37     void SetUserId(const int32_t &userId) override;
38 
39 public:
40     // 核查
41     int32_t UpdateDirty(const std::string &cloudId, DirtyTypes dirtyType) override;
42     int32_t UpdatePosition(const std::vector<std::string> &cloudIds, int32_t position) override;
43     int32_t UpdateThmStatus(const std::string &cloudId, int32_t thmStatus) override;
44     int32_t GetAgingFile(const int64_t time, int32_t mediaType, int32_t sizeLimit, int32_t offset,
45         std::vector<CloudMetaData> &metaData) override;
46     int32_t GetActiveAgingFile(const int64_t time, int32_t mediaType, int32_t sizeLimit, int32_t offset,
47         std::vector<CloudMetaData> &metaData) override;
48     // 下载
49     int32_t GetDownloadAsset(
50         const std::vector<std::string> &uris, std::vector<CloudMetaData> &cloudMetaDataVec) override;
51     int32_t GetDownloadThmsByUri(
52         const std::vector<std::string> &uri, int32_t type, std::vector<CloudMetaData> &metaData) override;
53     int32_t OnDownloadAsset(const std::vector<std::string> &cloudIds, std::vector<MediaOperateResult> &result) override;
54     int32_t GetDownloadThms(std::vector<CloudMetaData> &cloudMetaDataVec, const DownloadThumPara &param) override;
55     int32_t OnDownloadThms(const std::unordered_map<std::string, int32_t> &resMap, int32_t &failSize) override;
56     int32_t GetDownloadThmNum(int32_t &totalNum, int32_t type) override;
57     // 缓存视频
58     int32_t GetVideoToCache(std::vector<CloudMetaData> &cloudMetaDataVec, int32_t size) override;
59     // 大数据
60     int32_t GetFilePosStat(std::vector<uint64_t> &filePosStat) override;
61     int32_t GetCloudThmStat(std::vector<uint64_t> &cloudThmStat) override;
62     int32_t GetDirtyTypeStat(std::vector<uint64_t> &dirtyTypeStat) override;
63     int32_t UpdateLocalFileDirty(std::vector<MDKRecord> &records) override;
64     int32_t UpdateSyncStatus(const std::string &cloudId, int32_t syncStatus) override;
65 
66     int32_t GetCloudSyncUnPreparedData(int32_t &result) override;
67     int32_t SubmitCloudSyncPreparedDataTask() override;
68 
69 private:
70     int32_t GetAgingFile(uint32_t operationCode, GetAgingFileReqBody &reqBody, std::vector<CloudMetaData> &metaData);
71     int32_t OnDownloadThmsInner(
72         std::vector<OnDownloadThmsReqBody::DownloadThmsData> &downloadThmsDataList, int32_t &failSize);
73 
74 private:
75     enum {
76         SIZE_FILE_POSITION_LEN = 3,
77         SIZE_CLOUD_THM_STAT_LEN = 4,
78         SIZE_DIRTY_TYPE_LEN = 5,
79     };
80     const int32_t MAX_DOWNLOAD_THMS_SIZE = 1000;
81 
82 private:
83     std::string traceId_;
84     int32_t userId_;
85     CloudMediaDataClientHandlerProcessor processor_;
86 };
87 }  // namespace OHOS::Media::CloudSync
88 #endif  // OHOS_MEDIA_CLOUD_SYNC_CLOUD_MEDIA_DATA_CLIENT_HANDLER_H