• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 <gtest/gtest.h>
17 #include <osal_mem.h>
18 #include <securec.h>
19 #include <unistd.h>
20 #include "codec_callback_stub.h"
21 #include "hdf_log.h"
22 #include "icodec.h"
23 #include "share_mem.h"
24 
25 #define HDF_LOG_TAG codec_hdi_uinttest
26 
27 using namespace std;
28 using namespace testing::ext;
29 
30 namespace {
31 constexpr const char *TEST_SERVICE_NAME = "codec_hdi_service";
32 constexpr const int TEST_PACKET_BUFFER_SIZE = 4096;
33 constexpr const int TEST_FRAME_BUFFER_SIZE = (640 * 480 * 3 / 2);
34 constexpr const uint32_t QUEUE_TIME_OUT = 10;
35 constexpr const int CAPABILITY_COUNT = 9;
36 constexpr int32_t INT_TO_STR_LEN = 32;
37 constexpr int32_t ARRAY_TO_STR_LEN = 1000; // hcs array length
38 constexpr int32_t VIDEO_WIDHT = 640;
39 constexpr int32_t VIDEO_HEIGHT = 480;
40 struct ICodec *g_codecObj = nullptr;
41 ShareMemory g_inputBuffer;
42 ShareMemory g_outputBuffer;
43 CodecBuffer *g_inputInfoData = nullptr;
44 CodecBuffer *g_outputInfoData = nullptr;
45 CODEC_HANDLETYPE g_handle = NULL;
46 
47 typedef struct {
48     VideoCodecGopMode gopMode;
49     uint32_t gopLen;
50     int32_t gop;
51     int32_t viLen;
52 } HdiGopSetup;
53 
54 class CodecProxyTest : public testing::Test {
55 public:
SetUpTestCase()56     static void SetUpTestCase() {}
TearDownTestCase()57     static void TearDownTestCase() {}
SetUp()58     void SetUp() {}
TearDown()59     void TearDown() {}
60 };
61 
62 static char arrayStr[ARRAY_TO_STR_LEN];
GetArrayStr(int32_t * array,int32_t arrayLen,int32_t endValue)63 static char *GetArrayStr(int32_t *array, int32_t arrayLen, int32_t endValue)
64 {
65     int32_t len = 0;
66     int32_t totalLen = 0;
67     int32_t ret;
68     char value[INT_TO_STR_LEN];
69     ret = memset_s(arrayStr, sizeof(arrayStr), 0, sizeof(arrayStr));
70     if (ret != EOK) {
71         HDF_LOGE("%{public}s: memset_s arrayStr failed, error code: %{public}d", __func__, ret);
72         return arrayStr;
73     }
74     for (int32_t i = 0; i < arrayLen; i++) {
75         if (array[i] == endValue) {
76             break;
77         }
78         ret = memset_s(value, sizeof(value), 0, sizeof(value));
79         if (ret != EOK) {
80             HDF_LOGE("%{public}s: memset_s value failed, error code: %{public}d", __func__, ret);
81             return arrayStr;
82         }
83         ret = sprintf_s(value, sizeof(value) - 1, "0x0%X, ", array[i]);
84         if (ret < 0) {
85             HDF_LOGE("%{public}s: sprintf_s value failed, error code: %{public}d", __func__, ret);
86             return arrayStr;
87         }
88         len = strlen(value);
89         ret = memcpy_s(arrayStr + totalLen, len, value, len);
90         if (ret != EOK) {
91             HDF_LOGE("%{public}s: memcpy_s arrayStr failed, error code: %{public}d", __func__, ret);
92             return arrayStr;
93         }
94         totalLen += len;
95     }
96     return arrayStr;
97 }
98 
PrintCapability(CodecCapability * cap,int index)99 static void PrintCapability(CodecCapability *cap, int index)
100 {
101     int32_t mime = 0;
102     if (cap == NULL) {
103         HDF_LOGE("null capability!");
104         return;
105     }
106     mime = static_cast<int32_t>(cap->mime);
107     if (mime < 0) {
108         HDF_LOGE("print invalid capability!");
109         return;
110     }
111     HDF_LOGI("-------------------------- capability %{public}d ---------------------------", index + 1);
112     HDF_LOGI("mime:%{public}d", cap->mime);
113     HDF_LOGI("type:%{public}d", cap->type);
114     HDF_LOGI("name:%{public}s", cap->name);
115     HDF_LOGI("supportProfiles:%{public}s", GetArrayStr(cap->supportProfiles, PROFILE_NUM, INVALID_PROFILE));
116     HDF_LOGI("isSoftwareCodec:%{public}d", cap->isSoftwareCodec);
117     HDF_LOGI("processModeMask:0x0%{public}x", cap->processModeMask);
118     HDF_LOGI("capsMask:0x0%{public}x", cap->capsMask);
119     HDF_LOGI("allocateMask:0x0%{public}x", cap->allocateMask);
120     HDF_LOGI("inputBufferNum.min:%{public}d", cap->inputBufferNum.min);
121     HDF_LOGI("inputBufferNum.max:%{public}d", cap->inputBufferNum.max);
122     HDF_LOGI("outputBufferNum.min:%{public}d", cap->outputBufferNum.min);
123     HDF_LOGI("outputBufferNum.max:%{public}d", cap->outputBufferNum.max);
124     HDF_LOGI("bitRate.min:%{public}d", cap->bitRate.min);
125     HDF_LOGI("bitRate.max:%{public}d", cap->bitRate.max);
126     HDF_LOGI("inputBufferSize:%{public}d", cap->inputBufferSize);
127     HDF_LOGI("outputBufferSize:%{public}d", cap->outputBufferSize);
128     if (cap->mime < MEDIA_MIMETYPE_AUDIO_FIRST) {
129         HDF_LOGI("minSize.width:%{public}d", cap->port.video.minSize.width);
130         HDF_LOGI("minSize.height:%{public}d", cap->port.video.minSize.height);
131         HDF_LOGI("maxSize.width:%{public}d", cap->port.video.maxSize.width);
132         HDF_LOGI("maxSize.height:%{public}d", cap->port.video.maxSize.height);
133         HDF_LOGI("widthAlignment:%{public}d", cap->port.video.whAlignment.widthAlignment);
134         HDF_LOGI("heightAlignment:%{public}d", cap->port.video.whAlignment.heightAlignment);
135         HDF_LOGI("supportPixFmts:%{public}s", GetArrayStr(cap->port.video.supportPixFmts, PIX_FMT_NUM, 0));
136     } else {
137         HDF_LOGI(":%{public}s", GetArrayStr(cap->port.audio.sampleFormats, SAMPLE_FORMAT_NUM, 0));
138         HDF_LOGI(":%{public}s", GetArrayStr(cap->port.audio.sampleRate, SAMPLE_RATE_NUM, 0));
139         HDF_LOGI(":%{public}s", GetArrayStr(cap->port.audio.channelLayouts, CHANNEL_NUM, -1));
140     }
141     HDF_LOGI("-------------------------------------------------------------------");
142 }
143 
144 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetCodecObjTest_001, TestSize.Level1)
145 {
146     g_codecObj = HdiCodecGet(TEST_SERVICE_NAME);
147     ASSERT_TRUE(g_codecObj != nullptr);
148 }
149 
150 HWTEST_F(CodecProxyTest, HdfCodecHdiV1EnumerateCapabilityTest_001, TestSize.Level1)
151 {
152     int32_t ret = HDF_SUCCESS;
153     for (int index = 0; index < CAPABILITY_COUNT; index++) {
154         CodecCapability cap;
155         ret = g_codecObj->CodecEnumerateCapability(g_codecObj, index, &cap);
156         ASSERT_EQ(ret, HDF_SUCCESS);
157         PrintCapability(&cap, index);
158     }
159 }
160 
161 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetCapabilityTest_001, TestSize.Level1)
162 {
163     CodecCapability cap;
164     int32_t ret = g_codecObj->CodecGetCapability(g_codecObj, MEDIA_MIMETYPE_IMAGE_JPEG, VIDEO_DECODER, 0, &cap);
165     ASSERT_EQ(ret, HDF_SUCCESS);
166     PrintCapability(&cap, 0);
167 }
168 
169 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetCapabilityTest_002, TestSize.Level1)
170 {
171     CodecCapability cap;
172     int32_t ret = g_codecObj->CodecGetCapability(g_codecObj, MEDIA_MIMETYPE_VIDEO_HEVC, VIDEO_DECODER, 0, &cap);
173     ASSERT_EQ(ret, HDF_SUCCESS);
174     PrintCapability(&cap, 0);
175 }
176 
177 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetCapabilityTest_003, TestSize.Level1)
178 {
179     CodecCapability cap;
180     int32_t ret = g_codecObj->CodecGetCapability(g_codecObj, MEDIA_MIMETYPE_VIDEO_AVC, VIDEO_DECODER, 0, &cap);
181     ASSERT_EQ(ret, HDF_SUCCESS);
182     PrintCapability(&cap, 0);
183 }
184 
185 HWTEST_F(CodecProxyTest, HdfCodecHdiV1InitCodecTest_001, TestSize.Level1)
186 {
187     ASSERT_TRUE(g_codecObj != nullptr);
188     int32_t errorCode = g_codecObj->CodecInit(g_codecObj);
189     ASSERT_EQ(errorCode, HDF_SUCCESS);
190 }
191 
192 HWTEST_F(CodecProxyTest, HdfCodecHdiV1CreateCodecTest_001, TestSize.Level1)
193 {
194     const char* name = "codec.avc.hardware.encoder";
195     int32_t errorCode = g_codecObj->CodecCreate(g_codecObj, name, &g_handle);
196     ASSERT_EQ(errorCode, HDF_SUCCESS);
197     ASSERT_TRUE(g_handle != nullptr);
198 }
199 
200 HWTEST_F(CodecProxyTest, HdfCodecHdiV1CreateCodecByTypeTest_001, TestSize.Level1)
201 {
202     CodecType type = VIDEO_DECODER;
203     AvCodecMime mime = MEDIA_MIMETYPE_VIDEO_AVC;
204     int32_t errorCode = g_codecObj->CodecCreateByType(g_codecObj, type, mime, &g_handle);
205     ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
206 }
207 
208 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetPortModeTest_001, TestSize.Level1)
209 {
210     DirectionType direct = OUTPUT_TYPE;
211     AllocateBufferMode mode = ALLOCATE_INPUT_BUFFER_CODEC_PRESET;
212     BufferType type = BUFFER_TYPE_FD;
213     int32_t errorCode = g_codecObj->CodecSetPortMode(g_codecObj, g_handle, direct, mode, type);
214     ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
215 }
216 
217 HWTEST_F(CodecProxyTest, HdfCodecHdiV1GetPortModeTest_001, TestSize.Level1)
218 {
219     DirectionType direct = OUTPUT_TYPE;
220     AllocateBufferMode mode;
221     BufferType type;
222     int32_t errorCode = g_codecObj->CodecGetPortMode(g_codecObj, g_handle, direct, &mode, &type);
223     ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
224 }
225 
226 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetVideoWidthTest_001, TestSize.Level1)
227 {
228     Param *params;
229     int paramCnt = 1;
230     params = (Param *)OsalMemAlloc(sizeof(Param)*paramCnt);
231     ASSERT_TRUE(params != nullptr);
232     params->key = KEY_VIDEO_WIDTH;
233     int32_t width = VIDEO_WIDHT;
234     params->val = reinterpret_cast<void *>(&width);
235     params->size = sizeof(width);
236 
237     int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
238     OsalMemFree(params);
239     ASSERT_EQ(errorCode, HDF_SUCCESS);
240 }
241 
242 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetVideoHeightTest_001, TestSize.Level1)
243 {
244     Param *params;
245     int paramCnt = 1;
246     params = reinterpret_cast<Param *>(OsalMemAlloc(sizeof(Param)*paramCnt));
247     ASSERT_TRUE(params != nullptr);
248     params->key = KEY_VIDEO_HEIGHT;
249     int32_t height = VIDEO_HEIGHT;
250     params->val = reinterpret_cast<void *>(&height);
251     params->size = sizeof(height);
252 
253     int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
254     OsalMemFree(params);
255     ASSERT_EQ(errorCode, HDF_SUCCESS);
256 }
257 
258 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetCodecTypeTest_001, TestSize.Level1)
259 {
260     Param *params;
261     int paramCnt = 1;
262     params = reinterpret_cast<Param *>(OsalMemAlloc(sizeof(Param)*paramCnt));
263     ASSERT_TRUE(params != nullptr);
264     params->key = KEY_CODEC_TYPE;
265     CodecType type = VIDEO_DECODER;
266     params->val = reinterpret_cast<void *>(&type);
267     params->size = sizeof(type);
268 
269     int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
270     OsalMemFree(params);
271     ASSERT_EQ(errorCode, HDF_SUCCESS);
272 }
273 
274 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetGopModeTest_001, TestSize.Level1)
275 {
276     Param *params;
277     int paramCnt = 1;
278     params = reinterpret_cast<Param *>(OsalMemAlloc(sizeof(Param)*paramCnt));
279     ASSERT_TRUE(params != nullptr);
280 
281     HdiGopSetup gop;
282     gop.gopMode = VID_CODEC_GOPMODE_NORMALP;
283     gop.gopLen = 0;
284     gop.viLen = 0;
285     gop.gop = 48;
286     params->key = KEY_VIDEO_GOP_MODE;
287     params->val = reinterpret_cast<void *>(&gop);
288     params->size = sizeof(gop);
289 
290     int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
291     OsalMemFree(params);
292     ASSERT_EQ(errorCode, HDF_SUCCESS);
293 }
294 
295 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetMimeTypeTest_001, TestSize.Level1)
296 {
297     Param *params;
298     int paramCnt = 1;
299     params = reinterpret_cast<Param *>(OsalMemAlloc(sizeof(Param)*paramCnt));
300     ASSERT_TRUE(params != nullptr);
301     params->key = KEY_MIMETYPE;
302     AvCodecMime mime = MEDIA_MIMETYPE_IMAGE_JPEG;
303     params->val = reinterpret_cast<void *>(&mime);
304     params->size = sizeof(mime);
305 
306     int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
307     OsalMemFree(params);
308     ASSERT_EQ(errorCode, HDF_SUCCESS);
309 }
310 
311 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetPixelFormatTest_001, TestSize.Level1)
312 {
313     Param *params;
314     int paramCnt = 1;
315     params = reinterpret_cast<Param *>(OsalMemAlloc(sizeof(Param)*paramCnt));
316     ASSERT_TRUE(params != nullptr);
317     params->key = KEY_PIXEL_FORMAT;
318     PixelFormat format = PIXEL_FMT_YCBCR_420_SP;
319     params->val = (void *)&format;
320     params->size = sizeof(format);
321 
322     int32_t errorCode = g_codecObj->CodecSetParameter(g_codecObj, g_handle, params, paramCnt);
323     OsalMemFree(params);
324     ASSERT_EQ(errorCode, HDF_SUCCESS);
325 }
326 
327 HWTEST_F(CodecProxyTest, HdfCodecHdiV1QueueInputTest_001, TestSize.Level1)
328 {
329     g_inputBuffer.id = 0;
330     g_inputBuffer.size = TEST_PACKET_BUFFER_SIZE;
331     int32_t ret = CreateFdShareMemory(&g_inputBuffer);
332     ASSERT_EQ(ret, HDF_SUCCESS);
333 
334     g_inputInfoData =
335         reinterpret_cast<CodecBuffer *>(OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1));
336     ASSERT_TRUE(g_inputInfoData != nullptr);
337     g_inputInfoData->bufferId = 0;
338     g_inputInfoData->bufferCnt = 1;
339     g_inputInfoData->flag = 1;
340     g_inputInfoData->timeStamp = 1;
341     g_inputInfoData->buffer[0].type = BUFFER_TYPE_FD;
342     g_inputInfoData->buffer[0].offset = 1;
343     g_inputInfoData->buffer[0].length = 1;
344     g_inputInfoData->buffer[0].capacity = TEST_PACKET_BUFFER_SIZE;
345     g_inputInfoData->buffer[0].buf = (intptr_t)g_inputBuffer.fd;
346 
347     int32_t errorCode = g_codecObj->CodecQueueInput(g_codecObj, g_handle, g_inputInfoData,
348         static_cast<uint32_t>(QUEUE_TIME_OUT), -1);
349     ASSERT_EQ(errorCode, HDF_SUCCESS);
350 }
351 
352 HWTEST_F(CodecProxyTest, HdfCodecHdiV1DequeInputTest_001, TestSize.Level1)
353 {
354     int32_t acquireFd;
355     CodecBuffer *inputInfo =
356         reinterpret_cast<CodecBuffer *>(OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1));
357     ASSERT_TRUE(inputInfo != nullptr);
358     inputInfo->bufferCnt = 1;
359 
360     int32_t errorCode = g_codecObj->CodecDequeueInput(g_codecObj, g_handle, QUEUE_TIME_OUT, &acquireFd, inputInfo);
361     ASSERT_EQ(errorCode, HDF_SUCCESS);
362     ASSERT_EQ(inputInfo->bufferId, g_inputInfoData->bufferId);
363     ASSERT_EQ(inputInfo->bufferCnt, g_inputInfoData->bufferCnt);
364     ASSERT_EQ(inputInfo->buffer[0].type, g_inputInfoData->buffer[0].type);
365     ASSERT_EQ(inputInfo->buffer[0].offset, g_inputInfoData->buffer[0].offset);
366     ASSERT_EQ(inputInfo->buffer[0].length, g_inputInfoData->buffer[0].length);
367     ASSERT_EQ(inputInfo->buffer[0].capacity, g_inputInfoData->buffer[0].capacity);
368     OsalMemFree(inputInfo);
369     OsalMemFree(g_inputInfoData);
370 }
371 
372 HWTEST_F(CodecProxyTest, HdfCodecHdiV1StartCodecTest_001, TestSize.Level1)
373 {
374     int32_t  errorCode = g_codecObj->CodecStart(g_codecObj, g_handle);
375     ASSERT_EQ(errorCode, HDF_SUCCESS);
376 }
377 
378 HWTEST_F(CodecProxyTest, HdfCodecHdiV1StopCodecTest_001, TestSize.Level1)
379 {
380     int32_t errorCode = g_codecObj->CodecStop(g_codecObj, g_handle);
381     ASSERT_EQ(errorCode, HDF_SUCCESS);
382 }
383 
384 HWTEST_F(CodecProxyTest, HdfCodecHdiV1ResetCodecTest_001, TestSize.Level1)
385 {
386     int32_t errorCode = g_codecObj->CodecReset(g_codecObj, g_handle);
387     ASSERT_EQ(errorCode, HDF_ERR_NOT_SUPPORT);
388 }
389 
390 HWTEST_F(CodecProxyTest, HdfCodecHdiV1QueueOutputTest_001, TestSize.Level1)
391 {
392     g_outputBuffer.id = 1;
393     g_outputBuffer.size = TEST_FRAME_BUFFER_SIZE;
394     int32_t ret = CreateFdShareMemory(&g_outputBuffer);
395     ASSERT_EQ(ret, HDF_SUCCESS);
396 
397     g_outputInfoData =
398         reinterpret_cast<CodecBuffer *>(OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1));
399     ASSERT_TRUE(g_outputInfoData != nullptr);
400     g_outputInfoData->bufferId = 1;
401     g_outputInfoData->bufferCnt = 1;
402     g_outputInfoData->flag = 1;
403     g_outputInfoData->timeStamp = 1;
404     g_outputInfoData->buffer[0].type = BUFFER_TYPE_FD;
405     g_outputInfoData->buffer[0].offset = 1;
406     g_outputInfoData->buffer[0].length = 1;
407     g_outputInfoData->buffer[0].capacity = TEST_FRAME_BUFFER_SIZE;
408     g_outputInfoData->buffer[0].buf = (intptr_t)g_outputBuffer.fd;
409 
410     int32_t errorCode = g_codecObj->CodecQueueOutput(g_codecObj, g_handle,
411         g_outputInfoData, static_cast<uint32_t>(0), -1);
412     ASSERT_EQ(errorCode, HDF_SUCCESS);
413 }
414 
415 HWTEST_F(CodecProxyTest, HdfCodecHdiV1DequeueOutputTest_001, TestSize.Level1)
416 {
417     int32_t errorCode = 0;
418     int32_t acquireFd;
419     CodecBuffer *outInfo =
420         reinterpret_cast<CodecBuffer *>(OsalMemAlloc(sizeof(CodecBuffer) + sizeof(CodecBufferInfo) * 1));
421     ASSERT_TRUE(outInfo != nullptr);
422     outInfo->bufferCnt = 1;
423 
424     errorCode = g_codecObj->CodecDequeueOutput(g_codecObj, g_handle, QUEUE_TIME_OUT, &acquireFd, outInfo);
425     ASSERT_EQ(errorCode, HDF_SUCCESS);
426     ASSERT_EQ(outInfo->bufferId, g_outputInfoData->bufferId);
427     ASSERT_EQ(outInfo->bufferCnt, g_outputInfoData->bufferCnt);
428     ASSERT_EQ(outInfo->buffer[0].type, g_outputInfoData->buffer[0].type);
429     ASSERT_EQ(outInfo->buffer[0].offset, g_outputInfoData->buffer[0].offset);
430     ASSERT_EQ(outInfo->buffer[0].length, g_outputInfoData->buffer[0].length);
431     ASSERT_EQ(outInfo->buffer[0].capacity, g_outputInfoData->buffer[0].capacity);
432     OsalMemFree(outInfo);
433     OsalMemFree(g_outputInfoData);
434 }
435 
436 HWTEST_F(CodecProxyTest, HdfCodecHdiV1FlushTest_001, TestSize.Level1)
437 {
438     DirectionType directType = OUTPUT_TYPE;
439 
440     int32_t errorCode = g_codecObj->CodecFlush(g_codecObj, g_handle, directType);
441     ASSERT_EQ(errorCode, HDF_SUCCESS);
442     ASSERT_EQ(directType, OUTPUT_TYPE);
443 }
444 
445 HWTEST_F(CodecProxyTest, HdfCodecHdiV1FlushTest_002, TestSize.Level1)
446 {
447     DirectionType directType = INPUT_TYPE;
448 
449     int32_t errorCode = g_codecObj->CodecFlush(g_codecObj, g_handle, directType);
450     ASSERT_EQ(errorCode, HDF_SUCCESS);
451     ASSERT_EQ(directType, INPUT_TYPE);
452 }
453 
454 HWTEST_F(CodecProxyTest, HdfCodecHdiV1FlushTest_003, TestSize.Level1)
455 {
456     DirectionType directType = ALL_TYPE;
457 
458     int32_t errorCode = g_codecObj->CodecFlush(g_codecObj, g_handle, directType);
459     ASSERT_EQ(errorCode, HDF_SUCCESS);
460     ASSERT_EQ(directType, ALL_TYPE);
461 }
462 
463 HWTEST_F(CodecProxyTest, HdfCodecHdiV1SetCallbackTest_001, TestSize.Level1)
464 {
465     UINTPTR instance = 0;
466     CodecCallback callback;
467     struct CodecCallbackStub *stub = CodecCallbackStubObtain(&callback);
468     ASSERT_TRUE(stub != nullptr);
469 
470     int32_t errorCode = g_codecObj->CodecSetCallback(g_codecObj, g_handle, &stub->service, instance);
471     ASSERT_EQ(errorCode, HDF_SUCCESS);
472 }
473 
474 HWTEST_F(CodecProxyTest, HdfCodecHdiV1DestroyCodecTest_001, TestSize.Level1)
475 {
476     int32_t errorCode = g_codecObj->CodecDestroy(g_codecObj, g_handle);
477     ASSERT_EQ(errorCode, HDF_SUCCESS);
478 }
479 
480 HWTEST_F(CodecProxyTest, HdfCodecHdiV1DeinitTest_001, TestSize.Level1)
481 {
482     int32_t errorCode = g_codecObj->CodecDeinit(g_codecObj);
483     ASSERT_EQ(errorCode, HDF_SUCCESS);
484     HdiCodecRelease(g_codecObj);
485 }
486 }