1 /*
2  * Copyright (C) 2023 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_KITS_JS_COMMON_INCLUDE_IMAGE_SOURCE_MDK_KITS_H
17 #define FRAMEWORKS_KITS_JS_COMMON_INCLUDE_IMAGE_SOURCE_MDK_KITS_H
18 
19 #include "common_utils.h"
20 #include "image_source_napi.h"
21 #include "image_source_mdk.h"
22 #include "raw_file.h"
23 
24 namespace OHOS {
25 namespace Media {
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 struct DataArray {
31     uint8_t* data = nullptr;
32     uint32_t dataSize = 0;
33 };
34 
35 struct ImageSourceArgs {
36     struct OhosImageSource* source;
37     struct OhosImageSourceOps* sourceOps;
38     struct OhosImageDecodingOps* decodingOps;
39     struct OhosImageSourceDelayTimeList* outDelayTimes;
40     struct OhosImageSourceSupportedFormatList* outFormats;
41     struct OhosImageSourceInfo* outInfo;
42     struct OhosImageSourceProperty* inPropertyKey;
43     struct OhosImageSourceProperty* propertyVal;
44     struct OhosImageSourceUpdateData* inUpdateData;
45     DataArray dataArray;
46     std::string uri;
47     int32_t fd = -1;
48     RawFileDescriptor rawFile;
49     ImageSourceNapi* napi;
50     napi_env inEnv;
51     napi_value inVal;
52     int32_t inInt32;
53     napi_value *outVal;
54     uint32_t* outUint32;
55 };
56 
57 enum {
58     ENV_FUNC_IMAGE_SOURCE_CREATE,
59     ENV_FUNC_IMAGE_SOURCE_CREATE_FROM_URI,
60     ENV_FUNC_IMAGE_SOURCE_CREATE_FROM_FD,
61     ENV_FUNC_IMAGE_SOURCE_CREATE_FROM_DATA,
62     ENV_FUNC_IMAGE_SOURCE_CREATE_FROM_RAW_FILE,
63     ENV_FUNC_IMAGE_SOURCE_CREATE_INCREMENTAL,
64     ENV_FUNC_IMAGE_SOURCE_UNWRAP,
65     STA_FUNC_IMAGE_SOURCE_GET_SUPPORTED_FORMATS,
66     CTX_FUNC_IMAGE_SOURCE_CREATE_PIXELMAP,
67     CTX_FUNC_IMAGE_SOURCE_CREATE_PIXELMAP_LIST,
68     CTX_FUNC_IMAGE_SOURCE_GET_DELAY_TIME,
69     CTX_FUNC_IMAGE_SOURCE_GET_FRAME_COUNT,
70     CTX_FUNC_IMAGE_SOURCE_GET_IMAGE_INFO,
71     CTX_FUNC_IMAGE_SOURCE_GET_IMAGE_PROPERTY,
72     CTX_FUNC_IMAGE_SOURCE_MODIFY_IMAGE_PROPERTY,
73     CTX_FUNC_IMAGE_SOURCE_UPDATE_DATA
74 };
75 
76 int32_t ImageSourceNativeCall(int32_t mode, struct ImageSourceArgs* args);
77 #ifdef __cplusplus
78 };
79 #endif
80 } // namespace Media
81 } // namespace OHOS
82 
83 #endif // FRAMEWORKS_KITS_JS_COMMON_INCLUDE_IMAGE_SOURCE_MDK_KITS_H