• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "napi/native_api.h"
17 #include "native_common.h"
18 #include "cstdlib"
19 #include <map>
20 #include <js_native_api_types.h>
21 #include <multimedia/player_framework/native_avcodec_base.h>
22 #include <multimedia/player_framework/native_averrors.h>
23 #include <multimedia/player_framework/native_avformat.h>
24 #include <multimedia/player_framework/native_avmemory.h>
25 #include <multimedia/player_framework/native_avbuffer.h>
26 
27 #define SUCCESS 0
28 #define FAIL (-1)
29 #define PARAM_1 1
30 #define MPARAM_1 1.0
31 #define FPARAM_1 (-1)
32 #define PARAM_2 2
33 #define PARAM_0 0
34 #define PARAM_10 10
35 #define PARAM_44100 44100
36 #define PARAM_100 100
37 #define PARAM_400 400
38 #define PARAM_500 500
39 
40 enum OH_MD_KEY {
41     KEY_RANGE_FLAG = 1,
42     KEY_COLOR_PRIMARIES,
43     KEY_TRANSFER_CHARACTERISTICS,
44     KEY_MATRIX_COEFFICIENTS,
45     KEY_REQUEST_I_FRAME,
46     KEY_CODEC_CONFIG,
47     KEY_TITLE,
48     KEY_ARTIST,
49     KEY_ALBUM,
50     KEY_ALBUM_ARTIST,
51     KEY_DATE,
52     KEY_COMMENT,
53     KEY_GENRE,
54     KEY_COPYRIGHT,
55     KEY_LANGUAGE,
56     KEY_DESCRIPTION,
57     KEY_LYRICS,
58     KEY_TRACK_COUNT,
59     KEY_CHANNEL_LAYOUT,
60     KEY_BITS_PER_CODED_SAMPLE,
61     KEY_AAC_IS_ADTS,
62     KEY_SBR,
63     KEY_COMPLIANCE_LEVEL,
64     KEY_IDENTIFICATION_HEADER,
65     KEY_SETUP_HEADER,
66     KEY_SCALING_MODE,
67     MAX_INPUT_BUFFER_COUNT,
68     MAX_OUTPUT_BUFFER_COUNT,
69     KEY_TRACK_TYPE,
70     KEY_CODEC_MIME,
71     KEY_DURATION,
72     KEY_BITRATE,
73     KEY_MAX_INPUT_SIZE,
74     KEY_WIDTH,
75     KEY_HEIGHT,
76     KEY_PIXEL_FORMAT,
77     KEY_FRAME_RATE,
78     KEY_AUD_CHANNEL_COUNT,
79     KEY_AUD_SAMPLE_RATE,
80     KEY_I_FRAME_INTERVAL,
81     KEY_ROTATION,
82 };
83 
84 const std::map <const char *, bool> Set_Buffer_Key_Map = {
85     {OH_MD_KEY_CODEC_CONFIG, true},
86     {OH_MD_KEY_IDENTIFICATION_HEADER, true},
87     {OH_MD_KEY_SETUP_HEADER, true},
88     {OH_MD_KEY_AUDIO_VIVID_METADATA, true},
89 };
90 
91 const char *bufferKey = "buffer value key";
92 const char *intKey = "int value key";
93 const char *longKey = "long value key";
94 const char *floatKey = "float value key";
95 const char *doubleKey = "double value key";
96 const char *stringKey = "string value key";
97 const char *stringValue = "string_value";
98 int32_t intValue = PARAM_1;
99 int64_t longValue = PARAM_1;
100 float floatValue = MPARAM_1;
101 double doubleValue = MPARAM_1;
102 constexpr int32_t INFO_SIZE = PARAM_100;
MultimediaCoreAVFormatCreate(napi_env env,napi_callback_info)103 static napi_value MultimediaCoreAVFormatCreate(napi_env env, napi_callback_info)
104 {
105     struct OH_AVFormat *ReturnValue = OH_AVFormat_Create();
106     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AudioDecoder_CreateByMime failed");
107     OH_AVFormat_Destroy(ReturnValue);
108     napi_value result = nullptr;
109     napi_create_int32(env, SUCCESS, &result);
110     return result;
111 }
112 
MultimediaCoreAVFormatCreateAudioFormatOne(napi_env env,napi_callback_info)113 static napi_value MultimediaCoreAVFormatCreateAudioFormatOne(napi_env env, napi_callback_info)
114 {
115     struct OH_AVFormat *ReturnValue = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_FLAC,
116         PARAM_44100, PARAM_2);
117     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_CreateAudioFormat failed");
118     OH_AVFormat_Destroy(ReturnValue);
119     napi_value result = nullptr;
120     napi_create_int32(env, SUCCESS, &result);
121     return result;
122 }
123 
MultimediaCoreAVFormatCreateAudioFormatTwo(napi_env env,napi_callback_info)124 static napi_value MultimediaCoreAVFormatCreateAudioFormatTwo(napi_env env, napi_callback_info)
125 {
126     struct OH_AVFormat *ReturnValue = OH_AVFormat_CreateAudioFormat(nullptr, PARAM_44100, PARAM_2);
127     NAPI_ASSERT(env, ReturnValue == nullptr, "OH_AVFormat_CreateAudioFormat failed");
128     napi_value result = nullptr;
129     napi_create_int32(env, SUCCESS, &result);
130     return result;
131 }
132 
MultimediaCoreAVFormatCreateVideoFormatOne(napi_env env,napi_callback_info)133 static napi_value MultimediaCoreAVFormatCreateVideoFormatOne(napi_env env, napi_callback_info)
134 {
135     struct OH_AVFormat *ReturnValue = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_AVC,
136         PARAM_400, PARAM_500);
137     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_CreateVideoFormat failed");
138     OH_AVFormat_Destroy(ReturnValue);
139     napi_value result = nullptr;
140     napi_create_int32(env, SUCCESS, &result);
141     return result;
142 }
143 
MultimediaCoreAVFormatCreateVideoFormatTwo(napi_env env,napi_callback_info)144 static napi_value MultimediaCoreAVFormatCreateVideoFormatTwo(napi_env env, napi_callback_info)
145 {
146     struct OH_AVFormat *ReturnValue = OH_AVFormat_CreateVideoFormat(nullptr, PARAM_400, PARAM_500);
147     NAPI_ASSERT(env, ReturnValue == nullptr, "OH_AVFormat_CreateVideoFormat failed");
148     napi_value result = nullptr;
149     napi_create_int32(env, SUCCESS, &result);
150     return result;
151 }
152 
MultimediaCoreAVFormatCopyOne(napi_env env,napi_callback_info)153 static napi_value MultimediaCoreAVFormatCopyOne(napi_env env, napi_callback_info)
154 {
155     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_AVC, PARAM_400, PARAM_500);
156     OH_AVFormat *NewAVFormat = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_AVC, PARAM_400, PARAM_500);
157     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
158     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_Copy failed");
159     napi_value result = nullptr;
160     OH_AVFormat_Destroy(NewAVFormat);
161     OH_AVFormat_Destroy(AVFormat);
162     napi_create_int32(env, SUCCESS, &result);
163     return result;
164 }
165 
MultimediaCoreAVFormatCopyTwo(napi_env env,napi_callback_info)166 static napi_value MultimediaCoreAVFormatCopyTwo(napi_env env, napi_callback_info)
167 {
168     struct OH_AVFormat *NewAVFormat = nullptr;
169     bool ReturnValue = OH_AVFormat_Copy(nullptr, NewAVFormat);
170     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_Copy failed");
171     napi_value result = nullptr;
172     napi_create_int32(env, SUCCESS, &result);
173     return result;
174 }
175 
MultimediaCoreAVFormatCopyThree(napi_env env,napi_callback_info)176 static napi_value MultimediaCoreAVFormatCopyThree(napi_env env, napi_callback_info)
177 {
178     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_AVC, PARAM_400, PARAM_500);
179     bool ReturnValue = OH_AVFormat_Copy(AVFormat, nullptr);
180     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_Copy failed");
181     napi_value result = nullptr;
182     napi_create_int32(env, SUCCESS, &result);
183     return result;
184 }
185 
MultimediaCoreAVFormatDestroy(napi_env env,napi_callback_info)186 static napi_value MultimediaCoreAVFormatDestroy(napi_env env, napi_callback_info)
187 {
188     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_AVC, PARAM_400, PARAM_500);
189     struct OH_AVFormat *NewAVFormat = nullptr;
190     OH_AVFormat_Destroy(AVFormat);
191     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
192     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_Destroy failed");
193     napi_value result = nullptr;
194     napi_create_int32(env, SUCCESS, &result);
195     return result;
196 }
197 
MultimediaCoreAVFormatDumpInfoOne(napi_env env,napi_callback_info)198 static napi_value MultimediaCoreAVFormatDumpInfoOne(napi_env env, napi_callback_info)
199 {
200     struct OH_AVFormat *AVFormat = OH_AVFormat_Create();
201     OH_AVFormat_SetStringValue(AVFormat, OH_MD_KEY_TITLE, "aaa");
202     const char *ReturnValue = OH_AVFormat_DumpInfo(AVFormat);
203     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_DumpInfo failed");
204     OH_AVFormat_Destroy(AVFormat);
205     napi_value result = nullptr;
206     napi_create_int32(env, SUCCESS, &result);
207     return result;
208 }
209 
MultimediaCoreAVFormatDumpInfoTwo(napi_env env,napi_callback_info)210 static napi_value MultimediaCoreAVFormatDumpInfoTwo(napi_env env, napi_callback_info)
211 {
212     const char *ReturnValue = OH_AVFormat_DumpInfo(nullptr);
213     NAPI_ASSERT(env, ReturnValue == nullptr, "OH_AVFormat_DumpInfo failed");
214     napi_value result = nullptr;
215     napi_create_int32(env, SUCCESS, &result);
216     return result;
217 }
218 
MultimediaCoreAVFormatGetBufferOne(napi_env env,napi_callback_info)219 static napi_value MultimediaCoreAVFormatGetBufferOne(napi_env env, napi_callback_info)
220 {
221     OH_AVFormat *AVFormat = OH_AVFormat_Create();
222     int32_t buffernum = PARAM_10;
223     size_t sizeIn = buffernum * sizeof(uint8_t);
224     uint8_t *buffer = reinterpret_cast<uint8_t *>(malloc(sizeIn));
225     OH_AVFormat_SetBuffer(AVFormat, bufferKey, buffer, sizeIn);
226     uint8_t *addrout = nullptr;
227     size_t sizeOut = PARAM_0;
228     bool ReturnValue = OH_AVFormat_GetBuffer(AVFormat, bufferKey, &addrout, &sizeOut);
229     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_GetBuffer failed");
230     OH_AVFormat_Destroy(AVFormat);
231     free(buffer);
232     napi_value result = nullptr;
233     napi_create_int32(env, SUCCESS, &result);
234     return result;
235 }
236 
MultimediaCoreAVFormatGetBufferTwo(napi_env env,napi_callback_info)237 static napi_value MultimediaCoreAVFormatGetBufferTwo(napi_env env, napi_callback_info)
238 {
239     OH_AVFormat *AVFormat = OH_AVFormat_Create();
240     int32_t buffernum = PARAM_10;
241     size_t sizeIn = buffernum * sizeof(uint8_t);
242     uint8_t *buffer = reinterpret_cast<uint8_t *>(malloc(sizeIn));
243     OH_AVFormat_SetBuffer(AVFormat, bufferKey, buffer, sizeIn);
244     uint8_t *addrout = nullptr;
245     size_t sizeOut = PARAM_0;
246     bool ReturnValue = OH_AVFormat_GetBuffer(nullptr, bufferKey, &addrout, &sizeOut);
247     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetBuffer failed");
248     OH_AVFormat_Destroy(AVFormat);
249     free(buffer);
250     napi_value result = nullptr;
251     napi_create_int32(env, SUCCESS, &result);
252     return result;
253 }
254 
MultimediaCoreAVFormatGetBufferThree(napi_env env,napi_callback_info)255 static napi_value MultimediaCoreAVFormatGetBufferThree(napi_env env, napi_callback_info)
256 {
257     OH_AVFormat *AVFormat = OH_AVFormat_Create();
258     int32_t buffernum = PARAM_10;
259     size_t sizeIn = buffernum * sizeof(uint8_t);
260     uint8_t *buffer = reinterpret_cast<uint8_t *>(malloc(sizeIn));
261     OH_AVFormat_SetBuffer(AVFormat, bufferKey, buffer, sizeIn);
262     uint8_t *addrout = nullptr;
263     size_t sizeOut = PARAM_0;
264     bool ReturnValue = OH_AVFormat_GetBuffer(AVFormat, nullptr, &addrout, &sizeOut);
265     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetBuffer failed");
266     OH_AVFormat_Destroy(AVFormat);
267     free(buffer);
268     napi_value result = nullptr;
269     napi_create_int32(env, SUCCESS, &result);
270     return result;
271 }
272 
MultimediaCoreAVFormatGetBufferFour(napi_env env,napi_callback_info)273 static napi_value MultimediaCoreAVFormatGetBufferFour(napi_env env, napi_callback_info)
274 {
275     OH_AVFormat *AVFormat = OH_AVFormat_Create();
276     int32_t buffernum = PARAM_10;
277     size_t sizeIn = buffernum * sizeof(uint8_t);
278     uint8_t *buffer = reinterpret_cast<uint8_t *>(malloc(sizeIn));
279     OH_AVFormat_SetBuffer(AVFormat, bufferKey, buffer, sizeIn);
280     size_t sizeOut = PARAM_0;
281     bool ReturnValue = OH_AVFormat_GetBuffer(AVFormat, bufferKey, nullptr, &sizeOut);
282     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetBuffer failed");
283     OH_AVFormat_Destroy(AVFormat);
284     free(buffer);
285     napi_value result = nullptr;
286     napi_create_int32(env, SUCCESS, &result);
287     return result;
288 }
289 
MultimediaCoreAVFormatGetBufferFive(napi_env env,napi_callback_info)290 static napi_value MultimediaCoreAVFormatGetBufferFive(napi_env env, napi_callback_info)
291 {
292     OH_AVFormat *AVFormat = OH_AVFormat_Create();
293     int32_t buffernum = PARAM_10;
294     size_t sizeIn = buffernum * sizeof(uint8_t);
295     uint8_t *buffer = reinterpret_cast<uint8_t *>(malloc(sizeIn));
296     OH_AVFormat_SetBuffer(AVFormat, bufferKey, buffer, sizeIn);
297     uint8_t *addrout = nullptr;
298     bool ReturnValue = OH_AVFormat_GetBuffer(AVFormat, bufferKey, &addrout, nullptr);
299     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetBuffer failed");
300     OH_AVFormat_Destroy(AVFormat);
301     free(buffer);
302     napi_value result = nullptr;
303     napi_create_int32(env, SUCCESS, &result);
304     return result;
305 }
306 
MultimediaCoreAVFormatGetDoubleValueOne(napi_env env,napi_callback_info)307 static napi_value MultimediaCoreAVFormatGetDoubleValueOne(napi_env env, napi_callback_info)
308 {
309     OH_AVFormat *AVFormat = OH_AVFormat_Create();
310     OH_AVFormat_SetDoubleValue(AVFormat, doubleKey, doubleValue);
311     double doubleValueOut = PARAM_0;
312     bool ReturnValue = OH_AVFormat_GetDoubleValue(AVFormat, doubleKey, &doubleValueOut);
313     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_GetDoubleValue failed");
314     OH_AVFormat_Destroy(AVFormat);
315     napi_value result = nullptr;
316     napi_create_int32(env, SUCCESS, &result);
317     return result;
318 }
319 
MultimediaCoreAVFormatGetDoubleValueTwo(napi_env env,napi_callback_info)320 static napi_value MultimediaCoreAVFormatGetDoubleValueTwo(napi_env env, napi_callback_info)
321 {
322     OH_AVFormat *AVFormat = OH_AVFormat_Create();
323     double doubleValueOut = PARAM_0;
324     bool ReturnValue = OH_AVFormat_GetDoubleValue(AVFormat, doubleKey, &doubleValueOut);
325     OH_AVFormat_Destroy(AVFormat);
326     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetDoubleValue failed");
327     napi_value result = nullptr;
328     napi_create_int32(env, SUCCESS, &result);
329     return result;
330 }
331 
MultimediaCoreAVFormatGetDoubleValueThree(napi_env env,napi_callback_info)332 static napi_value MultimediaCoreAVFormatGetDoubleValueThree(napi_env env, napi_callback_info)
333 {
334     OH_AVFormat *AVFormat = OH_AVFormat_Create();
335     OH_AVFormat_SetDoubleValue(AVFormat, doubleKey, doubleValue);
336     double doubleValueOut = PARAM_0;
337     bool ReturnValue = OH_AVFormat_GetDoubleValue(AVFormat, nullptr, &doubleValueOut);
338     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetDoubleValue failed");
339     OH_AVFormat_Destroy(AVFormat);
340     napi_value result = nullptr;
341     napi_create_int32(env, SUCCESS, &result);
342     return result;
343 }
344 
MultimediaCoreAVFormatGetDoubleValueFour(napi_env env,napi_callback_info)345 static napi_value MultimediaCoreAVFormatGetDoubleValueFour(napi_env env, napi_callback_info)
346 {
347     OH_AVFormat *AVFormat = OH_AVFormat_Create();
348     OH_AVFormat_SetDoubleValue(AVFormat, doubleKey, doubleValue);
349     bool ReturnValue = OH_AVFormat_GetDoubleValue(AVFormat, doubleKey, nullptr);
350     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetDoubleValue failed");
351     OH_AVFormat_Destroy(AVFormat);
352     napi_value result = nullptr;
353     napi_create_int32(env, SUCCESS, &result);
354     return result;
355 }
356 
MultimediaCoreAVFormatGetDoubleValueFive(napi_env env,napi_callback_info)357 static napi_value MultimediaCoreAVFormatGetDoubleValueFive(napi_env env, napi_callback_info)
358 {
359     OH_AVFormat *AVFormat = OH_AVFormat_Create();
360     OH_AVFormat_SetDoubleValue(AVFormat, doubleKey, doubleValue);
361     double doubleValueOut = PARAM_0;
362     bool ReturnValue = OH_AVFormat_GetDoubleValue(nullptr, doubleKey, &doubleValueOut);
363     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetDoubleValue failed");
364     OH_AVFormat_Destroy(AVFormat);
365     napi_value result = nullptr;
366     napi_create_int32(env, SUCCESS, &result);
367     return result;
368 }
369 
MultimediaCoreAVFormatGetFloatValueOne(napi_env env,napi_callback_info)370 static napi_value MultimediaCoreAVFormatGetFloatValueOne(napi_env env, napi_callback_info)
371 {
372     OH_AVFormat *AVFormat = OH_AVFormat_Create();
373     OH_AVFormat_SetFloatValue(AVFormat, floatKey, floatValue);
374     float floatValueOut = PARAM_0;
375     bool ReturnValue = OH_AVFormat_GetFloatValue(AVFormat, floatKey, &floatValueOut);
376     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_GetFloatValue failed");
377     OH_AVFormat_Destroy(AVFormat);
378     napi_value result = nullptr;
379     napi_create_int32(env, SUCCESS, &result);
380     return result;
381 }
382 
MultimediaCoreAVFormatGetFloatValueTwo(napi_env env,napi_callback_info)383 static napi_value MultimediaCoreAVFormatGetFloatValueTwo(napi_env env, napi_callback_info)
384 {
385     OH_AVFormat *AVFormat = OH_AVFormat_Create();
386     float floatValueOut = PARAM_0;
387     bool ReturnValue = OH_AVFormat_GetFloatValue(AVFormat, floatKey, &floatValueOut);
388     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetFloatValue failed");
389     OH_AVFormat_Destroy(AVFormat);
390     napi_value result = nullptr;
391     napi_create_int32(env, SUCCESS, &result);
392     return result;
393 }
394 
MultimediaCoreAVFormatGetFloatValueThree(napi_env env,napi_callback_info)395 static napi_value MultimediaCoreAVFormatGetFloatValueThree(napi_env env, napi_callback_info)
396 {
397     OH_AVFormat *AVFormat = OH_AVFormat_Create();
398     OH_AVFormat_SetFloatValue(AVFormat, floatKey, floatValue);
399     float floatValueOut = PARAM_0;
400     bool ReturnValue = OH_AVFormat_GetFloatValue(nullptr, floatKey, &floatValueOut);
401     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetFloatValue failed");
402     OH_AVFormat_Destroy(AVFormat);
403     napi_value result = nullptr;
404     napi_create_int32(env, SUCCESS, &result);
405     return result;
406 }
407 
MultimediaCoreAVFormatGetFloatValueFour(napi_env env,napi_callback_info)408 static napi_value MultimediaCoreAVFormatGetFloatValueFour(napi_env env, napi_callback_info)
409 {
410     OH_AVFormat *AVFormat = OH_AVFormat_Create();
411     OH_AVFormat_SetFloatValue(AVFormat, floatKey, floatValue);
412     float floatValueOut = PARAM_0;
413     bool ReturnValue = OH_AVFormat_GetFloatValue(AVFormat, nullptr, &floatValueOut);
414     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetFloatValue failed");
415     OH_AVFormat_Destroy(AVFormat);
416     napi_value result = nullptr;
417     napi_create_int32(env, SUCCESS, &result);
418     return result;
419 }
420 
MultimediaCoreAVFormatGetFloatValueFive(napi_env env,napi_callback_info)421 static napi_value MultimediaCoreAVFormatGetFloatValueFive(napi_env env, napi_callback_info)
422 {
423     OH_AVFormat *AVFormat = OH_AVFormat_Create();
424     OH_AVFormat_SetFloatValue(AVFormat, floatKey, floatValue);
425     bool ReturnValue = OH_AVFormat_GetFloatValue(AVFormat, floatKey, nullptr);
426     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetFloatValue failed");
427     OH_AVFormat_Destroy(AVFormat);
428     napi_value result = nullptr;
429     napi_create_int32(env, SUCCESS, &result);
430     return result;
431 }
432 
MultimediaCoreAVFormatGetIntValueOne(napi_env env,napi_callback_info)433 static napi_value MultimediaCoreAVFormatGetIntValueOne(napi_env env, napi_callback_info)
434 {
435     OH_AVFormat *AVFormat = OH_AVFormat_Create();
436     OH_AVFormat_SetIntValue(AVFormat, intKey, intValue);
437     int intValueOut = PARAM_0;
438     bool ReturnValue = OH_AVFormat_GetIntValue(AVFormat, intKey, &intValueOut);
439     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_GetIntValue failed");
440     OH_AVFormat_Destroy(AVFormat);
441     napi_value result = nullptr;
442     napi_create_int32(env, SUCCESS, &result);
443     return result;
444 }
445 
MultimediaCoreAVFormatGetIntValueTwo(napi_env env,napi_callback_info)446 static napi_value MultimediaCoreAVFormatGetIntValueTwo(napi_env env, napi_callback_info)
447 {
448     OH_AVFormat *AVFormat = OH_AVFormat_Create();
449     int intValueOut = PARAM_0;
450     bool ReturnValue = OH_AVFormat_GetIntValue(AVFormat, intKey, &intValueOut);
451     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetIntValue failed");
452     OH_AVFormat_Destroy(AVFormat);
453     napi_value result = nullptr;
454     napi_create_int32(env, SUCCESS, &result);
455     return result;
456 }
457 
MultimediaCoreAVFormatGetIntValueThree(napi_env env,napi_callback_info)458 static napi_value MultimediaCoreAVFormatGetIntValueThree(napi_env env, napi_callback_info)
459 {
460     OH_AVFormat *AVFormat = OH_AVFormat_Create();
461     OH_AVFormat_SetIntValue(AVFormat, intKey, intValue);
462     int intValueOut = PARAM_0;
463     bool ReturnValue = OH_AVFormat_GetIntValue(nullptr, intKey, &intValueOut);
464     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetIntValue failed");
465     OH_AVFormat_Destroy(AVFormat);
466     napi_value result = nullptr;
467     napi_create_int32(env, SUCCESS, &result);
468     return result;
469 }
470 
MultimediaCoreAVFormatGetIntValueFour(napi_env env,napi_callback_info)471 static napi_value MultimediaCoreAVFormatGetIntValueFour(napi_env env, napi_callback_info)
472 {
473     OH_AVFormat *AVFormat = OH_AVFormat_Create();
474     OH_AVFormat_SetIntValue(AVFormat, intKey, intValue);
475     int intValueOut = PARAM_0;
476     bool ReturnValue = OH_AVFormat_GetIntValue(AVFormat, nullptr, &intValueOut);
477     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetIntValue failed");
478     OH_AVFormat_Destroy(AVFormat);
479     napi_value result = nullptr;
480     napi_create_int32(env, SUCCESS, &result);
481     return result;
482 }
483 
MultimediaCoreAVFormatGetIntValueFive(napi_env env,napi_callback_info)484 static napi_value MultimediaCoreAVFormatGetIntValueFive(napi_env env, napi_callback_info)
485 {
486     OH_AVFormat *AVFormat = OH_AVFormat_Create();
487     OH_AVFormat_SetIntValue(AVFormat, intKey, intValue);
488     bool ReturnValue = OH_AVFormat_GetIntValue(AVFormat, intKey, nullptr);
489     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetIntValue failed");
490     OH_AVFormat_Destroy(AVFormat);
491     napi_value result = nullptr;
492     napi_create_int32(env, SUCCESS, &result);
493     return result;
494 }
495 
MultimediaCoreAVFormatGetLongValueOne(napi_env env,napi_callback_info)496 static napi_value MultimediaCoreAVFormatGetLongValueOne(napi_env env, napi_callback_info)
497 {
498     OH_AVFormat *AVFormat = OH_AVFormat_Create();
499     OH_AVFormat_SetLongValue(AVFormat, longKey, longValue);
500     int64_t longValueOut = PARAM_0;
501     bool ReturnValue = OH_AVFormat_GetLongValue(AVFormat, longKey, &longValueOut);
502     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_GetLongValue failed");
503     OH_AVFormat_Destroy(AVFormat);
504     napi_value result = nullptr;
505     napi_create_int32(env, SUCCESS, &result);
506     return result;
507 }
508 
MultimediaCoreAVFormatGetLongValueTwo(napi_env env,napi_callback_info)509 static napi_value MultimediaCoreAVFormatGetLongValueTwo(napi_env env, napi_callback_info)
510 {
511     OH_AVFormat *AVFormat = OH_AVFormat_Create();
512     int64_t longValueOut = PARAM_0;
513     bool ReturnValue = OH_AVFormat_GetLongValue(AVFormat, longKey, &longValueOut);
514     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetLongValue failed");
515     OH_AVFormat_Destroy(AVFormat);
516     napi_value result = nullptr;
517     napi_create_int32(env, SUCCESS, &result);
518     return result;
519 }
520 
MultimediaCoreAVFormatGetLongValueThree(napi_env env,napi_callback_info)521 static napi_value MultimediaCoreAVFormatGetLongValueThree(napi_env env, napi_callback_info)
522 {
523     OH_AVFormat *AVFormat = OH_AVFormat_Create();
524     OH_AVFormat_SetLongValue(AVFormat, longKey, longValue);
525     int64_t longValueOut = PARAM_0;
526     bool ReturnValue = OH_AVFormat_GetLongValue(nullptr, longKey, &longValueOut);
527     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetLongValue failed");
528     OH_AVFormat_Destroy(AVFormat);
529     napi_value result = nullptr;
530     napi_create_int32(env, SUCCESS, &result);
531     return result;
532 }
533 
MultimediaCoreAVFormatGetLongValueFour(napi_env env,napi_callback_info)534 static napi_value MultimediaCoreAVFormatGetLongValueFour(napi_env env, napi_callback_info)
535 {
536     OH_AVFormat *AVFormat = OH_AVFormat_Create();
537     OH_AVFormat_SetLongValue(AVFormat, longKey, longValue);
538     int64_t longValueOut = PARAM_0;
539     bool ReturnValue = OH_AVFormat_GetLongValue(AVFormat, nullptr, &longValueOut);
540     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetLongValue failed");
541     OH_AVFormat_Destroy(AVFormat);
542     napi_value result = nullptr;
543     napi_create_int32(env, SUCCESS, &result);
544     return result;
545 }
546 
MultimediaCoreAVFormatGetLongValueFive(napi_env env,napi_callback_info)547 static napi_value MultimediaCoreAVFormatGetLongValueFive(napi_env env, napi_callback_info)
548 {
549     OH_AVFormat *AVFormat = OH_AVFormat_Create();
550     OH_AVFormat_SetLongValue(AVFormat, longKey, longValue);
551     bool ReturnValue = OH_AVFormat_GetLongValue(AVFormat, longKey, nullptr);
552     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetLongValue failed");
553     OH_AVFormat_Destroy(AVFormat);
554     napi_value result = nullptr;
555     napi_create_int32(env, SUCCESS, &result);
556     return result;
557 }
558 
MultimediaCoreAVFormatGetStringValueOne(napi_env env,napi_callback_info)559 static napi_value MultimediaCoreAVFormatGetStringValueOne(napi_env env, napi_callback_info)
560 {
561     OH_AVFormat *AVFormat = OH_AVFormat_Create();
562     OH_AVFormat_SetStringValue(AVFormat, stringKey, stringValue);
563     const char *stringValueOut = nullptr;
564     bool ReturnValue = OH_AVFormat_GetStringValue(AVFormat, stringKey, &stringValueOut);
565     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_GetStringValue failed");
566     OH_AVFormat_Destroy(AVFormat);
567     napi_value result = nullptr;
568     napi_create_int32(env, SUCCESS, &result);
569     return result;
570 }
571 
MultimediaCoreAVFormatGetStringValueTwo(napi_env env,napi_callback_info)572 static napi_value MultimediaCoreAVFormatGetStringValueTwo(napi_env env, napi_callback_info)
573 {
574     OH_AVFormat *AVFormat = OH_AVFormat_Create();
575     const char *stringValueOut = nullptr;
576     bool ReturnValue = OH_AVFormat_GetStringValue(AVFormat, stringKey, &stringValueOut);
577     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetStringValue failed");
578     OH_AVFormat_Destroy(AVFormat);
579     napi_value result = nullptr;
580     napi_create_int32(env, SUCCESS, &result);
581     return result;
582 }
583 
MultimediaCoreAVFormatGetStringValueThree(napi_env env,napi_callback_info)584 static napi_value MultimediaCoreAVFormatGetStringValueThree(napi_env env, napi_callback_info)
585 {
586     OH_AVFormat *AVFormat = OH_AVFormat_Create();
587     OH_AVFormat_SetStringValue(AVFormat, stringKey, stringValue);
588     const char *stringValueOut = nullptr;
589     bool ReturnValue = OH_AVFormat_GetStringValue(nullptr, stringKey, &stringValueOut);
590     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetStringValue failed");
591     OH_AVFormat_Destroy(AVFormat);
592     napi_value result = nullptr;
593     napi_create_int32(env, SUCCESS, &result);
594     return result;
595 }
596 
MultimediaCoreAVFormatGetStringValueFour(napi_env env,napi_callback_info)597 static napi_value MultimediaCoreAVFormatGetStringValueFour(napi_env env, napi_callback_info)
598 {
599     OH_AVFormat *AVFormat = OH_AVFormat_Create();
600     OH_AVFormat_SetStringValue(AVFormat, stringKey, stringValue);
601     const char *stringValueOut = nullptr;
602     bool ReturnValue = OH_AVFormat_GetStringValue(AVFormat, nullptr, &stringValueOut);
603     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetStringValue failed");
604     OH_AVFormat_Destroy(AVFormat);
605     napi_value result = nullptr;
606     napi_create_int32(env, SUCCESS, &result);
607     return result;
608 }
609 
MultimediaCoreAVFormatGetStringValueFive(napi_env env,napi_callback_info)610 static napi_value MultimediaCoreAVFormatGetStringValueFive(napi_env env, napi_callback_info)
611 {
612     OH_AVFormat *AVFormat = OH_AVFormat_Create();
613     OH_AVFormat_SetStringValue(AVFormat, stringKey, stringValue);
614     bool ReturnValue = OH_AVFormat_GetStringValue(AVFormat, stringKey, nullptr);
615     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_GetStringValue failed");
616     OH_AVFormat_Destroy(AVFormat);
617     napi_value result = nullptr;
618     napi_create_int32(env, SUCCESS, &result);
619     return result;
620 }
621 
MultimediaCoreAVFormatSetBufferOne(napi_env env,napi_callback_info)622 static napi_value MultimediaCoreAVFormatSetBufferOne(napi_env env, napi_callback_info)
623 {
624     OH_AVFormat *AVFormat = OH_AVFormat_Create();
625     int32_t buffernum = PARAM_10;
626     size_t sizeIn = buffernum * sizeof(uint8_t);
627     uint8_t *buffer = reinterpret_cast<uint8_t *>(malloc(sizeIn));
628     bool ReturnValue = OH_AVFormat_SetBuffer(AVFormat, bufferKey, buffer, sizeIn);
629     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_SetBuffer failed");
630     OH_AVFormat_Destroy(AVFormat);
631     free(buffer);
632     napi_value result = nullptr;
633     napi_create_int32(env, SUCCESS, &result);
634     return result;
635 }
636 
MultimediaCoreAVFormatSetBufferTwo(napi_env env,napi_callback_info)637 static napi_value MultimediaCoreAVFormatSetBufferTwo(napi_env env, napi_callback_info)
638 {
639     OH_AVFormat *AVFormat = OH_AVFormat_Create();
640     int32_t buffernum = PARAM_10;
641     size_t sizeIn = buffernum * sizeof(uint8_t);
642     uint8_t *buffer = reinterpret_cast<uint8_t *>(malloc(sizeIn));
643     bool ReturnValue = OH_AVFormat_SetBuffer(nullptr, bufferKey, buffer, sizeIn);
644     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetBuffer failed");
645     OH_AVFormat_Destroy(AVFormat);
646     free(buffer);
647     napi_value result = nullptr;
648     napi_create_int32(env, SUCCESS, &result);
649     return result;
650 }
651 
MultimediaCoreAVFormatSetBufferThree(napi_env env,napi_callback_info)652 static napi_value MultimediaCoreAVFormatSetBufferThree(napi_env env, napi_callback_info)
653 {
654     OH_AVFormat *AVFormat = OH_AVFormat_Create();
655     int32_t buffernum = PARAM_10;
656     size_t sizeIn = buffernum * sizeof(uint8_t);
657     uint8_t *buffer = reinterpret_cast<uint8_t *>(malloc(sizeIn));
658     bool ReturnValue = OH_AVFormat_SetBuffer(AVFormat, nullptr, buffer, sizeIn);
659     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetBuffer failed");
660     OH_AVFormat_Destroy(AVFormat);
661     free(buffer);
662     napi_value result = nullptr;
663     napi_create_int32(env, SUCCESS, &result);
664     return result;
665 }
666 
MultimediaCoreAVFormatSetBufferFour(napi_env env,napi_callback_info)667 static napi_value MultimediaCoreAVFormatSetBufferFour(napi_env env, napi_callback_info)
668 {
669     OH_AVFormat *AVFormat = OH_AVFormat_Create();
670     int32_t buffernum = PARAM_10;
671     size_t sizeIn = buffernum * sizeof(uint8_t);
672     bool ReturnValue = OH_AVFormat_SetBuffer(AVFormat, bufferKey, nullptr, sizeIn);
673     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetBuffer failed");
674     OH_AVFormat_Destroy(AVFormat);
675     napi_value result = nullptr;
676     napi_create_int32(env, SUCCESS, &result);
677     return result;
678 }
679 
MultimediaCoreAVFormatSetDoubleValueOne(napi_env env,napi_callback_info)680 static napi_value MultimediaCoreAVFormatSetDoubleValueOne(napi_env env, napi_callback_info)
681 {
682     OH_AVFormat *AVFormat = OH_AVFormat_Create();
683     bool ReturnValue = OH_AVFormat_SetDoubleValue(AVFormat, doubleKey, doubleValue);
684     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_SetDoubleValue failed");
685     OH_AVFormat_Destroy(AVFormat);
686     napi_value result = nullptr;
687     napi_create_int32(env, SUCCESS, &result);
688     return result;
689 }
690 
MultimediaCoreAVFormatSetDoubleValueTwo(napi_env env,napi_callback_info)691 static napi_value MultimediaCoreAVFormatSetDoubleValueTwo(napi_env env, napi_callback_info)
692 {
693     OH_AVFormat *AVFormat = OH_AVFormat_Create();
694     bool ReturnValue = OH_AVFormat_SetDoubleValue(nullptr, doubleKey, doubleValue);
695     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetDoubleValue failed");
696     OH_AVFormat_Destroy(AVFormat);
697     napi_value result = nullptr;
698     napi_create_int32(env, SUCCESS, &result);
699     return result;
700 }
701 
MultimediaCoreAVFormatSetDoubleValueThree(napi_env env,napi_callback_info)702 static napi_value MultimediaCoreAVFormatSetDoubleValueThree(napi_env env, napi_callback_info)
703 {
704     OH_AVFormat *AVFormat = OH_AVFormat_Create();
705     bool ReturnValue = OH_AVFormat_SetDoubleValue(AVFormat, nullptr, doubleValue);
706     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetDoubleValue failed");
707     OH_AVFormat_Destroy(AVFormat);
708     napi_value result = nullptr;
709     napi_create_int32(env, SUCCESS, &result);
710     return result;
711 }
712 
MultimediaCoreAVFormatSetFloatValueOne(napi_env env,napi_callback_info)713 static napi_value MultimediaCoreAVFormatSetFloatValueOne(napi_env env, napi_callback_info)
714 {
715     OH_AVFormat *AVFormat = OH_AVFormat_Create();
716     bool ReturnValue = OH_AVFormat_SetFloatValue(AVFormat, floatKey, floatValue);
717     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_SetFloatValue failed");
718     OH_AVFormat_Destroy(AVFormat);
719     napi_value result = nullptr;
720     napi_create_int32(env, SUCCESS, &result);
721     return result;
722 }
723 
MultimediaCoreAVFormatSetFloatValueTwo(napi_env env,napi_callback_info)724 static napi_value MultimediaCoreAVFormatSetFloatValueTwo(napi_env env, napi_callback_info)
725 {
726     OH_AVFormat *AVFormat = OH_AVFormat_Create();
727     bool ReturnValue = OH_AVFormat_SetFloatValue(nullptr, floatKey, floatValue);
728     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetFloatValue failed");
729     OH_AVFormat_Destroy(AVFormat);
730     napi_value result = nullptr;
731     napi_create_int32(env, SUCCESS, &result);
732     return result;
733 }
734 
MultimediaCoreAVFormatSetFloatValueThree(napi_env env,napi_callback_info)735 static napi_value MultimediaCoreAVFormatSetFloatValueThree(napi_env env, napi_callback_info)
736 {
737     OH_AVFormat *AVFormat = OH_AVFormat_Create();
738     bool ReturnValue = OH_AVFormat_SetFloatValue(AVFormat, nullptr, floatValue);
739     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetFloatValue failed");
740     OH_AVFormat_Destroy(AVFormat);
741     napi_value result = nullptr;
742     napi_create_int32(env, SUCCESS, &result);
743     return result;
744 }
745 
MultimediaCoreAVFormatSetIntValueOne(napi_env env,napi_callback_info)746 static napi_value MultimediaCoreAVFormatSetIntValueOne(napi_env env, napi_callback_info)
747 {
748     OH_AVFormat *AVFormat = OH_AVFormat_Create();
749     bool ReturnValue = OH_AVFormat_SetIntValue(AVFormat, intKey, intValue);
750     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_SetIntValue failed");
751     OH_AVFormat_Destroy(AVFormat);
752     napi_value result = nullptr;
753     napi_create_int32(env, SUCCESS, &result);
754     return result;
755 }
756 
MultimediaCoreAVFormatSetIntValueTwo(napi_env env,napi_callback_info)757 static napi_value MultimediaCoreAVFormatSetIntValueTwo(napi_env env, napi_callback_info)
758 {
759     OH_AVFormat *AVFormat = OH_AVFormat_Create();
760     bool ReturnValue = OH_AVFormat_SetIntValue(nullptr, intKey, intValue);
761     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetIntValue failed");
762     OH_AVFormat_Destroy(AVFormat);
763     napi_value result = nullptr;
764     napi_create_int32(env, SUCCESS, &result);
765     return result;
766 }
767 
MultimediaCoreAVFormatSetIntValueThree(napi_env env,napi_callback_info)768 static napi_value MultimediaCoreAVFormatSetIntValueThree(napi_env env, napi_callback_info)
769 {
770     OH_AVFormat *AVFormat = OH_AVFormat_Create();
771     bool ReturnValue = OH_AVFormat_SetIntValue(AVFormat, nullptr, intValue);
772     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetIntValue failed");
773     OH_AVFormat_Destroy(AVFormat);
774     napi_value result = nullptr;
775     napi_create_int32(env, SUCCESS, &result);
776     return result;
777 }
778 
MultimediaCoreAVFormatSetLongValueOne(napi_env env,napi_callback_info)779 static napi_value MultimediaCoreAVFormatSetLongValueOne(napi_env env, napi_callback_info)
780 {
781     OH_AVFormat *AVFormat = OH_AVFormat_Create();
782     bool ReturnValue = OH_AVFormat_SetLongValue(AVFormat, longKey, longValue);
783     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_SetLongValue failed");
784     OH_AVFormat_Destroy(AVFormat);
785     napi_value result = nullptr;
786     napi_create_int32(env, SUCCESS, &result);
787     return result;
788 }
789 
MultimediaCoreAVFormatSetLongValueTwo(napi_env env,napi_callback_info)790 static napi_value MultimediaCoreAVFormatSetLongValueTwo(napi_env env, napi_callback_info)
791 {
792     OH_AVFormat *AVFormat = OH_AVFormat_Create();
793     bool ReturnValue = OH_AVFormat_SetLongValue(nullptr, longKey, longValue);
794     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetLongValue failed");
795     OH_AVFormat_Destroy(AVFormat);
796     napi_value result = nullptr;
797     napi_create_int32(env, SUCCESS, &result);
798     return result;
799 }
800 
MultimediaCoreAVFormatSetLongValueThree(napi_env env,napi_callback_info)801 static napi_value MultimediaCoreAVFormatSetLongValueThree(napi_env env, napi_callback_info)
802 {
803     OH_AVFormat *AVFormat = OH_AVFormat_Create();
804     bool ReturnValue = OH_AVFormat_SetLongValue(AVFormat, nullptr, longValue);
805     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetLongValue failed");
806     OH_AVFormat_Destroy(AVFormat);
807     napi_value result = nullptr;
808     napi_create_int32(env, SUCCESS, &result);
809     return result;
810 }
811 
MultimediaCoreAVFormatSetStringValueOne(napi_env env,napi_callback_info)812 static napi_value MultimediaCoreAVFormatSetStringValueOne(napi_env env, napi_callback_info)
813 {
814     OH_AVFormat *AVFormat = OH_AVFormat_Create();
815     bool ReturnValue = OH_AVFormat_SetStringValue(AVFormat, stringKey, stringValue);
816     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_SetStringValue failed");
817     OH_AVFormat_Destroy(AVFormat);
818     napi_value result = nullptr;
819     napi_create_int32(env, SUCCESS, &result);
820     return result;
821 }
822 
MultimediaCoreAVFormatSetStringValueTwo(napi_env env,napi_callback_info)823 static napi_value MultimediaCoreAVFormatSetStringValueTwo(napi_env env, napi_callback_info)
824 {
825     OH_AVFormat *AVFormat = OH_AVFormat_Create();
826     bool ReturnValue = OH_AVFormat_SetStringValue(nullptr, stringKey, stringValue);
827     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetStringValue failed");
828     OH_AVFormat_Destroy(AVFormat);
829     napi_value result = nullptr;
830     napi_create_int32(env, SUCCESS, &result);
831     return result;
832 }
833 
MultimediaCoreAVFormatSetStringValueThree(napi_env env,napi_callback_info)834 static napi_value MultimediaCoreAVFormatSetStringValueThree(napi_env env, napi_callback_info)
835 {
836     OH_AVFormat *AVFormat = OH_AVFormat_Create();
837     bool ReturnValue = OH_AVFormat_SetStringValue(AVFormat, nullptr, stringValue);
838     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetStringValue failed");
839     OH_AVFormat_Destroy(AVFormat);
840     napi_value result = nullptr;
841     napi_create_int32(env, SUCCESS, &result);
842     return result;
843 }
844 
MultimediaCoreAVFormatSetStringValueFour(napi_env env,napi_callback_info)845 static napi_value MultimediaCoreAVFormatSetStringValueFour(napi_env env, napi_callback_info)
846 {
847     OH_AVFormat *AVFormat = OH_AVFormat_Create();
848     bool ReturnValue = OH_AVFormat_SetStringValue(AVFormat, stringKey, nullptr);
849     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetStringValue failed");
850     OH_AVFormat_Destroy(AVFormat);
851     napi_value result = nullptr;
852     napi_create_int32(env, SUCCESS, &result);
853     return result;
854 }
855 
MultimediaCoreAVMemoryCreateOne(napi_env env,napi_callback_info)856 static napi_value MultimediaCoreAVMemoryCreateOne(napi_env env, napi_callback_info)
857 {
858     OH_AVMemory *avMemBuffer = OH_AVMemory_Create(INFO_SIZE);
859     NAPI_ASSERT(env, avMemBuffer != nullptr, "OH_AVMemory_Create failed");
860     OH_AVMemory_Destroy(avMemBuffer);
861     napi_value result = nullptr;
862     napi_create_int32(env, SUCCESS, &result);
863     return result;
864 }
865 
MultimediaCoreAVMemoryCreateTwo(napi_env env,napi_callback_info)866 static napi_value MultimediaCoreAVMemoryCreateTwo(napi_env env, napi_callback_info)
867 {
868     OH_AVMemory *avMemBuffer = OH_AVMemory_Create(FPARAM_1);
869     NAPI_ASSERT(env, avMemBuffer == nullptr, "OH_AVMemory_Create failed");
870     napi_value result = nullptr;
871     napi_create_int32(env, SUCCESS, &result);
872     return result;
873 }
874 
MultimediaCoreAVMemoryDestroyOne(napi_env env,napi_callback_info)875 static napi_value MultimediaCoreAVMemoryDestroyOne(napi_env env, napi_callback_info)
876 {
877     OH_AVMemory *avMemBuffer = OH_AVMemory_Create(INFO_SIZE);
878     OH_AVErrCode ReturnValue = OH_AVMemory_Destroy(avMemBuffer);
879     NAPI_ASSERT(env, ReturnValue == AV_ERR_OK, "OH_AVMemory_Destroy failed");
880     napi_value result = nullptr;
881     napi_create_int32(env, SUCCESS, &result);
882     return result;
883 }
884 
MultimediaCoreAVMemoryDestroyTwo(napi_env env,napi_callback_info)885 static napi_value MultimediaCoreAVMemoryDestroyTwo(napi_env env, napi_callback_info)
886 {
887     OH_AVErrCode ReturnValue = OH_AVMemory_Destroy(nullptr);
888     NAPI_ASSERT(env, ReturnValue == AV_ERR_INVALID_VAL, "OH_AVMemory_Destroy failed");
889     napi_value result = nullptr;
890     napi_create_int32(env, SUCCESS, &result);
891     return result;
892 }
893 
MultimediaCoreAVMemoryGetAddrOne(napi_env env,napi_callback_info)894 static napi_value MultimediaCoreAVMemoryGetAddrOne(napi_env env, napi_callback_info)
895 {
896     OH_AVMemory *avMemBuffer = OH_AVMemory_Create(INFO_SIZE);
897     uint8_t *data = OH_AVMemory_GetAddr(avMemBuffer);
898     NAPI_ASSERT(env, data != nullptr, "OH_AVMemory_GetAddr failed");
899     OH_AVMemory_Destroy(avMemBuffer);
900     napi_value result = nullptr;
901     napi_create_int32(env, SUCCESS, &result);
902     return result;
903 }
904 
MultimediaCoreAVMemoryGetAddrTwo(napi_env env,napi_callback_info)905 static napi_value MultimediaCoreAVMemoryGetAddrTwo(napi_env env, napi_callback_info)
906 {
907     uint8_t *data = OH_AVMemory_GetAddr(nullptr);
908     NAPI_ASSERT(env, data == nullptr, "OH_AVMemory_GetAddr failed");
909     napi_value result = nullptr;
910     napi_create_int32(env, SUCCESS, &result);
911     return result;
912 }
913 
MultimediaCoreAVMemoryGetSizeOne(napi_env env,napi_callback_info)914 static napi_value MultimediaCoreAVMemoryGetSizeOne(napi_env env, napi_callback_info)
915 {
916     OH_AVMemory *avMemBuffer = OH_AVMemory_Create(INFO_SIZE);
917     int32_t data = OH_AVMemory_GetSize(avMemBuffer);
918     NAPI_ASSERT(env, data == INFO_SIZE, "OH_AVMemory_GetSize failed");
919     napi_value result = nullptr;
920     OH_AVMemory_Destroy(avMemBuffer);
921     napi_create_int32(env, SUCCESS, &result);
922     return result;
923 }
924 
MultimediaCoreAVMemoryGetSizeTwo(napi_env env,napi_callback_info)925 static napi_value MultimediaCoreAVMemoryGetSizeTwo(napi_env env, napi_callback_info)
926 {
927     int32_t data = OH_AVMemory_GetSize(nullptr);
928     NAPI_ASSERT(env, data == FPARAM_1, "OH_AVMemory_GetSize failed");
929     napi_value result = nullptr;
930     napi_create_int32(env, SUCCESS, &result);
931     return result;
932 }
933 
MultimediaCoreAVFormatCreateAudioFormatAVC(napi_env env,napi_callback_info)934 static napi_value MultimediaCoreAVFormatCreateAudioFormatAVC(napi_env env, napi_callback_info)
935 {
936     struct OH_AVFormat *ReturnValue = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_VIDEO_AVC,
937         PARAM_44100, PARAM_2);
938     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_CreateAudioFormat failed");
939     OH_AVFormat_Destroy(ReturnValue);
940     napi_value result = nullptr;
941     napi_create_int32(env, SUCCESS, &result);
942     return result;
943 }
944 
MultimediaCoreAVFormatCreateAudioFormatVORBIS(napi_env env,napi_callback_info)945 static napi_value MultimediaCoreAVFormatCreateAudioFormatVORBIS(napi_env env, napi_callback_info)
946 {
947     struct OH_AVFormat *ReturnValue = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_VORBIS,
948         PARAM_44100, PARAM_2);
949     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_CreateAudioFormat failed");
950     OH_AVFormat_Destroy(ReturnValue);
951     napi_value result = nullptr;
952     napi_create_int32(env, SUCCESS, &result);
953     return result;
954 }
955 
MultimediaCoreAVFormatCreateAudioFormatVORBISMPEG(napi_env env,napi_callback_info)956 static napi_value MultimediaCoreAVFormatCreateAudioFormatVORBISMPEG(napi_env env, napi_callback_info)
957 {
958     struct OH_AVFormat *ReturnValue = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_MPEG,
959         PARAM_44100, PARAM_2);
960     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_CreateAudioFormat failed");
961     OH_AVFormat_Destroy(ReturnValue);
962     napi_value result = nullptr;
963     napi_create_int32(env, SUCCESS, &result);
964     return result;
965 }
966 
MultimediaCoreAVFormatCreateVideoFormatHEVC(napi_env env,napi_callback_info)967 static napi_value MultimediaCoreAVFormatCreateVideoFormatHEVC(napi_env env, napi_callback_info)
968 {
969     struct OH_AVFormat *ReturnValue = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_HEVC,
970         PARAM_400, PARAM_500);
971     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_CreateVideoFormat failed");
972     OH_AVFormat_Destroy(ReturnValue);
973     napi_value result = nullptr;
974     napi_create_int32(env, SUCCESS, &result);
975     return result;
976 }
977 
MultimediaCoreAVFormatCreateVideoFormatMPEG4(napi_env env,napi_callback_info)978 static napi_value MultimediaCoreAVFormatCreateVideoFormatMPEG4(napi_env env, napi_callback_info)
979 {
980     struct OH_AVFormat *ReturnValue = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_MPEG4,
981         PARAM_400, PARAM_500);
982     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_CreateVideoFormat failed");
983     OH_AVFormat_Destroy(ReturnValue);
984     napi_value result = nullptr;
985     napi_create_int32(env, SUCCESS, &result);
986     return result;
987 }
988 
MultimediaCoreAVFormatDestroyVideoHEVC(napi_env env,napi_callback_info)989 static napi_value MultimediaCoreAVFormatDestroyVideoHEVC(napi_env env, napi_callback_info)
990 {
991     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_HEVC,
992         PARAM_400, PARAM_500);
993     struct OH_AVFormat *NewAVFormat = nullptr;
994     OH_AVFormat_Destroy(AVFormat);
995     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
996     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_Destroy failed");
997     napi_value result = nullptr;
998     napi_create_int32(env, SUCCESS, &result);
999     return result;
1000 }
1001 
MultimediaCoreAVFormatDestroyVideoMPEG4(napi_env env,napi_callback_info)1002 static napi_value MultimediaCoreAVFormatDestroyVideoMPEG4(napi_env env, napi_callback_info)
1003 {
1004     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_MPEG4,
1005         PARAM_400, PARAM_500);
1006     struct OH_AVFormat *NewAVFormat = nullptr;
1007     OH_AVFormat_Destroy(AVFormat);
1008     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
1009     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_Destroy failed");
1010     napi_value result = nullptr;
1011     napi_create_int32(env, SUCCESS, &result);
1012     return result;
1013 }
1014 
MultimediaCoreAVFormatDestroyAudioFLAC(napi_env env,napi_callback_info)1015 static napi_value MultimediaCoreAVFormatDestroyAudioFLAC(napi_env env, napi_callback_info)
1016 {
1017     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_FLAC, PARAM_44100, PARAM_2);
1018     struct OH_AVFormat *NewAVFormat = nullptr;
1019     OH_AVFormat_Destroy(AVFormat);
1020     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
1021     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_Destroy failed");
1022     napi_value result = nullptr;
1023     napi_create_int32(env, SUCCESS, &result);
1024     return result;
1025 }
1026 
MultimediaCoreAVFormatDestroyAudioAAC(napi_env env,napi_callback_info)1027 static napi_value MultimediaCoreAVFormatDestroyAudioAAC(napi_env env, napi_callback_info)
1028 {
1029     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_AAC, PARAM_44100, PARAM_2);
1030     struct OH_AVFormat *NewAVFormat = nullptr;
1031     OH_AVFormat_Destroy(AVFormat);
1032     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
1033     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_Destroy failed");
1034     napi_value result = nullptr;
1035     napi_create_int32(env, SUCCESS, &result);
1036     return result;
1037 }
1038 
MultimediaCoreAVFormatDestroyAudioVORBIS(napi_env env,napi_callback_info)1039 static napi_value MultimediaCoreAVFormatDestroyAudioVORBIS(napi_env env, napi_callback_info)
1040 {
1041     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_VORBIS,
1042         PARAM_44100, PARAM_2);
1043     struct OH_AVFormat *NewAVFormat = nullptr;
1044     OH_AVFormat_Destroy(AVFormat);
1045     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
1046     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_Destroy failed");
1047     napi_value result = nullptr;
1048     napi_create_int32(env, SUCCESS, &result);
1049     return result;
1050 }
1051 
MultimediaCoreAVFormatDestroyAudioMPEG(napi_env env,napi_callback_info)1052 static napi_value MultimediaCoreAVFormatDestroyAudioMPEG(napi_env env, napi_callback_info)
1053 {
1054     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_MPEG, PARAM_44100, PARAM_2);
1055     struct OH_AVFormat *NewAVFormat = nullptr;
1056     OH_AVFormat_Destroy(AVFormat);
1057     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
1058     NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_Destroy failed");
1059     napi_value result = nullptr;
1060     napi_create_int32(env, SUCCESS, &result);
1061     return result;
1062 }
1063 
MultimediaCoreAVFormatCopyVideoHEVC(napi_env env,napi_callback_info)1064 static napi_value MultimediaCoreAVFormatCopyVideoHEVC(napi_env env, napi_callback_info)
1065 {
1066     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_HEVC, PARAM_400, PARAM_500);
1067     OH_AVFormat *NewAVFormat = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_HEVC, PARAM_400, PARAM_500);
1068     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
1069     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_Copy failed");
1070     napi_value result = nullptr;
1071     napi_create_int32(env, SUCCESS, &result);
1072     return result;
1073 }
1074 
MultimediaCoreAVFormatCopyVideoMPEG4(napi_env env,napi_callback_info)1075 static napi_value MultimediaCoreAVFormatCopyVideoMPEG4(napi_env env, napi_callback_info)
1076 {
1077     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_MPEG4, PARAM_400, PARAM_500);
1078     OH_AVFormat *NewAVFormat = OH_AVFormat_CreateVideoFormat(OH_AVCODEC_MIMETYPE_VIDEO_MPEG4, PARAM_400, PARAM_500);
1079     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
1080     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_Copy failed");
1081     napi_value result = nullptr;
1082     napi_create_int32(env, SUCCESS, &result);
1083     return result;
1084 }
1085 
MultimediaCoreAVFormatCopyAudioAAC(napi_env env,napi_callback_info)1086 static napi_value MultimediaCoreAVFormatCopyAudioAAC(napi_env env, napi_callback_info)
1087 {
1088     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_AAC, PARAM_44100, PARAM_2);
1089     OH_AVFormat *NewAVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_AAC, PARAM_44100, PARAM_2);
1090     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
1091     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_Copy failed");
1092     napi_value result = nullptr;
1093     napi_create_int32(env, SUCCESS, &result);
1094     return result;
1095 }
1096 
MultimediaCoreAVFormatCopyAudioFLAC(napi_env env,napi_callback_info)1097 static napi_value MultimediaCoreAVFormatCopyAudioFLAC(napi_env env, napi_callback_info)
1098 {
1099     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_FLAC, PARAM_44100, PARAM_2);
1100     OH_AVFormat *NewAVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_FLAC, PARAM_44100, PARAM_2);
1101     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
1102     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_Copy failed");
1103     napi_value result = nullptr;
1104     napi_create_int32(env, SUCCESS, &result);
1105     return result;
1106 }
1107 
MultimediaCoreAVFormatCopyAudioVORBIS(napi_env env,napi_callback_info)1108 static napi_value MultimediaCoreAVFormatCopyAudioVORBIS(napi_env env, napi_callback_info)
1109 {
1110     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_VORBIS,
1111         PARAM_44100, PARAM_2);
1112     OH_AVFormat *NewAVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_VORBIS, PARAM_44100, PARAM_2);
1113     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
1114     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_Copy failed");
1115     napi_value result = nullptr;
1116     napi_create_int32(env, SUCCESS, &result);
1117     return result;
1118 }
1119 
MultimediaCoreAVFormatCopyAudioMPEG(napi_env env,napi_callback_info)1120 static napi_value MultimediaCoreAVFormatCopyAudioMPEG(napi_env env, napi_callback_info)
1121 {
1122     struct OH_AVFormat *AVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_MPEG, PARAM_44100, PARAM_2);
1123     OH_AVFormat *NewAVFormat = OH_AVFormat_CreateAudioFormat(OH_AVCODEC_MIMETYPE_AUDIO_MPEG, PARAM_44100, PARAM_2);
1124     bool ReturnValue = OH_AVFormat_Copy(AVFormat, NewAVFormat);
1125     NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_Copy failed");
1126     napi_value result = nullptr;
1127     napi_create_int32(env, SUCCESS, &result);
1128     return result;
1129 }
1130 
MultimediaCoreAVFormatDumpInfoARTIST(napi_env env,napi_callback_info)1131 static napi_value MultimediaCoreAVFormatDumpInfoARTIST(napi_env env, napi_callback_info)
1132 {
1133     struct OH_AVFormat *AVFormat = OH_AVFormat_Create();
1134     OH_AVFormat_SetStringValue(AVFormat, OH_MD_KEY_ARTIST, "aaa");
1135     const char *ReturnValue = OH_AVFormat_DumpInfo(AVFormat);
1136     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_DumpInfo failed");
1137     OH_AVFormat_Destroy(AVFormat);
1138     napi_value result = nullptr;
1139     napi_create_int32(env, SUCCESS, &result);
1140     return result;
1141 }
1142 
MultimediaCoreAVFormatDumpInfoALBUM(napi_env env,napi_callback_info)1143 static napi_value MultimediaCoreAVFormatDumpInfoALBUM(napi_env env, napi_callback_info)
1144 {
1145     struct OH_AVFormat *AVFormat = OH_AVFormat_Create();
1146     OH_AVFormat_SetStringValue(AVFormat, OH_MD_KEY_ALBUM, "aaa");
1147     const char *ReturnValue = OH_AVFormat_DumpInfo(AVFormat);
1148     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_DumpInfo failed");
1149     OH_AVFormat_Destroy(AVFormat);
1150     napi_value result = nullptr;
1151     napi_create_int32(env, SUCCESS, &result);
1152     return result;
1153 }
1154 
MultimediaCoreAVFormatDumpInfoALBUMARTIST(napi_env env,napi_callback_info)1155 static napi_value MultimediaCoreAVFormatDumpInfoALBUMARTIST(napi_env env, napi_callback_info)
1156 {
1157     struct OH_AVFormat *AVFormat = OH_AVFormat_Create();
1158     OH_AVFormat_SetStringValue(AVFormat, OH_MD_KEY_ALBUM_ARTIST, "aaa");
1159     const char *ReturnValue = OH_AVFormat_DumpInfo(AVFormat);
1160     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_DumpInfo failed");
1161     OH_AVFormat_Destroy(AVFormat);
1162     napi_value result = nullptr;
1163     napi_create_int32(env, SUCCESS, &result);
1164     return result;
1165 }
1166 
MultimediaCoreAVFormatDumpInfoDATE(napi_env env,napi_callback_info)1167 static napi_value MultimediaCoreAVFormatDumpInfoDATE(napi_env env, napi_callback_info)
1168 {
1169     struct OH_AVFormat *AVFormat = OH_AVFormat_Create();
1170     OH_AVFormat_SetStringValue(AVFormat, OH_MD_KEY_DATE, "aaa");
1171     const char *ReturnValue = OH_AVFormat_DumpInfo(AVFormat);
1172     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_DumpInfo failed");
1173     OH_AVFormat_Destroy(AVFormat);
1174     napi_value result = nullptr;
1175     napi_create_int32(env, SUCCESS, &result);
1176     return result;
1177 }
1178 
MultimediaCoreAVFormatDumpInfoCOMMENT(napi_env env,napi_callback_info)1179 static napi_value MultimediaCoreAVFormatDumpInfoCOMMENT(napi_env env, napi_callback_info)
1180 {
1181     struct OH_AVFormat *AVFormat = OH_AVFormat_Create();
1182     OH_AVFormat_SetStringValue(AVFormat, OH_MD_KEY_COMMENT, "aaa");
1183     const char *ReturnValue = OH_AVFormat_DumpInfo(AVFormat);
1184     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_DumpInfo failed");
1185     OH_AVFormat_Destroy(AVFormat);
1186     napi_value result = nullptr;
1187     napi_create_int32(env, SUCCESS, &result);
1188     return result;
1189 }
1190 
MultimediaCoreAVFormatDumpInfoGENRE(napi_env env,napi_callback_info)1191 static napi_value MultimediaCoreAVFormatDumpInfoGENRE(napi_env env, napi_callback_info)
1192 {
1193     struct OH_AVFormat *AVFormat = OH_AVFormat_Create();
1194     OH_AVFormat_SetStringValue(AVFormat, OH_MD_KEY_GENRE, "aaa");
1195     const char *ReturnValue = OH_AVFormat_DumpInfo(AVFormat);
1196     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_DumpInfo failed");
1197     OH_AVFormat_Destroy(AVFormat);
1198     napi_value result = nullptr;
1199     napi_create_int32(env, SUCCESS, &result);
1200     return result;
1201 }
1202 
MultimediaCoreAVFormatDumpInfoCOPYRIGHT(napi_env env,napi_callback_info)1203 static napi_value MultimediaCoreAVFormatDumpInfoCOPYRIGHT(napi_env env, napi_callback_info)
1204 {
1205     struct OH_AVFormat *AVFormat = OH_AVFormat_Create();
1206     OH_AVFormat_SetStringValue(AVFormat, OH_MD_KEY_COPYRIGHT, "aaa");
1207     const char *ReturnValue = OH_AVFormat_DumpInfo(AVFormat);
1208     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_DumpInfo failed");
1209     OH_AVFormat_Destroy(AVFormat);
1210     napi_value result = nullptr;
1211     napi_create_int32(env, SUCCESS, &result);
1212     return result;
1213 }
1214 
MultimediaCoreAVFormatDumpInfoLANGUAGE(napi_env env,napi_callback_info)1215 static napi_value MultimediaCoreAVFormatDumpInfoLANGUAGE(napi_env env, napi_callback_info)
1216 {
1217     struct OH_AVFormat *AVFormat = OH_AVFormat_Create();
1218     OH_AVFormat_SetStringValue(AVFormat, OH_MD_KEY_LANGUAGE, "aaa");
1219     const char *ReturnValue = OH_AVFormat_DumpInfo(AVFormat);
1220     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_DumpInfo failed");
1221     OH_AVFormat_Destroy(AVFormat);
1222     napi_value result = nullptr;
1223     napi_create_int32(env, SUCCESS, &result);
1224     return result;
1225 }
1226 
MultimediaCoreAVFormatDumpInfoDESCRIPTION(napi_env env,napi_callback_info)1227 static napi_value MultimediaCoreAVFormatDumpInfoDESCRIPTION(napi_env env, napi_callback_info)
1228 {
1229     struct OH_AVFormat *AVFormat = OH_AVFormat_Create();
1230     OH_AVFormat_SetStringValue(AVFormat, OH_MD_KEY_DESCRIPTION, "aaa");
1231     const char *ReturnValue = OH_AVFormat_DumpInfo(AVFormat);
1232     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_DumpInfo failed");
1233     OH_AVFormat_Destroy(AVFormat);
1234     napi_value result = nullptr;
1235     napi_create_int32(env, SUCCESS, &result);
1236     return result;
1237 }
1238 
MultimediaCoreAVFormatDumpInfoLYRICS(napi_env env,napi_callback_info)1239 static napi_value MultimediaCoreAVFormatDumpInfoLYRICS(napi_env env, napi_callback_info)
1240 {
1241     struct OH_AVFormat *AVFormat = OH_AVFormat_Create();
1242     OH_AVFormat_SetStringValue(AVFormat, OH_MD_KEY_LYRICS, "aaa");
1243     const char *ReturnValue = OH_AVFormat_DumpInfo(AVFormat);
1244     NAPI_ASSERT(env, ReturnValue != nullptr, "OH_AVFormat_DumpInfo failed");
1245     OH_AVFormat_Destroy(AVFormat);
1246     napi_value result = nullptr;
1247     napi_create_int32(env, SUCCESS, &result);
1248     return result;
1249 }
1250 
domain(napi_env env,napi_callback_info info)1251 static const char *domain(napi_env env, napi_callback_info info)
1252 {
1253     size_t argc = PARAM_1;
1254     napi_value args[PARAM_1] = {nullptr};
1255     napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
1256     int param = PARAM_0;
1257     napi_get_value_int32(env, args[PARAM_0], &param);
1258     const char *key = nullptr;
1259     if (param == KEY_RANGE_FLAG) {
1260         key = OH_MD_KEY_RANGE_FLAG;
1261     } else if (param == KEY_COLOR_PRIMARIES) {
1262         key = OH_MD_KEY_COLOR_PRIMARIES;
1263     } else if (param == KEY_TRANSFER_CHARACTERISTICS) {
1264         key = OH_MD_KEY_TRANSFER_CHARACTERISTICS;
1265     } else if (param == KEY_MATRIX_COEFFICIENTS) {
1266         key = OH_MD_KEY_MATRIX_COEFFICIENTS;
1267     } else if (param == KEY_REQUEST_I_FRAME) {
1268         key = OH_MD_KEY_REQUEST_I_FRAME;
1269     } else if (param == KEY_CODEC_CONFIG) {
1270         key = OH_MD_KEY_CODEC_CONFIG;
1271     } else if (param == KEY_TITLE) {
1272         key = OH_MD_KEY_TITLE;
1273     } else if (param == KEY_ARTIST) {
1274         key = OH_MD_KEY_ARTIST;
1275     } else if (param == KEY_ALBUM) {
1276         key = OH_MD_KEY_ALBUM;
1277     } else if (param == KEY_ALBUM_ARTIST) {
1278         key = OH_MD_KEY_ALBUM_ARTIST;
1279     } else if (param == KEY_DATE) {
1280         key = OH_MD_KEY_DATE;
1281     } else if (param == KEY_COMMENT) {
1282         key = OH_MD_KEY_COMMENT;
1283     } else if (param == KEY_GENRE) {
1284         key = OH_MD_KEY_GENRE;
1285     } else if (param == KEY_COPYRIGHT) {
1286         key = OH_MD_KEY_COPYRIGHT;
1287     } else if (param == KEY_LANGUAGE) {
1288         key = OH_MD_KEY_LANGUAGE;
1289     } else if (param == KEY_DESCRIPTION) {
1290         key = OH_MD_KEY_DESCRIPTION;
1291     } else if (param == KEY_LYRICS) {
1292         key = OH_MD_KEY_LYRICS;
1293     } else if (param == KEY_TRACK_COUNT) {
1294         key = OH_MD_KEY_TRACK_COUNT;
1295     } else if (param == KEY_CHANNEL_LAYOUT) {
1296         key = OH_MD_KEY_CHANNEL_LAYOUT;
1297     } else if (param == KEY_BITS_PER_CODED_SAMPLE) {
1298         key = OH_MD_KEY_BITS_PER_CODED_SAMPLE;
1299     } else if (param == KEY_AAC_IS_ADTS) {
1300         key = OH_MD_KEY_AAC_IS_ADTS;
1301     } else if (param == KEY_SBR) {
1302         key = OH_MD_KEY_SBR;
1303     } else if (param == KEY_COMPLIANCE_LEVEL) {
1304         key = OH_MD_KEY_COMPLIANCE_LEVEL;
1305     } else if (param == KEY_IDENTIFICATION_HEADER) {
1306         key = OH_MD_KEY_IDENTIFICATION_HEADER;
1307     } else if (param == KEY_SETUP_HEADER) {
1308         key = OH_MD_KEY_SETUP_HEADER;
1309     } else if (param == KEY_SCALING_MODE) {
1310         key = OH_MD_KEY_SCALING_MODE;
1311     } else if (param == MAX_INPUT_BUFFER_COUNT) {
1312         key = OH_MD_MAX_INPUT_BUFFER_COUNT;
1313     } else if (param == MAX_OUTPUT_BUFFER_COUNT) {
1314         key = OH_MD_MAX_OUTPUT_BUFFER_COUNT;
1315     } else if (param == KEY_TRACK_TYPE) {
1316         key = OH_MD_KEY_TRACK_TYPE;
1317     } else if (param == KEY_CODEC_MIME) {
1318         key = OH_MD_KEY_CODEC_MIME;
1319     } else if (param == KEY_DURATION) {
1320         key = OH_MD_KEY_DURATION;
1321     } else if (param == KEY_BITRATE) {
1322         key = OH_MD_KEY_BITRATE;
1323     } else if (param == KEY_MAX_INPUT_SIZE) {
1324         key = OH_MD_KEY_MAX_INPUT_SIZE;
1325     } else if (param == KEY_WIDTH) {
1326         key = OH_MD_KEY_WIDTH;
1327     } else if (param == KEY_HEIGHT) {
1328         key = OH_MD_KEY_HEIGHT;
1329     } else if (param == KEY_PIXEL_FORMAT) {
1330         key = OH_MD_KEY_PIXEL_FORMAT;
1331     } else if (param == KEY_FRAME_RATE) {
1332         key = OH_MD_KEY_FRAME_RATE;
1333     } else if (param == KEY_AUD_CHANNEL_COUNT) {
1334         key = OH_MD_KEY_AUD_CHANNEL_COUNT;
1335     } else if (param == KEY_AUD_SAMPLE_RATE) {
1336         key = OH_MD_KEY_AUD_SAMPLE_RATE;
1337     } else if (param == KEY_I_FRAME_INTERVAL) {
1338         key = OH_MD_KEY_I_FRAME_INTERVAL;
1339     } else if (param == KEY_ROTATION) {
1340         key = OH_MD_KEY_ROTATION;
1341     } else {
1342         key = OH_MD_KEY_ROTATION;
1343     }
1344     return key;
1345 }
1346 
MultimediaCoreAVFormatSetBufferAll(napi_env env,napi_callback_info info)1347 static napi_value MultimediaCoreAVFormatSetBufferAll(napi_env env, napi_callback_info info)
1348 {
1349     OH_AVFormat *AVFormat = OH_AVFormat_Create();
1350     int32_t buffernum = PARAM_10;
1351     size_t sizeIn = buffernum * sizeof(uint8_t);
1352     uint8_t *buffer = reinterpret_cast<uint8_t *>(malloc(sizeIn));
1353     const char *key = domain(env, info);
1354     bool ReturnValue = OH_AVFormat_SetBuffer(AVFormat, key, buffer, sizeIn);
1355 
1356     if (Set_Buffer_Key_Map.find(key) != Set_Buffer_Key_Map.end()) {
1357         NAPI_ASSERT(env, ReturnValue == true, "OH_AVFormat_SetBuffer failed");
1358     } else {
1359         NAPI_ASSERT(env, ReturnValue == false, "OH_AVFormat_SetBuffer failed");
1360     }
1361 
1362     OH_AVFormat_Destroy(AVFormat);
1363     free(buffer);
1364     napi_value result = nullptr;
1365     napi_create_int32(env, SUCCESS, &result);
1366     return result;
1367 }
1368 
MultimediaCoreAVBufferCreate(napi_env env,napi_callback_info)1369 static napi_value MultimediaCoreAVBufferCreate(napi_env env, napi_callback_info)
1370 {
1371     OH_AVBuffer *avMemBuffer = OH_AVBuffer_Create(INFO_SIZE);
1372     NAPI_ASSERT(env, avMemBuffer != nullptr, "OH_AVBuffer_Create failed");
1373     OH_AVBuffer_Destroy(avMemBuffer);
1374     napi_value result = nullptr;
1375     napi_create_int32(env, SUCCESS, &result);
1376     return result;
1377 }
1378 
MultimediaCoreAVBufferDestroy(napi_env env,napi_callback_info)1379 static napi_value MultimediaCoreAVBufferDestroy(napi_env env, napi_callback_info)
1380 {
1381     OH_AVBuffer *avMemBuffer = OH_AVBuffer_Create(INFO_SIZE);
1382     OH_AVErrCode ReturnValue = OH_AVBuffer_Destroy(avMemBuffer);
1383     NAPI_ASSERT(env, ReturnValue == AV_ERR_OK, "OH_AVBuffer_Destroy failed");
1384     napi_value result = nullptr;
1385     napi_create_int32(env, SUCCESS, &result);
1386     return result;
1387 }
1388 
MultimediaCoreAVBufferGetBufferAttr(napi_env env,napi_callback_info)1389 static napi_value MultimediaCoreAVBufferGetBufferAttr(napi_env env, napi_callback_info)
1390 {
1391     OH_AVBuffer *avMemBuffer = OH_AVBuffer_Create(INFO_SIZE);
1392     OH_AVCodecBufferAttr attr;
1393     OH_AVErrCode ReturnValue = OH_AVBuffer_GetBufferAttr(avMemBuffer, &attr);
1394     NAPI_ASSERT(env, ReturnValue == AV_ERR_OK, "OH_AVBuffer_GetBufferAttr failed");
1395     OH_AVBuffer_Destroy(avMemBuffer);
1396     napi_value result = nullptr;
1397     napi_create_int32(env, SUCCESS, &result);
1398     return result;
1399 }
1400 
MultimediaCoreAVBufferSetBufferAttr(napi_env env,napi_callback_info)1401 static napi_value MultimediaCoreAVBufferSetBufferAttr(napi_env env, napi_callback_info)
1402 {
1403     OH_AVBuffer *avMemBuffer = OH_AVBuffer_Create(INFO_SIZE);
1404     OH_AVErrCode ReturnValue = OH_AVBuffer_SetBufferAttr(avMemBuffer, nullptr);
1405     NAPI_ASSERT(env, ReturnValue != AV_ERR_OK, "OH_AVBuffer_SetBufferAttr failed");
1406     OH_AVBuffer_Destroy(avMemBuffer);
1407     napi_value result = nullptr;
1408     napi_create_int32(env, SUCCESS, &result);
1409     return result;
1410 }
1411 
MultimediaCoreAVBufferGetParameter(napi_env env,napi_callback_info)1412 static napi_value MultimediaCoreAVBufferGetParameter(napi_env env, napi_callback_info)
1413 {
1414     OH_AVBuffer *avMemBuffer = OH_AVBuffer_Create(INFO_SIZE);
1415     OH_AVFormat *format = OH_AVBuffer_GetParameter(avMemBuffer);
1416     NAPI_ASSERT(env, format != nullptr, "OH_AVBuffer_GetParameter failed");
1417     OH_AVBuffer_Destroy(avMemBuffer);
1418     napi_value result = nullptr;
1419     napi_create_int32(env, SUCCESS, &result);
1420     return result;
1421 }
1422 
MultimediaCoreAVBufferSetParameter(napi_env env,napi_callback_info)1423 static napi_value MultimediaCoreAVBufferSetParameter(napi_env env, napi_callback_info)
1424 {
1425     OH_AVBuffer *avMemBuffer = OH_AVBuffer_Create(INFO_SIZE);
1426     OH_AVErrCode ReturnValue = OH_AVBuffer_SetParameter(avMemBuffer, nullptr);
1427     NAPI_ASSERT(env, ReturnValue != AV_ERR_OK, "OH_AVBuffer_SetParameter failed");
1428     OH_AVBuffer_Destroy(avMemBuffer);
1429     napi_value result = nullptr;
1430     napi_create_int32(env, SUCCESS, &result);
1431     return result;
1432 }
1433 
MultimediaCoreAVBufferGetAddr(napi_env env,napi_callback_info)1434 static napi_value MultimediaCoreAVBufferGetAddr(napi_env env, napi_callback_info)
1435 {
1436     OH_AVBuffer *avMemBuffer = OH_AVBuffer_Create(INFO_SIZE);
1437     uint8_t *data = OH_AVBuffer_GetAddr(avMemBuffer);
1438     NAPI_ASSERT(env, data != nullptr, "OH_AVBuffer_GetAddr failed");
1439     OH_AVBuffer_Destroy(avMemBuffer);
1440     napi_value result = nullptr;
1441     napi_create_int32(env, SUCCESS, &result);
1442     return result;
1443 }
1444 
MultimediaCoreAVBufferGetCapacity(napi_env env,napi_callback_info)1445 static napi_value MultimediaCoreAVBufferGetCapacity(napi_env env, napi_callback_info)
1446 {
1447     OH_AVBuffer *avMemBuffer = OH_AVBuffer_Create(INFO_SIZE);
1448     int32_t data = OH_AVBuffer_GetCapacity(avMemBuffer);
1449     NAPI_ASSERT(env, data == INFO_SIZE, "OH_AVBuffer_GetCapacity failed");
1450     napi_value result = nullptr;
1451     OH_AVBuffer_Destroy(avMemBuffer);
1452     napi_create_int32(env, SUCCESS, &result);
1453     return result;
1454 }
1455 
MultimediaCoreAVBufferGetNativeBuffer(napi_env env,napi_callback_info)1456 static napi_value MultimediaCoreAVBufferGetNativeBuffer(napi_env env, napi_callback_info)
1457 {
1458     OH_AVBuffer *avMemBuffer = OH_AVBuffer_Create(INFO_SIZE);
1459     OH_NativeBuffer *surfaceBuffer = OH_AVBuffer_GetNativeBuffer(avMemBuffer);
1460     napi_value result = nullptr;
1461     OH_AVBuffer_Destroy(avMemBuffer);
1462     napi_create_int32(env, SUCCESS, &result);
1463     return result;
1464 }
1465 
1466 EXTERN_C_START
Init(napi_env env,napi_value exports)1467 static napi_value Init(napi_env env, napi_value exports) {
1468     napi_property_descriptor desc[] = {
1469         {"multimediaCoreAVFormatCreate", nullptr, MultimediaCoreAVFormatCreate, nullptr, nullptr, nullptr, napi_default,
1470          nullptr},
1471         {"multimediaCoreAVFormatCreateAudioFormatOne", nullptr, MultimediaCoreAVFormatCreateAudioFormatOne, nullptr,
1472          nullptr, nullptr, napi_default, nullptr},
1473         {"multimediaCoreAVFormatCreateAudioFormatTwo", nullptr, MultimediaCoreAVFormatCreateAudioFormatTwo, nullptr,
1474          nullptr, nullptr, napi_default, nullptr},
1475         {"multimediaCoreAVFormatCreateVideoFormatOne", nullptr, MultimediaCoreAVFormatCreateVideoFormatOne, nullptr,
1476          nullptr, nullptr, napi_default, nullptr},
1477         {"multimediaCoreAVFormatCreateVideoFormatTwo", nullptr, MultimediaCoreAVFormatCreateVideoFormatTwo, nullptr,
1478          nullptr, nullptr, napi_default, nullptr},
1479         {"multimediaCoreAVFormatCopyOne", nullptr, MultimediaCoreAVFormatCopyOne, nullptr, nullptr, nullptr,
1480          napi_default, nullptr},
1481         {"multimediaCoreAVFormatCopyTwo", nullptr, MultimediaCoreAVFormatCopyTwo, nullptr, nullptr, nullptr,
1482          napi_default, nullptr},
1483         {"multimediaCoreAVFormatCopyThree", nullptr, MultimediaCoreAVFormatCopyThree, nullptr, nullptr, nullptr,
1484          napi_default, nullptr},
1485         {"multimediaCoreAVFormatDestroy", nullptr, MultimediaCoreAVFormatDestroy, nullptr, nullptr, nullptr,
1486          napi_default, nullptr},
1487         {"multimediaCoreAVFormatDumpInfoOne", nullptr, MultimediaCoreAVFormatDumpInfoOne, nullptr, nullptr, nullptr,
1488          napi_default, nullptr},
1489         {"multimediaCoreAVFormatDumpInfoTwo", nullptr, MultimediaCoreAVFormatDumpInfoTwo, nullptr, nullptr, nullptr,
1490          napi_default, nullptr},
1491         {"multimediaCoreAVFormatGetBufferOne", nullptr, MultimediaCoreAVFormatGetBufferOne, nullptr, nullptr, nullptr,
1492          napi_default, nullptr},
1493         {"multimediaCoreAVFormatGetBufferTwo", nullptr, MultimediaCoreAVFormatGetBufferTwo, nullptr, nullptr, nullptr,
1494          napi_default, nullptr},
1495         {"multimediaCoreAVFormatGetBufferThree", nullptr, MultimediaCoreAVFormatGetBufferThree, nullptr, nullptr,
1496          nullptr, napi_default, nullptr},
1497         {"multimediaCoreAVFormatGetBufferFour", nullptr, MultimediaCoreAVFormatGetBufferFour, nullptr, nullptr, nullptr,
1498          napi_default, nullptr},
1499         {"multimediaCoreAVFormatGetBufferFive", nullptr, MultimediaCoreAVFormatGetBufferFive, nullptr, nullptr, nullptr,
1500          napi_default, nullptr},
1501         {"multimediaCoreAVFormatGetDoubleValueOne", nullptr, MultimediaCoreAVFormatGetDoubleValueOne, nullptr, nullptr,
1502          nullptr, napi_default, nullptr},
1503         {"multimediaCoreAVFormatGetDoubleValueTwo", nullptr, MultimediaCoreAVFormatGetDoubleValueTwo, nullptr, nullptr,
1504          nullptr, napi_default, nullptr},
1505         {"multimediaCoreAVFormatGetDoubleValueThree", nullptr, MultimediaCoreAVFormatGetDoubleValueThree, nullptr,
1506          nullptr, nullptr, napi_default, nullptr},
1507         {"multimediaCoreAVFormatGetDoubleValueFour", nullptr, MultimediaCoreAVFormatGetDoubleValueFour, nullptr,
1508          nullptr, nullptr, napi_default, nullptr},
1509         {"multimediaCoreAVFormatGetDoubleValueFive", nullptr, MultimediaCoreAVFormatGetDoubleValueFive, nullptr,
1510          nullptr, nullptr, napi_default, nullptr},
1511         {"multimediaCoreAVFormatGetFloatValueOne", nullptr, MultimediaCoreAVFormatGetFloatValueOne, nullptr, nullptr,
1512          nullptr, napi_default, nullptr},
1513         {"multimediaCoreAVFormatGetFloatValueTwo", nullptr, MultimediaCoreAVFormatGetFloatValueTwo, nullptr, nullptr,
1514          nullptr, napi_default, nullptr},
1515         {"multimediaCoreAVFormatGetFloatValueThree", nullptr, MultimediaCoreAVFormatGetFloatValueThree, nullptr,
1516          nullptr, nullptr, napi_default, nullptr},
1517         {"multimediaCoreAVFormatGetFloatValueFour", nullptr, MultimediaCoreAVFormatGetFloatValueFour, nullptr, nullptr,
1518          nullptr, napi_default, nullptr},
1519         {"multimediaCoreAVFormatGetFloatValueFive", nullptr, MultimediaCoreAVFormatGetFloatValueFive, nullptr, nullptr,
1520          nullptr, napi_default, nullptr},
1521         {"multimediaCoreAVFormatGetIntValueOne", nullptr, MultimediaCoreAVFormatGetIntValueOne, nullptr, nullptr,
1522          nullptr, napi_default, nullptr},
1523         {"multimediaCoreAVFormatGetIntValueTwo", nullptr, MultimediaCoreAVFormatGetIntValueTwo, nullptr, nullptr,
1524          nullptr, napi_default, nullptr},
1525         {"multimediaCoreAVFormatGetIntValueThree", nullptr, MultimediaCoreAVFormatGetIntValueThree, nullptr, nullptr,
1526          nullptr, napi_default, nullptr},
1527         {"multimediaCoreAVFormatGetIntValueFour", nullptr, MultimediaCoreAVFormatGetIntValueFour, nullptr, nullptr,
1528          nullptr, napi_default, nullptr},
1529         {"multimediaCoreAVFormatGetIntValueFive", nullptr, MultimediaCoreAVFormatGetIntValueFive, nullptr, nullptr,
1530          nullptr, napi_default, nullptr},
1531         {"multimediaCoreAVFormatGetLongValueOne", nullptr, MultimediaCoreAVFormatGetLongValueOne, nullptr, nullptr,
1532          nullptr, napi_default, nullptr},
1533         {"multimediaCoreAVFormatGetLongValueTwo", nullptr, MultimediaCoreAVFormatGetLongValueTwo, nullptr, nullptr,
1534          nullptr, napi_default, nullptr},
1535         {"multimediaCoreAVFormatGetLongValueThree", nullptr, MultimediaCoreAVFormatGetLongValueThree, nullptr, nullptr,
1536          nullptr, napi_default, nullptr},
1537         {"multimediaCoreAVFormatGetLongValueFour", nullptr, MultimediaCoreAVFormatGetLongValueFour, nullptr, nullptr,
1538          nullptr, napi_default, nullptr},
1539         {"multimediaCoreAVFormatGetLongValueFive", nullptr, MultimediaCoreAVFormatGetLongValueFive, nullptr, nullptr,
1540          nullptr, napi_default, nullptr},
1541         {"multimediaCoreAVFormatGetStringValueOne", nullptr, MultimediaCoreAVFormatGetStringValueOne, nullptr, nullptr,
1542          nullptr, napi_default, nullptr},
1543         {"multimediaCoreAVFormatGetStringValueTwo", nullptr, MultimediaCoreAVFormatGetStringValueTwo, nullptr, nullptr,
1544          nullptr, napi_default, nullptr},
1545         {"multimediaCoreAVFormatGetStringValueThree", nullptr, MultimediaCoreAVFormatGetStringValueThree, nullptr,
1546          nullptr, nullptr, napi_default, nullptr},
1547         {"multimediaCoreAVFormatGetStringValueFour", nullptr, MultimediaCoreAVFormatGetStringValueFour, nullptr,
1548          nullptr, nullptr, napi_default, nullptr},
1549         {"multimediaCoreAVFormatGetStringValueFive", nullptr, MultimediaCoreAVFormatGetStringValueFive, nullptr,
1550          nullptr, nullptr, napi_default, nullptr},
1551         {"multimediaCoreAVFormatSetBufferOne", nullptr, MultimediaCoreAVFormatSetBufferOne, nullptr, nullptr, nullptr,
1552          napi_default, nullptr},
1553         {"multimediaCoreAVFormatSetBufferTwo", nullptr, MultimediaCoreAVFormatSetBufferTwo, nullptr, nullptr, nullptr,
1554          napi_default, nullptr},
1555         {"multimediaCoreAVFormatSetBufferThree", nullptr, MultimediaCoreAVFormatSetBufferThree, nullptr, nullptr,
1556          nullptr, napi_default, nullptr},
1557         {"multimediaCoreAVFormatSetBufferFour", nullptr, MultimediaCoreAVFormatSetBufferFour, nullptr, nullptr, nullptr,
1558          napi_default, nullptr},
1559         {"multimediaCoreAVFormatSetDoubleValueOne", nullptr, MultimediaCoreAVFormatSetDoubleValueOne, nullptr, nullptr,
1560          nullptr, napi_default, nullptr},
1561         {"multimediaCoreAVFormatSetDoubleValueTwo", nullptr, MultimediaCoreAVFormatSetDoubleValueTwo, nullptr, nullptr,
1562          nullptr, napi_default, nullptr},
1563         {"multimediaCoreAVFormatSetDoubleValueThree", nullptr, MultimediaCoreAVFormatSetDoubleValueThree, nullptr,
1564          nullptr, nullptr, napi_default, nullptr},
1565         {"multimediaCoreAVFormatSetFloatValueOne", nullptr, MultimediaCoreAVFormatSetFloatValueOne, nullptr, nullptr,
1566          nullptr, napi_default, nullptr},
1567         {"multimediaCoreAVFormatSetFloatValueTwo", nullptr, MultimediaCoreAVFormatSetFloatValueTwo, nullptr, nullptr,
1568          nullptr, napi_default, nullptr},
1569         {"multimediaCoreAVFormatSetFloatValueThree", nullptr, MultimediaCoreAVFormatSetFloatValueThree, nullptr,
1570          nullptr, nullptr, napi_default, nullptr},
1571         {"multimediaCoreAVFormatSetIntValueOne", nullptr, MultimediaCoreAVFormatSetIntValueOne, nullptr, nullptr,
1572          nullptr, napi_default, nullptr},
1573         {"multimediaCoreAVFormatSetIntValueTwo", nullptr, MultimediaCoreAVFormatSetIntValueTwo, nullptr, nullptr,
1574          nullptr, napi_default, nullptr},
1575         {"multimediaCoreAVFormatSetIntValueThree", nullptr, MultimediaCoreAVFormatSetIntValueThree, nullptr, nullptr,
1576          nullptr, napi_default, nullptr},
1577         {"multimediaCoreAVFormatSetLongValueOne", nullptr, MultimediaCoreAVFormatSetLongValueOne, nullptr, nullptr,
1578          nullptr, napi_default, nullptr},
1579         {"multimediaCoreAVFormatSetLongValueTwo", nullptr, MultimediaCoreAVFormatSetLongValueTwo, nullptr, nullptr,
1580          nullptr, napi_default, nullptr},
1581         {"multimediaCoreAVFormatSetLongValueThree", nullptr, MultimediaCoreAVFormatSetLongValueThree, nullptr, nullptr,
1582          nullptr, napi_default, nullptr},
1583         {"MultimediaCoreAVFormatSetStringValueOne", nullptr, MultimediaCoreAVFormatSetStringValueOne, nullptr, nullptr,
1584          nullptr, napi_default, nullptr},
1585         {"MultimediaCoreAVFormatSetStringValueTwo", nullptr, MultimediaCoreAVFormatSetStringValueTwo, nullptr, nullptr,
1586          nullptr, napi_default, nullptr},
1587         {"MultimediaCoreAVFormatSetStringValueThree", nullptr, MultimediaCoreAVFormatSetStringValueThree, nullptr,
1588          nullptr, nullptr, napi_default, nullptr},
1589         {"MultimediaCoreAVFormatSetStringValueFour", nullptr, MultimediaCoreAVFormatSetStringValueFour, nullptr,
1590          nullptr, nullptr, napi_default, nullptr},
1591         {"multimediaCoreAVMemoryCreateOne", nullptr, MultimediaCoreAVMemoryCreateOne, nullptr, nullptr, nullptr,
1592          napi_default, nullptr},
1593         {"multimediaCoreAVMemoryCreateTwo", nullptr, MultimediaCoreAVMemoryCreateTwo, nullptr, nullptr, nullptr,
1594          napi_default, nullptr},
1595         {"multimediaCoreAVMemoryDestroyOne", nullptr, MultimediaCoreAVMemoryDestroyOne, nullptr, nullptr, nullptr,
1596          napi_default, nullptr},
1597         {"multimediaCoreAVMemoryDestroyTwo", nullptr, MultimediaCoreAVMemoryDestroyTwo, nullptr, nullptr, nullptr,
1598          napi_default, nullptr},
1599         {"multimediaCoreAVMemoryGetAddrOne", nullptr, MultimediaCoreAVMemoryGetAddrOne, nullptr, nullptr, nullptr,
1600          napi_default, nullptr},
1601         {"multimediaCoreAVMemoryGetAddrTwo", nullptr, MultimediaCoreAVMemoryGetAddrTwo, nullptr, nullptr, nullptr,
1602          napi_default, nullptr},
1603         {"multimediaCoreAVMemoryGetSizeOne", nullptr, MultimediaCoreAVMemoryGetSizeOne, nullptr, nullptr, nullptr,
1604          napi_default, nullptr},
1605         {"multimediaCoreAVMemoryGetSizeTwo", nullptr, MultimediaCoreAVMemoryGetSizeTwo, nullptr, nullptr, nullptr,
1606          napi_default, nullptr},
1607 
1608         {"multimediaCoreAVFormatCreateAudioFormatAVC", nullptr, MultimediaCoreAVFormatCreateAudioFormatAVC, nullptr,
1609          nullptr, nullptr, napi_default, nullptr},
1610         {"multimediaCoreAVFormatCreateAudioFormatVORBIS", nullptr, MultimediaCoreAVFormatCreateAudioFormatVORBIS,
1611          nullptr, nullptr, nullptr, napi_default, nullptr},
1612         {"multimediaCoreAVFormatCreateAudioFormatVORBISMPEG", nullptr,
1613          MultimediaCoreAVFormatCreateAudioFormatVORBISMPEG, nullptr, nullptr, nullptr, napi_default, nullptr},
1614         {"multimediaCoreAVFormatCreateVideoFormatHEVC", nullptr, MultimediaCoreAVFormatCreateVideoFormatHEVC, nullptr,
1615          nullptr, nullptr, napi_default, nullptr},
1616         {"multimediaCoreAVFormatCreateVideoFormatMPEG4", nullptr, MultimediaCoreAVFormatCreateVideoFormatMPEG4, nullptr,
1617          nullptr, nullptr, napi_default, nullptr},
1618 
1619         {"multimediaCoreAVFormatDestroyVideoHEVC", nullptr, MultimediaCoreAVFormatDestroyVideoHEVC, nullptr, nullptr,
1620          nullptr, napi_default, nullptr},
1621         {"multimediaCoreAVFormatDestroyVideoMPEG4", nullptr, MultimediaCoreAVFormatDestroyVideoMPEG4, nullptr, nullptr,
1622          nullptr, napi_default, nullptr},
1623         {"multimediaCoreAVFormatDestroyAudioFLAC", nullptr, MultimediaCoreAVFormatDestroyAudioFLAC, nullptr, nullptr,
1624          nullptr, napi_default, nullptr},
1625         {"multimediaCoreAVFormatDestroyAudioAAC", nullptr, MultimediaCoreAVFormatDestroyAudioAAC, nullptr, nullptr,
1626          nullptr, napi_default, nullptr},
1627         {"multimediaCoreAVFormatDestroyAudioVORBIS", nullptr, MultimediaCoreAVFormatDestroyAudioVORBIS, nullptr,
1628          nullptr, nullptr, napi_default, nullptr},
1629         {"multimediaCoreAVFormatDestroyAudioMPEG", nullptr, MultimediaCoreAVFormatDestroyAudioMPEG, nullptr, nullptr,
1630          nullptr, napi_default, nullptr},
1631 
1632         {"multimediaCoreAVFormatCopyVideoHEVC", nullptr, MultimediaCoreAVFormatCopyVideoHEVC, nullptr, nullptr, nullptr,
1633          napi_default, nullptr},
1634         {"multimediaCoreAVFormatCopyVideoMPEG4", nullptr, MultimediaCoreAVFormatCopyVideoMPEG4, nullptr, nullptr,
1635          nullptr, napi_default, nullptr},
1636 
1637         {"multimediaCoreAVFormatCopyAudioAAC", nullptr, MultimediaCoreAVFormatCopyAudioAAC, nullptr, nullptr, nullptr,
1638          napi_default, nullptr},
1639         {"multimediaCoreAVFormatCopyAudioFLAC", nullptr, MultimediaCoreAVFormatCopyAudioFLAC, nullptr, nullptr, nullptr,
1640          napi_default, nullptr},
1641         {"multimediaCoreAVFormatCopyAudioVORBIS", nullptr, MultimediaCoreAVFormatCopyAudioVORBIS, nullptr, nullptr,
1642          nullptr, napi_default, nullptr},
1643         {"multimediaCoreAVFormatCopyAudioMPEG", nullptr, MultimediaCoreAVFormatCopyAudioMPEG, nullptr, nullptr, nullptr,
1644          napi_default, nullptr},
1645 
1646         {"multimediaCoreAVFormatDumpInfoARTIST", nullptr, MultimediaCoreAVFormatDumpInfoARTIST, nullptr, nullptr,
1647          nullptr, napi_default, nullptr},
1648         {"multimediaCoreAVFormatDumpInfoALBUM", nullptr, MultimediaCoreAVFormatDumpInfoALBUM, nullptr, nullptr, nullptr,
1649          napi_default, nullptr},
1650         {"multimediaCoreAVFormatDumpInfoALBUMARTIST", nullptr, MultimediaCoreAVFormatDumpInfoALBUMARTIST, nullptr,
1651          nullptr, nullptr, napi_default, nullptr},
1652         {"multimediaCoreAVFormatDumpInfoDATE", nullptr, MultimediaCoreAVFormatDumpInfoDATE, nullptr, nullptr, nullptr,
1653          napi_default, nullptr},
1654         {"multimediaCoreAVFormatDumpInfoCOMMENT", nullptr, MultimediaCoreAVFormatDumpInfoCOMMENT, nullptr, nullptr,
1655          nullptr, napi_default, nullptr},
1656         {"multimediaCoreAVFormatDumpInfoGENRE", nullptr, MultimediaCoreAVFormatDumpInfoGENRE, nullptr, nullptr, nullptr,
1657          napi_default, nullptr},
1658         {"multimediaCoreAVFormatDumpInfoCOPYRIGHT", nullptr, MultimediaCoreAVFormatDumpInfoCOPYRIGHT, nullptr, nullptr,
1659          nullptr, napi_default, nullptr},
1660         {"multimediaCoreAVFormatDumpInfoLANGUAGE", nullptr, MultimediaCoreAVFormatDumpInfoLANGUAGE, nullptr, nullptr,
1661          nullptr, napi_default, nullptr},
1662         {"multimediaCoreAVFormatDumpInfoDESCRIPTION", nullptr, MultimediaCoreAVFormatDumpInfoDESCRIPTION, nullptr,
1663          nullptr, nullptr, napi_default, nullptr},
1664         {"multimediaCoreAVFormatDumpInfoLYRICS", nullptr, MultimediaCoreAVFormatDumpInfoLYRICS, nullptr, nullptr,
1665          nullptr, napi_default, nullptr},
1666         {"multimediaCoreAVFormatSetBufferAll", nullptr, MultimediaCoreAVFormatSetBufferAll, nullptr, nullptr, nullptr,
1667          napi_default, nullptr},
1668         {"multimediaCoreAVBufferCreate", nullptr, MultimediaCoreAVBufferCreate, nullptr, nullptr, nullptr,
1669          napi_default, nullptr},
1670         {"multimediaCoreAVBufferDestroy", nullptr, MultimediaCoreAVBufferDestroy, nullptr, nullptr, nullptr,
1671          napi_default, nullptr},
1672         {"multimediaCoreAVBufferGetBufferAttr", nullptr, MultimediaCoreAVBufferGetBufferAttr, nullptr, nullptr, nullptr,
1673          napi_default, nullptr},
1674         {"multimediaCoreAVBufferSetBufferAttr", nullptr, MultimediaCoreAVBufferSetBufferAttr, nullptr, nullptr, nullptr,
1675          napi_default, nullptr},
1676         {"multimediaCoreAVBufferGetParameter", nullptr, MultimediaCoreAVBufferGetParameter, nullptr, nullptr, nullptr,
1677          napi_default, nullptr},
1678         {"multimediaCoreAVBufferSetParameter", nullptr, MultimediaCoreAVBufferSetParameter, nullptr, nullptr, nullptr,
1679          napi_default, nullptr},
1680         {"multimediaCoreAVBufferGetAddr", nullptr, MultimediaCoreAVBufferGetAddr, nullptr, nullptr, nullptr,
1681          napi_default, nullptr},
1682         {"multimediaCoreAVBufferGetCapacity", nullptr, MultimediaCoreAVBufferGetCapacity, nullptr, nullptr, nullptr,
1683          napi_default, nullptr},
1684         {"multimediaCoreAVBufferGetNativeBuffer", nullptr, MultimediaCoreAVBufferGetNativeBuffer, nullptr, nullptr, nullptr,
1685          napi_default, nullptr},
1686     };
1687 
1688     napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
1689     return exports;
1690 }
1691 
1692 EXTERN_C_END
1693 
1694 static napi_module demoModule = {
1695     .nm_version = 1,
1696     .nm_flags = 0,
1697     .nm_filename = nullptr,
1698     .nm_register_func = Init,
1699     .nm_modname = "libmultimediaCore",
1700     .nm_priv = ((void *)0),
1701     .reserved = {0},
1702 };
1703 
RegisterEntryModule(void)1704 extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
1705 {
1706     napi_module_register(&demoModule);
1707 }
1708