1 /* 2 * Copyright (c) 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_MEDIALIBRARY_MOVING_PHOTO_PROCESSOR_H 17 #define OHOS_MEDIALIBRARY_MOVING_PHOTO_PROCESSOR_H 18 19 #include "abs_shared_result_set.h" 20 #include "values_bucket.h" 21 22 namespace OHOS { 23 namespace Media { 24 #define EXPORT __attribute__ ((visibility ("default"))) 25 26 EXPORT const std::string REFRESH_CLOUD_LIVE_PHOTO_FLAG = "persist.multimedia.medialibrary.cloudLivePhoto.isRefreshed"; 27 EXPORT const std::string CLOUD_LIVE_PHOTO_REFRESHED = "1"; 28 EXPORT const std::string CLOUD_LIVE_PHOTO_NOT_REFRESHED = "0"; 29 EXPORT const std::string COMPAT_LIVE_PHOTO_FILE_ID = "persist.multimedia.medialibrary.compatLivePhoto.fileId"; 30 31 class MovingPhotoProcessor { 32 public: 33 EXPORT static void StartProcess(); 34 EXPORT static void StopProcess(); 35 36 private: 37 typedef struct { 38 int32_t fileId; 39 int32_t subtype; 40 int32_t effectMode; 41 int64_t size; 42 std::string path; 43 } MovingPhotoData; 44 45 typedef struct { 46 std::vector<MovingPhotoData> movingPhotos; 47 } MovingPhotoDataList; 48 49 typedef struct { 50 bool isLivePhoto; 51 int32_t fileId; 52 int32_t mediaType; 53 int32_t subtype; 54 int32_t position; 55 int64_t editTime; 56 int64_t coverPosition; 57 int64_t metaDateModified; 58 std::string path; 59 } LivePhotoData; 60 61 typedef struct { 62 std::vector<LivePhotoData> livePhotos; 63 } LivePhotoDataList; 64 65 static std::shared_ptr<NativeRdb::ResultSet> QueryMovingPhoto(); 66 static void ParseMovingPhotoData(std::shared_ptr<NativeRdb::ResultSet>& resultSet, MovingPhotoDataList& dataList); 67 static void CompatMovingPhoto(const MovingPhotoDataList& dataList); 68 static int32_t GetUpdatedMovingPhotoData(const MovingPhotoData& currentData, MovingPhotoData& newData); 69 static void UpdateMovingPhotoData(const MovingPhotoData& movingPhotoData); 70 static void StartProcessMovingPhoto(); 71 72 static std::shared_ptr<NativeRdb::ResultSet> QueryCandidateLivePhoto(); 73 static void ParseLivePhotoData(std::shared_ptr<NativeRdb::ResultSet>& resultSet, LivePhotoDataList& dataList); 74 static void CompatLivePhoto(const LivePhotoDataList& dataList); 75 static int32_t GetUpdatedLivePhotoData(const LivePhotoData& currentData, LivePhotoData& newData); 76 static int32_t ProcessLocalLivePhoto(LivePhotoData& data); 77 static int32_t ProcessLocalCloudLivePhoto(LivePhotoData& data); 78 static void UpdateLivePhotoData(const LivePhotoData& livePhotoData); 79 static void StartProcessLivePhoto(); 80 81 static bool isProcessing_; 82 }; 83 } // namespace Media 84 } // namespace OHOS 85 #endif // OHOS_MEDIALIBRARY_MOVING_PHOTO_PROCESSOR_H