• 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 #include <iostream>
16 #include <cstdio>
17 #include <string>
18 
19 #include "gtest/gtest.h"
20 #include "native_avcodec_base.h"
21 #include "native_avformat.h"
22 #include "native_avcodec_videoencoder.h"
23 #include "videoenc_sample.h"
24 #include "native_avcapability.h"
25 #include "videoenc_api11_sample.h"
26 using namespace std;
27 using namespace OHOS;
28 using namespace OHOS::Media;
29 using namespace testing::ext;
30 namespace {
31 OH_AVCodec *venc_ = NULL;
32 constexpr uint32_t DEFAULT_WIDTH = 1920;
33 constexpr uint32_t DEFAULT_HEIGHT = 1080;
34 constexpr uint32_t CODEC_NAME_SIZE = 128;
35 char g_codecName[CODEC_NAME_SIZE] = {};
36 OH_AVCapability *cap = nullptr;
37 OHOS::Media::VEncSignal *signal_ = nullptr;
38 OH_AVFormat *format;
onError(OH_AVCodec * codec,int32_t errorCode,void * userData)39 void onError(OH_AVCodec *codec, int32_t errorCode, void *userData)
40 {
41     cout << "Error errorCode=" << errorCode << endl;
42 };
43 
onStreamChanged(OH_AVCodec * codec,OH_AVFormat * fmt,void * userData)44 void onStreamChanged(OH_AVCodec *codec, OH_AVFormat *fmt, void *userData)
45 {
46     cout << "stream Changed" << endl;
47 };
48 
onNeedInputData(OH_AVCodec * codec,uint32_t index,OH_AVMemory * data,void * userData)49 void onNeedInputData(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData)
50 {
51     VEncSignal *signal = static_cast<VEncSignal *>(userData);
52     if (signal == nullptr) {
53         return;
54     }
55     unique_lock<mutex> lock(signal->inMutex_);
56     signal->inIdxQueue_.push(index);
57     signal->inBufferQueue_.push(data);
58     signal->inCond_.notify_all();
59     cout << "need input data" << endl;
60 };
61 
onNewOutputData(OH_AVCodec * codec,uint32_t index,OH_AVMemory * data,OH_AVCodecBufferAttr * attr,void * userData)62 void onNewOutputData(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, OH_AVCodecBufferAttr *attr, void *userData)
63 {
64     cout << "output data" << endl;
65     VEncSignal *signal = static_cast<VEncSignal *>(userData);
66     if (signal == nullptr) {
67         return;
68     }
69     unique_lock<mutex> lock(signal->outMutex_);
70     signal->outIdxQueue_.push(index);
71     signal->attrQueue_.push(*attr);
72     signal->outBufferQueue_.push(data);
73     signal->outCond_.notify_all();
74 };
75 } // namespace
76 
77 namespace OHOS {
78 namespace Media {
79 class HwEncApiNdkTest : public testing::Test {
80 public:
81     // SetUpTestCase: Called before all test cases
82     static void SetUpTestCase(void);
83     // TearDownTestCase: Called after all test case
84     static void TearDownTestCase(void);
85     // SetUp: Called before each test cases
86     void SetUp(void);
87     // TearDown: Called after each test cases
88     void TearDown(void);
89 };
90 
SetUpTestCase()91 void HwEncApiNdkTest::SetUpTestCase()
92 {
93     cap = OH_AVCodec_GetCapabilityByCategory(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true, HARDWARE);
94     const char *TMP_CODEC_NAME = OH_AVCapability_GetName(cap);
95     if (memcpy_s(g_codecName, sizeof(g_codecName), TMP_CODEC_NAME, strlen(TMP_CODEC_NAME)) != 0) {
96         cout << "memcpy failed" << endl;
97     }
98     cout << "codecname: " << g_codecName << endl;
99 }
TearDownTestCase()100 void HwEncApiNdkTest::TearDownTestCase() {}
SetUp()101 void HwEncApiNdkTest::SetUp()
102 {
103     signal_ = new VEncSignal();
104 }
TearDown()105 void HwEncApiNdkTest::TearDown()
106 {
107     if (format != nullptr) {
108         OH_AVFormat_Destroy(format);
109         format = nullptr;
110     }
111     if (venc_ != NULL) {
112         OH_VideoEncoder_Destroy(venc_);
113         venc_ = nullptr;
114     }
115     if (signal_) {
116         delete signal_;
117         signal_ = nullptr;
118     }
119 }
120 } // namespace Media
121 } // namespace OHOS
122 
123 namespace {
124 /**
125  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_0100
126  * @tc.name      : OH_VideoEncoder_CreateByMime para1 error
127  * @tc.desc      : api test
128  */
129 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_0100, TestSize.Level2)
130 {
131     venc_ = OH_VideoEncoder_CreateByMime(nullptr);
132     ASSERT_EQ(nullptr, venc_);
133 }
134 
135 /**
136  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_0200
137  * @tc.name      : OH_VideoEncoder_CreateByMime para2 error
138  * @tc.desc      : api test
139  */
140 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_0200, TestSize.Level2)
141 {
142     venc_ = OH_VideoEncoder_CreateByMime("");
143     ASSERT_EQ(nullptr, venc_);
144 }
145 
146 /**
147  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_0300
148  * @tc.name      : OH_VideoEncoder_CreateByMime para error
149  * @tc.desc      : api test
150  */
151 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_0300, TestSize.Level2)
152 {
153     venc_ = OH_VideoEncoder_CreateByName(nullptr);
154     ASSERT_EQ(nullptr, venc_);
155 }
156 
157 /**
158  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_0400
159  * @tc.name      : OH_VideoEncoder_CreateByMime para error
160  * @tc.desc      : api test
161  */
162 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_0400, TestSize.Level2)
163 {
164     venc_ = OH_VideoEncoder_CreateByName("");
165     ASSERT_EQ(nullptr, venc_);
166 }
167 
168 /**
169  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_0500
170  * @tc.name      : OH_VideoEncoder_CreateByMime para error
171  * @tc.desc      : api test
172  */
173 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_0500, TestSize.Level2)
174 {
175     OH_AVErrCode ret = AV_ERR_OK;
176     ret = OH_VideoEncoder_Destroy(nullptr);
177     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
178 }
179 
180 /**
181  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_0600
182  * @tc.name      : OH_VideoEncoder_SetCallback para error
183  * @tc.desc      : api test
184  */
185 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_0600, TestSize.Level2)
186 {
187     OH_AVCodecAsyncCallback cb_;
188     cb_.onError = onError;
189     cb_.onStreamChanged = onStreamChanged;
190     cb_.onNeedInputData = onNeedInputData;
191     cb_.onNeedOutputData = onNewOutputData;
192 
193     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoEncoder_SetCallback(NULL, cb_, static_cast<void *>(signal_)));
194 }
195 
196 /**
197  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_0700
198  * @tc.name      : OH_VideoEncoder_SetCallback para error
199  * @tc.desc      : api test
200  */
201 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_0700, TestSize.Level2)
202 {
203     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
204     ASSERT_NE(NULL, venc_);
205 
206     OH_AVCodecAsyncCallback cb2_;
207     cb2_.onError = NULL;
208     cb2_.onStreamChanged = NULL;
209     cb2_.onNeedInputData = NULL;
210     cb2_.onNeedOutputData = NULL;
211     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_SetCallback(venc_, cb2_, static_cast<void *>(signal_)));
212 }
213 
214 /**
215  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_0800
216  * @tc.name      : OH_VideoEncoder_SetCallback para error
217  * @tc.desc      : api test
218  */
219 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_0800, TestSize.Level2)
220 {
221     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
222     OH_AVCodecAsyncCallback cb_;
223     cb_.onError = onError;
224     cb_.onStreamChanged = onStreamChanged;
225     cb_.onNeedInputData = onNeedInputData;
226     cb_.onNeedOutputData = onNewOutputData;
227     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_SetCallback(venc_, cb_, NULL));
228 }
229 
230 /**
231  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_0900
232  * @tc.name      : OH_VideoEncoder_Configure para error
233  * @tc.desc      : api test
234  */
235 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_0900, TestSize.Level2)
236 {
237     OH_AVErrCode ret = AV_ERR_OK;
238     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
239     ASSERT_NE(nullptr, venc_);
240     ret = OH_VideoEncoder_Configure(venc_, nullptr);
241     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
242 }
243 
244 /**
245  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_1100
246  * @tc.name      : OH_VideoEncoder_Configure para not enough
247  * @tc.desc      : api test
248  */
249 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_1100, TestSize.Level2)
250 {
251     OH_AVErrCode ret = AV_ERR_OK;
252     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
253     ASSERT_NE(nullptr, venc_);
254     format = OH_AVFormat_Create();
255     ASSERT_NE(nullptr, format);
256     OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITRATE, 100000);
257     ret = OH_VideoEncoder_Configure(venc_, format);
258     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
259 }
260 
261 /**
262  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_1400
263  * @tc.name      : OH_VideoEncoder_Start para error
264  * @tc.desc      : api test
265  */
266 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_1400, TestSize.Level2)
267 {
268     OH_AVErrCode ret = AV_ERR_OK;
269     ret = OH_VideoEncoder_Start(nullptr);
270     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
271 }
272 
273 /**
274  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_1500
275  * @tc.name      : OH_VideoEncoder_Stop para error
276  * @tc.desc      : api test
277  */
278 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_1500, TestSize.Level2)
279 {
280     OH_AVErrCode ret = AV_ERR_OK;
281     ret = OH_VideoEncoder_Stop(nullptr);
282     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
283 }
284 
285 /**
286  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_1600
287  * @tc.name      : OH_VideoEncoder_Flush para error
288  * @tc.desc      : api test
289  */
290 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_1600, TestSize.Level2)
291 {
292     OH_AVErrCode ret = AV_ERR_OK;
293     ret = OH_VideoEncoder_Flush(nullptr);
294     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
295 }
296 
297 /**
298  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_1700
299  * @tc.name      : OH_VideoEncoder_Reset para error
300  * @tc.desc      : api test
301  */
302 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_1700, TestSize.Level2)
303 {
304     OH_AVErrCode ret = AV_ERR_OK;
305     ret = OH_VideoEncoder_Reset(nullptr);
306     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
307 }
308 
309 /**
310  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_1800
311  * @tc.name      : OH_VideoEncoder_Reset para error
312  * @tc.desc      : api test
313  */
314 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_1800, TestSize.Level2)
315 {
316     format = OH_VideoEncoder_GetOutputDescription(nullptr);
317     ASSERT_EQ(format, nullptr);
318 }
319 
320 /**
321  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_1900
322  * @tc.name      : OH_VideoEncoder_SetParameter para error
323  * @tc.desc      : api test
324  */
325 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_1900, TestSize.Level2)
326 {
327     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
328     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoEncoder_SetParameter(venc_, nullptr));
329 }
330 
331 /**
332  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_2000
333  * @tc.name      : OH_VideoEncoder_SetParameter para error
334  * @tc.desc      : api test
335  */
336 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_2000, TestSize.Level2)
337 {
338     format = OH_AVFormat_Create();
339     ASSERT_NE(NULL, format);
340     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
341     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoEncoder_SetParameter(NULL, format));
342 }
343 
344 /**
345  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_2100
346  * @tc.name      : OH_VideoEncoder_GetSurface para error
347  * @tc.desc      : api test
348  */
349 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_2100, TestSize.Level2)
350 {
351     OH_AVErrCode ret = AV_ERR_OK;
352     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
353     ASSERT_NE(nullptr, venc_);
354     ret = OH_VideoEncoder_GetSurface(venc_, nullptr);
355     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
356 }
357 
358 /**
359  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_2200
360  * @tc.name      : OH_VideoEncoder_FreeOutputData para error
361  * @tc.desc      : api test
362  */
363 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_2200, TestSize.Level2)
364 {
365     OH_AVErrCode ret = AV_ERR_OK;
366     ret = OH_VideoEncoder_FreeOutputData(nullptr, 0);
367     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
368 }
369 
370 /**
371  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_2300
372  * @tc.name      : OH_VideoEncoder_FreeOutputData para error
373  * @tc.desc      : api test
374  */
375 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_2300, TestSize.Level2)
376 {
377     OH_AVErrCode ret = AV_ERR_OK;
378     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
379     ASSERT_NE(nullptr, venc_);
380     format = OH_AVFormat_Create();
381     ASSERT_NE(nullptr, format);
382     OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
383     OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_HEIGHT);
384     OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
385 
386     ret = OH_VideoEncoder_Configure(venc_, format);
387     ASSERT_EQ(ret, AV_ERR_OK);
388     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Start(venc_));
389     usleep(1000000);
390     ret = OH_VideoEncoder_FreeOutputData(venc_, 9999999);
391     ASSERT_EQ(ret, AV_ERR_INVALID_STATE);
392 }
393 
394 /**
395  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_2400
396  * @tc.name      : OH_VideoEncoder_NotifyEndOfStream para error
397  * @tc.desc      : api test
398  */
399 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_2400, TestSize.Level2)
400 {
401     OH_AVErrCode ret = AV_ERR_OK;
402     ret = OH_VideoEncoder_NotifyEndOfStream(nullptr);
403     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
404 }
405 /**
406  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_2500
407  * @tc.name      : OH_VideoEncoder_NotifyEndOfStream para error
408  * @tc.desc      : api test
409  */
410 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_2500, TestSize.Level2)
411 {
412     OH_AVErrCode ret = AV_ERR_OK;
413     ret = OH_VideoEncoder_NotifyEndOfStream(nullptr);
414     ASSERT_EQ(ret, AV_ERR_INVALID_VAL);
415 }
416 
417 /**
418  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_2600
419  * @tc.name      : OH_VideoEncoder_PushInputData para error
420  * @tc.desc      : api test
421  */
422 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_2600, TestSize.Level2)
423 {
424     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
425     ASSERT_NE(nullptr, venc_);
426     OH_AVCodecBufferAttr attr;
427     attr.pts = -1;
428     attr.size = -1;
429     attr.offset = 0;
430     attr.flags = AVCODEC_BUFFER_FLAGS_EOS;
431 
432     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoEncoder_PushInputData(venc_, 0, attr));
433 }
434 
435 /**
436  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_2700
437  * @tc.name      : OH_VideoEncoder_PushInputData para error
438  * @tc.desc      : api test
439  */
440 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_2700, TestSize.Level2)
441 {
442     OH_AVCodecBufferAttr attr;
443     attr.pts = 0;
444     attr.size = 0;
445     attr.offset = 0;
446     attr.flags = AVCODEC_BUFFER_FLAGS_EOS;
447     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoEncoder_PushInputData(NULL, 0, attr));
448 }
449 
450 /**
451  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_2800
452  * @tc.name      : OH_VideoEncoder_PushInputData para error
453  * @tc.desc      : api test
454  */
455 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_2800, TestSize.Level2)
456 {
457     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
458     ASSERT_NE(nullptr, venc_);
459     OH_AVCodecBufferAttr attr;
460     attr.pts = 0;
461     attr.size = 0;
462     attr.offset = 0;
463     attr.flags = AVCODEC_BUFFER_FLAGS_EOS;
464     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoEncoder_PushInputData(NULL, 99999, attr));
465 }
466 
467 /**
468  * @tc.number    : VIDEO_ENCODE_ILLEGAL_PARA_2900
469  * @tc.name      : OH_VideoEncoder_GetInputDescription para error
470  * * @tc.desc      : api test
471  */
472 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_ILLEGAL_PARA_2900, TestSize.Level2)
473 {
474     ASSERT_EQ(nullptr, OH_VideoEncoder_GetInputDescription(nullptr));
475 }
476 
477 /**
478  * @tc.number    : VIDEO_ENCODE_API_0100
479  * @tc.name      : create create
480  * @tc.desc      : function test
481  */
482 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_0100, TestSize.Level2)
483 {
484     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
485     ASSERT_NE(venc_, NULL);
486     OH_AVCodec *venc_2 = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
487     ASSERT_NE(venc_2, NULL);
488     OH_VideoEncoder_Destroy(venc_2);
489     venc_2 = nullptr;
490 }
491 
492 /**
493  * @tc.number    : VIDEO_ENCODE_API_3100
494  * @tc.name      : create create
495  * @tc.desc      : function test
496  */
497 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_3100, TestSize.Level2)
498 {
499     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
500     ASSERT_NE(venc_, NULL);
501     OH_AVCodec *venc_2 = OH_VideoEncoder_CreateByName(g_codecName);
502     ASSERT_NE(venc_2, NULL);
503     OH_VideoEncoder_Destroy(venc_2);
504     venc_2 = nullptr;
505 }
506 
507 /**
508  * @tc.number    : VIDEO_ENCODE_API_0200
509  * @tc.name      : create configure configure
510  * @tc.desc      : function test
511  */
512 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_0200, TestSize.Level2)
513 {
514     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
515     ASSERT_NE(NULL, venc_);
516 
517     format = OH_AVFormat_Create();
518     ASSERT_NE(NULL, format);
519 
520     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
521     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
522     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
523 
524     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Configure(venc_, format));
525     ASSERT_EQ(AV_ERR_INVALID_STATE, OH_VideoEncoder_Configure(venc_, format));
526 }
527 
528 /**
529  * @tc.number    : VIDEO_ENCODE_API_0300
530  * @tc.name      : create configure start start
531  * @tc.desc      : function test
532  */
533 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_0300, TestSize.Level2)
534 {
535     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
536     ASSERT_NE(NULL, venc_);
537 
538     format = OH_AVFormat_Create();
539     ASSERT_NE(NULL, format);
540 
541     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
542     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
543     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
544     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Configure(venc_, format));
545     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Start(venc_));
546     ASSERT_EQ(AV_ERR_INVALID_STATE, OH_VideoEncoder_Start(venc_));
547 }
548 
549 /**
550  * @tc.number    : VIDEO_ENCODE_API_0400
551  * @tc.name      : create configure start stop stop
552  * @tc.desc      : function test
553  */
554 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_0400, TestSize.Level2)
555 {
556     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
557     ASSERT_NE(NULL, venc_);
558 
559     format = OH_AVFormat_Create();
560     ASSERT_NE(NULL, format);
561 
562     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
563     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
564     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
565 
566     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Configure(venc_, format));
567     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Start(venc_));
568     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Stop(venc_));
569     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Stop(venc_));
570 }
571 
572 /**
573  * @tc.number    : VIDEO_ENCODE_API_0500
574  * @tc.name      : create configure start stop reset reset
575  * @tc.desc      : function test
576  */
577 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_0500, TestSize.Level2)
578 {
579     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
580     ASSERT_NE(NULL, venc_);
581 
582     format = OH_AVFormat_Create();
583     ASSERT_NE(NULL, format);
584     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
585     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
586     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
587 
588     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Configure(venc_, format));
589     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Start(venc_));
590     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Stop(venc_));
591     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Reset(venc_));
592     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Reset(venc_));
593 }
594 
595 /**
596  * @tc.number    : VIDEO_ENCODE_API_0600
597  * @tc.name      : create configure start EOS EOS
598  * @tc.desc      : function test
599  */
600 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_0600, TestSize.Level2)
601 {
602     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
603     ASSERT_NE(NULL, venc_);
604     format = OH_AVFormat_Create();
605     ASSERT_NE(NULL, format);
606     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
607     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
608     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
609     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Configure(venc_, format));
610     OH_AVCodecAsyncCallback cb_;
611     cb_.onError = onError;
612     cb_.onStreamChanged = onStreamChanged;
613     cb_.onNeedInputData = onNeedInputData;
614     cb_.onNeedOutputData = onNewOutputData;
615     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_SetCallback(venc_, cb_, static_cast<void *>(signal_)));
616 
617     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Start(venc_));
618     unique_lock<mutex> lock(signal_->inMutex_);
__anonc0ba47050302null619     signal_->inCond_.wait(lock, [] { return signal_->inIdxQueue_.size() > 1; });
620     uint32_t index = signal_->inIdxQueue_.front();
621     OH_AVCodecBufferAttr attr;
622     attr.pts = 0;
623     attr.size = 0;
624     attr.offset = 0;
625     attr.flags = AVCODEC_BUFFER_FLAGS_EOS;
626 
627     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_PushInputData(venc_, index, attr));
628     signal_->inIdxQueue_.pop();
629     index = signal_->inIdxQueue_.front();
630     ASSERT_EQ(AV_ERR_INVALID_STATE, OH_VideoEncoder_PushInputData(venc_, index, attr));
631     signal_->inIdxQueue_.pop();
632 }
633 
634 /**
635  * @tc.number    : VIDEO_ENCODE_API_0700
636  * @tc.name      : create configure start flush flush
637  * @tc.desc      : function test
638  */
639 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_0700, TestSize.Level2)
640 {
641     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
642     ASSERT_NE(NULL, venc_);
643     format = OH_AVFormat_Create();
644     ASSERT_NE(NULL, format);
645     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
646     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
647     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
648     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Configure(venc_, format));
649     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Start(venc_));
650     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Flush(venc_));
651     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Flush(venc_));
652 }
653 
654 /**
655  * @tc.number    : VIDEO_ENCODE_API_0800
656  * @tc.name      : create configure start stop release release
657  * @tc.desc      : function test
658  */
659 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_0800, TestSize.Level2)
660 {
661     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
662     ASSERT_NE(NULL, venc_);
663 
664     format = OH_AVFormat_Create();
665     ASSERT_NE(NULL, format);
666 
667     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
668     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
669     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
670 
671     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Configure(venc_, format));
672     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Start(venc_));
673     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Stop(venc_));
674     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Destroy(venc_));
675     venc_ = nullptr;
676     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoEncoder_Destroy(venc_));
677 }
678 
679 /**
680  * @tc.number    : VIDEO_ENCODE_API_0900
681  * @tc.name      : create create
682  * @tc.desc      : function test
683  */
684 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_0900, TestSize.Level2)
685 {
686     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
687     ASSERT_NE(venc_, NULL);
688     OH_AVCodec *venc_2 = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
689     ASSERT_NE(venc_2, NULL);
690     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Destroy(venc_2));
691     venc_2 = nullptr;
692 }
693 
694 /**
695  * @tc.number    : VIDEO_ENCODE_API_1000
696  * @tc.name      : repeat OH_VideoEncoder_SetCallback
697  * @tc.desc      : function test
698  */
699 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_1000, TestSize.Level2)
700 {
701     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
702     ASSERT_NE(venc_, NULL);
703     OH_AVCodecAsyncCallback cb_;
704     cb_.onError = onError;
705     cb_.onStreamChanged = onStreamChanged;
706     cb_.onNeedInputData = onNeedInputData;
707     cb_.onNeedOutputData = onNewOutputData;
708     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_SetCallback(venc_, cb_, NULL));
709     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_SetCallback(venc_, cb_, NULL));
710 }
711 
712 /**
713  * @tc.number    : VIDEO_ENCODE_API_1100
714  * @tc.name      : repeat OH_VideoEncoder_GetOutputDescription
715  * @tc.desc      : function test
716  */
717 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_1100, TestSize.Level2)
718 {
719     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
720     ASSERT_NE(venc_, NULL);
721     format = OH_VideoEncoder_GetOutputDescription(venc_);
722     ASSERT_NE(NULL, format);
723     OH_AVFormat_Destroy(format);
724     format = OH_VideoEncoder_GetOutputDescription(venc_);
725     ASSERT_NE(NULL, format);
726 }
727 
728 /**
729  * @tc.number    : VIDEO_ENCODE_API_1200
730  * @tc.name      : repeat OH_VideoEncoder_SetParameter
731  * @tc.desc      : function test
732  */
733 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_1200, TestSize.Level2)
734 {
735     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
736     ASSERT_NE(NULL, venc_);
737 
738     format = OH_AVFormat_Create();
739     ASSERT_NE(NULL, format);
740 
741     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
742     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
743     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_NV12);
744 
745     ASSERT_EQ(AV_ERR_INVALID_STATE, OH_VideoEncoder_SetParameter(venc_, format));
746     ASSERT_EQ(AV_ERR_INVALID_STATE, OH_VideoEncoder_SetParameter(venc_, format));
747 }
748 
749 /**
750  * @tc.number    : VIDEO_ENCODE_API_1200
751  * @tc.name      : repeat OH_VideoEncoder_GetInputDescription
752  * @tc.desc      : function test
753  */
754 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_1300, TestSize.Level2)
755 {
756     venc_ = OH_VideoEncoder_CreateByName(g_codecName);
757     ASSERT_NE(NULL, venc_);
758     format = OH_VideoEncoder_GetInputDescription(venc_);
759     ASSERT_NE(NULL, format);
760     OH_AVFormat_Destroy(format);
761     format = OH_VideoEncoder_GetInputDescription(venc_);
762     ASSERT_NE(NULL, format);
763 }
764 
765 /**
766  * @tc.number    : VIDEO_ENCODE_API_1400
767  * @tc.name      : set quality with illegal value
768  * @tc.desc      : function test
769  */
770 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_1400, TestSize.Level2)
771 {
772     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
773     ASSERT_NE(nullptr, venc_);
774     format = OH_AVFormat_Create();
775     ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, CQ));
776     ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_QUALITY, 101));
777     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
778     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
779     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
780     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoEncoder_Configure(venc_, format));
781 }
782 
783 /**
784  * @tc.number    : VIDEO_ENCODE_API_1410
785  * @tc.name      : set quality with illegal value
786  * @tc.desc      : function test
787  */
788 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_API_1410, TestSize.Level2)
789 {
790     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
791     ASSERT_NE(nullptr, venc_);
792     format = OH_AVFormat_Create();
793     ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, CQ));
794     ASSERT_EQ(true, OH_AVFormat_SetIntValue(format, OH_MD_KEY_QUALITY, -1));
795     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
796     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
797     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
798     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoEncoder_Configure(venc_, format));
799 }
800 
801 /**
802  * @tc.number    : VIDEO_ENCODE_SYNC_API_0010
803  * @tc.name      : QueryInputBuffer OH_AVCodec is nullptr
804  * @tc.desc      : api test
805  */
806 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_SYNC_API_0010, TestSize.Level2)
807 {
808     uint32_t index;
809     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoEncoder_QueryInputBuffer(nullptr, &index, -1));
810 }
811 
812 /**
813  * @tc.number    : VIDEO_ENCODE_SYNC_API_0020
814  * @tc.name      : QueryInputBuffer timeoutUs is INT64_MAX
815  * @tc.desc      : api test
816  */
817 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_SYNC_API_0020, TestSize.Level2)
818 {
819     uint32_t index;
820     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
821     ASSERT_NE(nullptr, venc_);
822     format = OH_AVFormat_Create();
823     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
824     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
825     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
826     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 1);
827     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Configure(venc_, format));
828     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Prepare(venc_));
829     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Start(venc_));
830     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_QueryInputBuffer(venc_, &index, INT64_MAX));
831 }
832 
833 /**
834  * @tc.number    : VIDEO_ENCODE_SYNC_API_0030
835  * @tc.name      : QueryInputBuffer timeoutUs is INT64_MIN
836  * @tc.desc      : api test
837  */
838 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_SYNC_API_0030, TestSize.Level2)
839 {
840     uint32_t index;
841     venc_ = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC);
842     ASSERT_NE(nullptr, venc_);
843     format = OH_AVFormat_Create();
844     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
845     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT);
846     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420);
847     (void)OH_AVFormat_SetIntValue(format, OH_MD_KEY_ENABLE_SYNC_MODE, 1);
848     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Configure(venc_, format));
849     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Prepare(venc_));
850     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_Start(venc_));
851     ASSERT_EQ(AV_ERR_OK, OH_VideoEncoder_QueryInputBuffer(venc_, &index, INT64_MIN));
852 }
853 
854 /**
855  * @tc.number    : VIDEO_ENCODE_SYNC_API_0040
856  * @tc.name      : GetInputBuffer OH_AVCodec is nullptr
857  * @tc.desc      : api test
858  */
859 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_SYNC_API_0040, TestSize.Level2)
860 {
861     ASSERT_EQ(nullptr, OH_VideoEncoder_GetInputBuffer(nullptr, 1));
862 }
863 
864 /**
865  * @tc.number    : VIDEO_ENCODE_SYNC_API_0050
866  * @tc.name      : QueryOutputBuffer OH_AVCodec is nullptr
867  * @tc.desc      : api test
868  */
869 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_SYNC_API_0050, TestSize.Level2)
870 {
871     uint32_t index;
872     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_VideoEncoder_QueryOutputBuffer(nullptr, &index, -1));
873 }
874 
875 /**
876  * @tc.number    : VIDEO_ENCODE_SYNC_API_0060
877  * @tc.name      : QueryOutputBuffer timeoutUs is INT64_MAX
878  * @tc.desc      : api test
879  */
880 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_SYNC_API_0060, TestSize.Level2)
881 {
882     if (cap != nullptr) {
883         auto vEncSample = make_unique<VEncAPI11Sample>();
884         vEncSample->INP_DIR = "/data/test/media/1280_720_nv.yuv";
885         vEncSample->enbleSyncMode = 1;
886         vEncSample->syncOutputWaitTime = INT64_MAX;
887         ASSERT_EQ(AV_ERR_OK, vEncSample->CreateVideoEncoder(g_codecName));
888         ASSERT_EQ(AV_ERR_OK, vEncSample->ConfigureVideoEncoder());
889         ASSERT_EQ(AV_ERR_OK, vEncSample->StartVideoEncoder());
890         vEncSample->WaitForEOS();
891         ASSERT_EQ(AV_ERR_OK, vEncSample->errCount);
892     }
893 }
894 
895 /**
896  * @tc.number    : VIDEO_ENCODE_SYNC_API_0070
897  * @tc.name      : QueryOutputBuffer timeoutUs is INT64_MIN
898  * @tc.desc      : api test
899  */
900 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_SYNC_API_0070, TestSize.Level2)
901 {
902     if (cap != nullptr) {
903         auto vEncSample = make_unique<VEncAPI11Sample>();
904         vEncSample->INP_DIR = "/data/test/media/1280_720_nv.yuv";
905         vEncSample->enbleSyncMode = 1;
906         vEncSample->syncOutputWaitTime = INT64_MIN;
907         ASSERT_EQ(AV_ERR_OK, vEncSample->CreateVideoEncoder(g_codecName));
908         ASSERT_EQ(AV_ERR_OK, vEncSample->ConfigureVideoEncoder());
909         ASSERT_EQ(AV_ERR_OK, vEncSample->StartVideoEncoder());
910         vEncSample->WaitForEOS();
911         ASSERT_EQ(AV_ERR_OK, vEncSample->errCount);
912     }
913 }
914 
915 /**
916  * @tc.number    : VIDEO_ENCODE_SYNC_API_0080
917  * @tc.name      : GetOutputBuffer OH_AVCodec is nullptr
918  * @tc.desc      : api test
919  */
920 HWTEST_F(HwEncApiNdkTest, VIDEO_ENCODE_SYNC_API_0080, TestSize.Level2)
921 {
922     ASSERT_EQ(nullptr, OH_VideoEncoder_GetOutputBuffer(nullptr, 1));
923 }
924 } // namespace