• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FRAMEWORKS_INNERKITSIMPL_MEDIA_LIBRARY_INCLUDE_MOVING_PHOTO_FILE_UTILS_H
17 #define FRAMEWORKS_INNERKITSIMPL_MEDIA_LIBRARY_INCLUDE_MOVING_PHOTO_FILE_UTILS_H
18 
19 #include <string>
20 
21 #include "photo_file_utils.h"
22 
23 namespace OHOS::Media {
24 #define EXPORT __attribute__ ((visibility ("default")))
25 EXPORT const std::string LIVE_TAG = "LIVE_";
26 
27 EXPORT constexpr int32_t LIVE_TAG_LEN = 20;
28 EXPORT constexpr int32_t PLAY_INFO_LEN = 20;
29 EXPORT constexpr int32_t VERSION_TAG_LEN = 20;
30 EXPORT constexpr int32_t CINEMAGRAPH_INFO_SIZE_LEN = 4;
31 EXPORT constexpr int32_t MIN_STANDARD_SIZE = LIVE_TAG_LEN + PLAY_INFO_LEN + VERSION_TAG_LEN;
32 
33 class MovingPhotoFileUtils : public PhotoFileUtils {
34 public:
35     EXPORT static int32_t ConvertToMovingPhoto(const std::string &livePhotoPath,
36         const std::string &movingPhotoImagePath, const std::string &movingPhotoVideoPath,
37         const std::string &extraDataPath);
38     EXPORT static int32_t GetMovingPhotoDetailedSize(const int32_t fd,
39         int64_t &imageSize, int64_t &videoSize, int64_t &extraDataSize);
40     EXPORT static int32_t ConvertToMovingPhoto(const int32_t fd,
41         const std::string &movingPhotoImagePath, const std::string &movingPhotoVideoPath,
42         const std::string &extraDataPath);
43     EXPORT static int32_t ConvertToMovingPhoto(const int32_t fd,
44         void *imageArrayBuffer, void *videoArrayBuffer, void *extraDataArrayBuffer);
45     EXPORT static int32_t ConvertToLivePhoto(const std::string &movingPhotoImagepath, int64_t coverPosition,
46         std::string &livePhotoPath, int32_t userId = -1);
47     EXPORT static int32_t ConvertToSourceLivePhoto(const std::string &movingPhotoImagepath,
48         std::string &sourceLivePhotoPath, int32_t userId = -1);
49     EXPORT static int32_t GetCoverPosition(const std::string &videoPath, const uint32_t frameIndex,
50         uint64_t &coverPosition, int32_t scene = 0);
51     EXPORT static int32_t GetVersionAndFrameNum(const std::string &tag,
52         uint32_t &version, uint32_t &frameIndex, bool &hasCinemagraphInfo);
53     EXPORT static int32_t GetVersionAndFrameNum(int32_t fd, uint32_t &version, uint32_t &frameIndex,
54         bool &hasCinemagraphInfo);
55     EXPORT static std::string GetMovingPhotoVideoPath(const std::string &imagePath, int32_t userId = -1);
56     EXPORT static std::string GetMovingPhotoExtraDataDir(const std::string &imagePath, int32_t userId = -1);
57     EXPORT static std::string GetMovingPhotoExtraDataPath(const std::string &imagePath, int32_t userId = -1);
58     EXPORT static std::string GetSourceMovingPhotoImagePath(const std::string &imagePath, int32_t userId = -1);
59     EXPORT static std::string GetSourceMovingPhotoVideoPath(const std::string &imagePath, int32_t userId = -1);
60     EXPORT static std::string GetLivePhotoCacheDir(const std::string &imagePath, int32_t userId = -1);
61     EXPORT static std::string GetLivePhotoCachePath(const std::string &imagePath, int32_t userId = -1);
62     EXPORT static std::string GetSourceLivePhotoCachePath(const std::string &imagePath, int32_t userId = -1);
63     EXPORT static bool IsMovingPhoto(int32_t subtype, int32_t effectMode, int32_t originalSubtype);
64     EXPORT static bool IsGraffiti(int32_t subtype, int32_t originalSubtype);
65     EXPORT static bool IsLivePhoto(const std::string &path);
66     EXPORT static int32_t GetLivePhotoSize(int32_t fd, int64_t &liveSize);
67     EXPORT static int32_t GetExtraDataLen(const std::string &imagePath, const std::string &videoPath,
68         uint32_t frameIndex, int64_t coverPosition, off_t &fileSize, bool isCameraShotMovingPhoto = false);
69     EXPORT static uint32_t GetFrameIndex(int64_t time, const int32_t fd);
70     EXPORT static size_t GetMovingPhotoSize(const std::string &imagePath, int32_t userId = -1);
71 };
72 } // namespace OHOS::Media
73 
74 #endif // FRAMEWORKS_INNERKITSIMPL_MEDIA_LIBRARY_INCLUDE_MOVING_PHOTO_FILE_UTILS_H
75