• 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 MEDIA_MOVING_PHOTO_CALL_TRANSCODE_H
17 #define MEDIA_MOVING_PHOTO_CALL_TRANSCODE_H
18 
19 #include <string>
20 #include "napi/native_api.h"
21 #include "unique_fd.h"
22 
23 namespace OHOS {
24 namespace Media {
25 struct MovingPhotoProgressHandler {
26     napi_env env;
27     napi_env mediaAssetEnv;
28     napi_ref progressHandlerRef;
29     UniqueFd srcFd;
30     UniqueFd destFd;
31     int64_t size;
32     int64_t offset;
33     int32_t extra;
34     int32_t errCode;
35     void *contextData;
36     napi_threadsafe_function onProgressFunc;
37     bool isComplete;
38     std::function<void(napi_env, void*, int)> callbackFunc;
MovingPhotoProgressHandlerMovingPhotoProgressHandler39     MovingPhotoProgressHandler() : env(nullptr), mediaAssetEnv(nullptr), progressHandlerRef(nullptr),
40         srcFd(-1), destFd(-1), size(0), offset(0), extra(0), errCode(0), contextData(nullptr),
41         onProgressFunc(nullptr), isComplete(false) {}
42 };
43 
44 class MovingPhotoCallTranscoder {
45 public:
46     MovingPhotoCallTranscoder() = delete;
47     ~MovingPhotoCallTranscoder() = delete;
48     static bool DoTranscode(const std::shared_ptr<MovingPhotoProgressHandler> &MovingPhotoProgressHandler);
49     static void OnProgress(napi_env env, napi_value cb, void *context, void *data);
50 };
51 
52 } // namespace Media
53 } // namespace OHOS
54 #endif // MEDIA_MOVING_PHOTO_CALL_TRANSCODE_H
55