1 /*
2 * Copyright (c) 2022 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 <OMX_Component.h>
17 #include <OMX_Core.h>
18 #include <OMX_Video.h>
19 #include <OMX_VideoExt.h>
20 #include <ashmem.h>
21 #include <buffer_handle.h>
22 #include <gtest/gtest.h>
23 #include <hdf_log.h>
24 #include <osal_mem.h>
25 #include <securec.h>
26 #include <servmgr_hdi.h>
27 #include "codec_callback_if.h"
28 #include "codec_component_manager.h"
29 #include "codec_component_type.h"
30 #include "codec_omx_ext.h"
31 #include "hdf_io_service_if.h"
32 #include "v1_0/display_composer_type.h"
33 #include "v1_0/display_buffer_type.h"
34 #include "v1_0/include/idisplay_buffer.h"
35 #define HDF_LOG_TAG codec_hdi_test
36
37 using namespace std;
38 using namespace testing::ext;
39 using namespace OHOS::HDI::Display::Buffer::V1_0;
40 using namespace OHOS::HDI::Display::Composer::V1_0;
41 namespace {
42 constexpr int32_t WIDTH = 640;
43 constexpr int32_t HEIGHT = 480;
44 #ifndef SUPPORT_OMX
45 constexpr uint32_t MAX_ROLE_INDEX = 1000;
46 constexpr int32_t ROLE_LEN = 240;
47 #endif
48 constexpr int32_t BUFFER_SIZE = WIDTH * HEIGHT * 3;
49 constexpr int32_t FRAMERATE = 30 << 16;
50 constexpr uint32_t BUFFER_ID_ERROR = 65000;
51 constexpr uint32_t WAIT_TIME = 1000;
52 constexpr uint32_t MAX_WAIT = 50;
53 static IDisplayBuffer *gralloc_ = nullptr;
54
InitCodecBuffer(OmxCodecBuffer & buffer,CodecBufferType type,OMX_VERSIONTYPE & version)55 static void InitCodecBuffer(OmxCodecBuffer& buffer, CodecBufferType type, OMX_VERSIONTYPE& version)
56 {
57 buffer.bufferType = type;
58 buffer.fenceFd = -1;
59 buffer.version = version;
60 buffer.allocLen = BUFFER_SIZE;
61 buffer.buffer = 0;
62 buffer.bufferLen = 0;
63 buffer.pts = 0;
64 buffer.flag = 0;
65 buffer.type = READ_WRITE_TYPE;
66 }
67
68 class CodecHdiOmxTest : public testing::Test {
69 public:
70 enum class PortIndex { PORT_INDEX_INPUT = 0, PORT_INDEX_OUTPUT = 1 };
71 struct BufferInfo {
72 std::shared_ptr<OmxCodecBuffer> omxBuffer;
73 std::shared_ptr<OHOS::Ashmem> sharedMem;
74 BufferHandle *bufferHandle;
BufferInfo__anon180145400111::CodecHdiOmxTest::BufferInfo75 BufferInfo()
76 {
77 omxBuffer = nullptr;
78 sharedMem = nullptr;
79 bufferHandle = nullptr;
80 }
~BufferInfo__anon180145400111::CodecHdiOmxTest::BufferInfo81 ~BufferInfo()
82 {
83 omxBuffer = nullptr;
84 if (sharedMem != nullptr) {
85 sharedMem->UnmapAshmem();
86 sharedMem->CloseAshmem();
87 sharedMem = nullptr;
88 }
89 if (bufferHandle != nullptr && gralloc_ != nullptr) {
90 gralloc_->FreeMem(*bufferHandle);
91 bufferHandle = nullptr;
92 }
93 }
94 };
95 template <typename T>
InitParam(T & param)96 void InitParam(T ¶m)
97 {
98 memset_s(¶m, sizeof(param), 0x0, sizeof(param));
99 param.nSize = sizeof(param);
100 param.nVersion = version_;
101 }
102
103 template <typename T>
InitExtParam(T & param)104 void InitExtParam(T ¶m)
105 {
106 memset_s(¶m, sizeof(param), 0x0, sizeof(param));
107 param.size = sizeof(param);
108 param.version = version_;
109 }
110
InitCodecBufferWithAshMem(enum PortIndex portIndex,int bufferSize,shared_ptr<OmxCodecBuffer> omxBuffer,shared_ptr<OHOS::Ashmem> sharedMem)111 void InitCodecBufferWithAshMem(enum PortIndex portIndex, int bufferSize, shared_ptr<OmxCodecBuffer> omxBuffer,
112 shared_ptr<OHOS::Ashmem> sharedMem)
113 {
114 omxBuffer->size = sizeof(OmxCodecBuffer);
115 omxBuffer->version = version_;
116 omxBuffer->bufferType = CODEC_BUFFER_TYPE_AVSHARE_MEM_FD;
117 omxBuffer->bufferLen = sizeof(int);
118 omxBuffer->buffer = (uint8_t *)(uintptr_t)sharedMem->GetAshmemFd();
119 omxBuffer->allocLen = bufferSize;
120 omxBuffer->fenceFd = -1;
121 omxBuffer->pts = 0;
122 omxBuffer->flag = 0;
123 if (portIndex == PortIndex::PORT_INDEX_INPUT) {
124 omxBuffer->type = READ_ONLY_TYPE;
125 sharedMem->MapReadAndWriteAshmem();
126 } else {
127 omxBuffer->type = READ_WRITE_TYPE;
128 sharedMem->MapReadOnlyAshmem();
129 }
130 }
131
UseBufferOnPort(enum PortIndex portIndex,int32_t bufferCount,int32_t bufferSize)132 bool UseBufferOnPort(enum PortIndex portIndex, int32_t bufferCount, int32_t bufferSize)
133 {
134 for (int i = 0; i < bufferCount; i++) {
135 std::shared_ptr<OmxCodecBuffer> omxBuffer = std::make_shared<OmxCodecBuffer>();
136 if (omxBuffer == nullptr) {
137 return false;
138 }
139
140 int fd = OHOS::AshmemCreate(0, bufferSize);
141 shared_ptr<OHOS::Ashmem> sharedMem = make_shared<OHOS::Ashmem>(fd, bufferSize);
142 if (sharedMem == nullptr) {
143 if (fd >= 0) {
144 close(fd);
145 fd = -1;
146 }
147 return false;
148 }
149 InitCodecBufferWithAshMem(portIndex, bufferSize, omxBuffer, sharedMem);
150 auto err = component_->UseBuffer(component_, (uint32_t)portIndex, omxBuffer.get());
151 if (err != HDF_SUCCESS) {
152 sharedMem->UnmapAshmem();
153 sharedMem->CloseAshmem();
154 sharedMem = nullptr;
155 omxBuffer = nullptr;
156 return false;
157 }
158 omxBuffer->bufferLen = 0;
159 std::shared_ptr<BufferInfo> bufferInfo = std::make_shared<BufferInfo>();
160 bufferInfo->omxBuffer = omxBuffer;
161 bufferInfo->sharedMem = sharedMem;
162 if (portIndex == PortIndex::PORT_INDEX_INPUT) {
163 inputBuffers_.emplace(std::make_pair(omxBuffer->bufferId, bufferInfo));
164 } else {
165 outputBuffers_.emplace(std::make_pair(omxBuffer->bufferId, bufferInfo));
166 }
167 }
168 return true;
169 }
170
FreeBufferOnPort(enum PortIndex portIndex)171 bool FreeBufferOnPort(enum PortIndex portIndex)
172 {
173 std::map<int32_t, std::shared_ptr<BufferInfo>> &buffer = inputBuffers_;
174 if (portIndex == PortIndex::PORT_INDEX_OUTPUT) {
175 buffer = outputBuffers_;
176 }
177 for (auto [bufferId, bufferInfo] : buffer) {
178 auto ret = component_->FreeBuffer(component_, (uint32_t)portIndex, bufferInfo->omxBuffer.get());
179 if (ret != HDF_SUCCESS) {
180 return false;
181 }
182 }
183 buffer.clear();
184 return true;
185 }
186
waitState(OMX_STATETYPE objState)187 void waitState(OMX_STATETYPE objState)
188 {
189 OMX_STATETYPE state = OMX_StateInvalid;
190 uint32_t count = 0;
191 do {
192 usleep(WAIT_TIME);
193 auto ret = component_->GetState(component_, &state);
194 ASSERT_EQ(ret, HDF_SUCCESS);
195 count++;
196 } while (state != objState && count <= MAX_WAIT);
197 }
198
InitBufferHandle(std::shared_ptr<OmxCodecBuffer> & omxBuffer,BufferHandle ** bufferHandle)199 void InitBufferHandle(std::shared_ptr<OmxCodecBuffer> &omxBuffer, BufferHandle **bufferHandle)
200 {
201 ASSERT_TRUE(gralloc_ != nullptr);
202 AllocInfo alloc = {.width = WIDTH,
203 .height = HEIGHT,
204 .usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA,
205 .format = PIXEL_FMT_YCBCR_420_SP};
206
207 auto err = gralloc_->AllocMem(alloc, *bufferHandle);
208 ASSERT_EQ(err, DISPLAY_SUCCESS);
209
210 omxBuffer->size = static_cast<uint32_t>(sizeof(OmxCodecBuffer));
211 omxBuffer->version = version_;
212 omxBuffer->bufferLen = static_cast<uint32_t>(sizeof(BufferHandle));
213 omxBuffer->buffer = reinterpret_cast<uint8_t *>(*bufferHandle);
214 omxBuffer->allocLen = static_cast<uint32_t>(sizeof(BufferHandle));
215 omxBuffer->fenceFd = -1;
216 omxBuffer->pts = 0;
217 omxBuffer->flag = 0;
218 }
SetUpTestCase()219 static void SetUpTestCase()
220 {
221 manager_ = GetCodecComponentManager();
222 gralloc_ = IDisplayBuffer::Get();
223 if (manager_ == nullptr) {
224 std::cout<<"GetCodecComponentManager ret nullptr"<<std::endl;
225 return;
226 }
227 auto count = manager_->GetComponentNum();
228 if (count > 0) {
229 CodecCompCapability *capList = (CodecCompCapability *)OsalMemAlloc(sizeof(CodecCompCapability) * count);
230 ASSERT_TRUE(capList != nullptr);
231 auto err = manager_->GetComponentCapabilityList(capList, count);
232 ASSERT_TRUE(err == HDF_SUCCESS);
233 compName_ = capList[0].compName;
234 OsalMemFree(capList);
235 capList = nullptr;
236 }
237 }
TearDownTestCase()238 static void TearDownTestCase()
239 {
240 CodecComponentManagerRelease();
241 manager_ = nullptr;
242 }
SetUp()243 void SetUp()
244 {
245 if (manager_ == nullptr) {
246 return;
247 }
248 callback_ = CodecCallbackTypeGet(nullptr);
249 if (callback_ == nullptr) {
250 return;
251 }
252 if (compName_.empty()) {
253 return;
254 }
255
256 auto ret = manager_->CreateComponent(&component_, &componentId_, compName_.data(),
257 reinterpret_cast<int64_t>(this), callback_);
258 if (ret != HDF_SUCCESS) {
259 return;
260 }
261 struct CompVerInfo verInfo;
262 ret = component_->GetComponentVersion(component_, &verInfo);
263 if (ret != HDF_SUCCESS) {
264 return;
265 }
266 version_ = verInfo.compVersion;
267 }
TearDown()268 void TearDown()
269 {
270 if (manager_ != nullptr && component_ != nullptr) {
271 manager_->DestroyComponent(componentId_);
272 }
273 if (callback_ != nullptr) {
274 CodecCallbackTypeRelease(callback_);
275 callback_ = nullptr;
276 }
277 }
278
279 public:
280 struct CodecComponentType *component_ = nullptr;
281 uint32_t componentId_ = 0;
282 struct CodecCallbackType *callback_ = nullptr;
283
284 static inline struct CodecComponentManager *manager_ = nullptr;
285 static inline std::string compName_ = "";
286 union OMX_VERSIONTYPE version_;
287 std::map<int32_t, std::shared_ptr<BufferInfo>> inputBuffers_;
288 std::map<int32_t, std::shared_ptr<BufferInfo>> outputBuffers_;
289 };
290 /**
291 * @tc.name HdfCodecHdiGetVersionTest_001
292 * @tc.number SUB_Driver_Codec_CodecHdi_0800
293 * @tc.desc Reads the version information of an open component
294 */
295 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_0800, Function | MediumTest | Level3)
296 {
297 ASSERT_TRUE(component_ != nullptr);
298 struct CompVerInfo verInfo;
299 auto ret = component_->GetComponentVersion(component_, &verInfo);
300 ASSERT_EQ(ret, HDF_SUCCESS);
301 }
302 /**
303 * @tc.name HdfCodecHdiGetVersionTest_002
304 * @tc.number SUB_Driver_Codec_CodecHdi_0900
305 * @tc.desc The input parameter is empty. GetComponentVersion is error.
306 */
307 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_0900, Function | MediumTest | Level3)
308 {
309 ASSERT_TRUE(component_ != nullptr);
310 auto ret = component_->GetComponentVersion(component_, nullptr);
311 ASSERT_NE(ret, HDF_SUCCESS);
312 }
313 #ifndef SUPPORT_OMX
314 /**
315 * @tc.name HdfCodecHdiGetParameterTest_003
316 * @tc.number SUB_Driver_Codec_CodecHdi_1000
317 * @tc.desc The input parameter structure pointer is null when the OMX_IndexParamVideoPortFormat parameter is read
318 */
319 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_1000, Function | MediumTest | Level3)
320 {
321 ASSERT_TRUE(component_ != nullptr);
322 CodecVideoPortFormatParam pixFormat;
323 InitExtParam(pixFormat);
324 pixFormat.portIndex = (uint32_t)PortIndex::PORT_INDEX_OUTPUT;
325 pixFormat.codecColorIndex = 0;
326 auto ret = component_->GetParameter(component_, OMX_IndexCodecVideoPortFormat,
327 reinterpret_cast<int8_t *>(&pixFormat), sizeof(pixFormat));
328 ASSERT_EQ(ret, HDF_SUCCESS);
329 }
330 /**
331 * @tc.name HdfCodecHdiGetParameterTest_004
332 * @tc.number SUB_Driver_Codec_CodecHdi_1100
333 * @tc.desc The OMX_IndexParamVideoPortFormat parameter of the input port of the component is normally read
334 */
335 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_1100, Function | MediumTest | Level3)
336 {
337 ASSERT_TRUE(component_ != nullptr);
338 CodecVideoPortFormatParam pixFormat;
339 InitExtParam(pixFormat);
340 pixFormat.portIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
341 pixFormat.codecColorIndex = 0;
342 auto ret = component_->GetParameter(component_, OMX_IndexCodecVideoPortFormat,
343 reinterpret_cast<int8_t *>(&pixFormat), sizeof(pixFormat));
344 ASSERT_EQ(ret, HDF_SUCCESS);
345 }
346 #endif
347 /**
348 * @tc.name HdfCodecHdiGetParameterTest_003
349 * @tc.number SUB_Driver_Codec_CodecHdi_1200
350 * @tc.desc The version information is not set for the input parameter. As a result, the parameter fails to be read
351 */
352 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_1200, Function | MediumTest | Level3)
353 {
354 ASSERT_TRUE(component_ != nullptr);
355 auto ret = component_->GetParameter(component_, OMX_IndexParamVideoPortFormat, nullptr, 0);
356 ASSERT_NE(ret, HDF_SUCCESS);
357 }
358 /**
359 * @tc.name HdfCodecHdiGetParameterTest_004
360 * @tc.number SUB_Driver_Codec_CodecHdi_1300
361 * @tc.desc The input parameter structure does not match the index. As a result, the parameter fails to be read
362 */
363 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_1300, Function | MediumTest | Level3)
364 {
365 ASSERT_TRUE(component_ != nullptr);
366 OMX_VIDEO_PARAM_PORTFORMATTYPE param;
367 InitParam(param);
368 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
369 param.eCompressionFormat = OMX_VIDEO_CodingAVC;
370 auto ret = component_->GetParameter(component_, OMX_IndexParamVideoPortFormat, reinterpret_cast<int8_t *>(¶m),
371 sizeof(param));
372 ASSERT_EQ(ret, HDF_SUCCESS);
373 }
374 /**
375 * @tc.name HdfCodecHdiGetParameterTest_005
376 * @tc.number SUB_Driver_Codec_CodecHdi_1400
377 * @tc.desc The input parameter index is not supported. As a result, the parameter fails to be read
378 */
379 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_1400, Function | MediumTest | Level3)
380 {
381 ASSERT_TRUE(component_ != nullptr);
382 OMX_VIDEO_PARAM_PORTFORMATTYPE param;
383 memset_s(¶m, sizeof(param), 0, sizeof(param));
384 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
385 param.eCompressionFormat = OMX_VIDEO_CodingAVC;
386 auto ret = component_->GetParameter(component_, OMX_IndexParamVideoPortFormat, reinterpret_cast<int8_t *>(¶m),
387 sizeof(param));
388 ASSERT_NE(ret, HDF_SUCCESS);
389 }
390 /**
391 * @tc.name HdfCodecHdiGetParameterTest_006
392 * @tc.number SUB_Driver_Codec_CodecHdi_1500
393 * @tc.desc The input parameter prot is not supported. As a result, the parameter fails to be read
394 */
395 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_1500, Function | MediumTest | Level3)
396 {
397 ASSERT_TRUE(component_ != nullptr);
398 OMX_VIDEO_CONFIG_BITRATETYPE param;
399 InitParam(param);
400 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
401 auto ret = component_->GetParameter(component_, OMX_IndexParamVideoPortFormat, reinterpret_cast<int8_t *>(¶m),
402 sizeof(param));
403 ASSERT_NE(ret, HDF_SUCCESS);
404 }
405 /**
406 * @tc.name HdfCodecHdiGetParameterTest_007
407 * @tc.number SUB_Driver_Codec_CodecHdi_1600
408 * @tc.desc The input parameter MX_IndexVideoStartUnused. As a result, the parameter fails to be read
409 */
410 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_1600, Function | MediumTest | Level3)
411 {
412 ASSERT_TRUE(component_ != nullptr);
413 OMX_VIDEO_CONFIG_BITRATETYPE param;
414 InitParam(param);
415 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
416 auto ret = component_->GetParameter(component_, OMX_IndexVideoStartUnused, reinterpret_cast<int8_t *>(¶m),
417 sizeof(param));
418 ASSERT_NE(ret, HDF_SUCCESS);
419 }
420 /**
421 * @tc.name HdfCodecHdiSetParameterTest_001
422 * @tc.number SUB_Driver_Codec_CodecHdi_1700
423 * @tc.desc Setting the OMX_IndexParamVideoPortFormat Parameter of the Component Input Port
424 */
425 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_1700, Function | MediumTest | Level3)
426 {
427 ASSERT_TRUE(component_ != nullptr);
428 OMX_VIDEO_PARAM_PORTFORMATTYPE param;
429 InitParam(param);
430 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
431 auto ret = component_->SetParameter(component_, OMX_IndexParamVideoPortFormat, reinterpret_cast<int8_t *>(¶m),
432 sizeof(param));
433 ASSERT_EQ(ret, HDF_SUCCESS);
434 }
435 /**
436 * @tc.name HdfCodecHdiSetParameterTest_002
437 * @tc.number SUB_Driver_Codec_CodecHdi_1800
438 * @tc.desc The input parameter version information is not set. As a result, the parameter setting fails
439 */
440 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_1800, Function | MediumTest | Level3)
441 {
442 ASSERT_TRUE(component_ != nullptr);
443 OMX_VIDEO_PARAM_PORTFORMATTYPE param;
444 memset_s(¶m, sizeof(param), 0, sizeof(param));
445 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
446 auto ret = component_->SetParameter(component_, OMX_IndexParamVideoPortFormat, reinterpret_cast<int8_t *>(¶m),
447 sizeof(param));
448 ASSERT_NE(ret, HDF_SUCCESS);
449 }
450 /**
451 * @tc.name HdfCodecHdiSetParameterTest_003
452 * @tc.number SUB_Driver_Codec_CodecHdi_1900
453 * @tc.desc The input parameter is null
454 */
455 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_1900, Function | MediumTest | Level3)
456 {
457 ASSERT_TRUE(component_ != nullptr);
458 auto ret = component_->SetParameter(component_, OMX_IndexParamVideoPortFormat, nullptr, 0);
459 ASSERT_NE(ret, HDF_SUCCESS);
460 }
461 /**
462 * @tc.name HdfCodecHdiSetParameterTest_004
463 * @tc.number SUB_Driver_Codec_CodecHdi_2000
464 * @tc.desc Parameter does not match index
465 */
466 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_2000, Function | MediumTest | Level3)
467 {
468 ASSERT_TRUE(component_ != nullptr);
469 OMX_VIDEO_CONFIG_BITRATETYPE param;
470 InitParam(param);
471 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
472 auto ret = component_->SetParameter(component_, OMX_IndexParamVideoPortFormat, reinterpret_cast<int8_t *>(¶m),
473 sizeof(param));
474 ASSERT_NE(ret, HDF_SUCCESS);
475 }
476 /**
477 * @tc.name HdfCodecHdiSetParameterTest_005
478 * @tc.number SUB_Driver_Codec_CodecHdi_2100
479 * @tc.desc The parameter index is not supported
480 */
481 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_2100, Function | MediumTest | Level3)
482 {
483 ASSERT_TRUE(component_ != nullptr);
484 OMX_VIDEO_PARAM_PORTFORMATTYPE param;
485 InitParam(param);
486 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
487 auto ret = component_->SetParameter(component_, OMX_IndexVideoStartUnused, reinterpret_cast<int8_t *>(¶m),
488 sizeof(param));
489 ASSERT_NE(ret, HDF_SUCCESS);
490 }
491 #ifndef SUPPORT_OMX
492 /**
493 * @tc.name HdfCodecHdiSetParameterTest_006
494 * @tc.number SUB_Driver_Codec_CodecHdi_2200
495 * @tc.desc
496 */
497 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_2200, Function | MediumTest | Level3)
498 {
499 ASSERT_TRUE(component_ != nullptr);
500 CodecVideoPortFormatParam pixFormat;
501 InitExtParam(pixFormat);
502 pixFormat.portIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
503 pixFormat.codecColorIndex = 0;
504 auto ret = component_->GetParameter(component_, OMX_IndexCodecVideoPortFormat,
505 reinterpret_cast<int8_t *>(&pixFormat), sizeof(pixFormat));
506 ASSERT_EQ(ret, HDF_SUCCESS);
507 pixFormat.codecColorFormat = PIXEL_FMT_RGB_555;
508 ret = component_->SetParameter(component_, OMX_IndexCodecVideoPortFormat, reinterpret_cast<int8_t *>(&pixFormat),
509 sizeof(pixFormat));
510 ASSERT_EQ(ret, HDF_SUCCESS);
511 }
512 #endif
513 /**
514 * @tc.name HdfCodecHdiGetConfigTest_001
515 * @tc.number SUB_Driver_Codec_CodecHdi_2300
516 * @tc.desc The configuration is read normally
517 */
518 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_2300, Function | MediumTest | Level3)
519 {
520 ASSERT_TRUE(component_ != nullptr);
521 OMX_VIDEO_CONFIG_BITRATETYPE param;
522 InitParam(param);
523 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_OUTPUT;
524 auto ret = component_->GetConfig(component_, OMX_IndexConfigVideoBitrate, reinterpret_cast<int8_t *>(¶m),
525 sizeof(param));
526 ASSERT_EQ(ret, HDF_SUCCESS);
527 }
528 /**
529 * @tc.name HdfCodecHdiGetConfigTest_002
530 * @tc.number SUB_Driver_Codec_CodecHdi_2400
531 * @tc.desc Reading Unsupported Port Parameters
532 */
533 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_2400, Function | MediumTest | Level3)
534 {
535 ASSERT_TRUE(component_ != nullptr);
536 OMX_VIDEO_CONFIG_BITRATETYPE param;
537 InitParam(param);
538 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
539 auto ret = component_->GetConfig(component_, OMX_IndexConfigVideoBitrate, reinterpret_cast<int8_t *>(¶m),
540 sizeof(param));
541 ASSERT_NE(ret, HDF_SUCCESS);
542 }
543 /**
544 * @tc.name HdfCodecHdiGetConfigTest_003
545 * @tc.number SUB_Driver_Codec_CodecHdi_2500
546 * @tc.desc The input parameter is a null pointer
547 */
548 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_2500, Function | MediumTest | Level3)
549 {
550 ASSERT_TRUE(component_ != nullptr);
551 auto ret = component_->GetConfig(component_, OMX_IndexConfigVideoBitrate, nullptr, 0);
552 ASSERT_NE(ret, HDF_SUCCESS);
553 }
554 /**
555 * @tc.name HdfCodecHdiGetConfigTest_004
556 * @tc.number SUB_Driver_Codec_CodecHdi_2600
557 * @tc.desc The input parameter index is not supported
558 */
559 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_2600, Function | MediumTest | Level3)
560 {
561 ASSERT_TRUE(component_ != nullptr);
562 OMX_VIDEO_CONFIG_BITRATETYPE param;
563 InitParam(param);
564 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_OUTPUT;
565 auto ret =
566 component_->GetConfig(component_, OMX_IndexVideoStartUnused, reinterpret_cast<int8_t *>(¶m), sizeof(param));
567 ASSERT_NE(ret, HDF_SUCCESS);
568 }
569 /**
570 * @tc.name HdfCodecHdiSetConfigTest_001
571 * @tc.number SUB_Driver_Codec_CodecHdi_2700
572 * @tc.desc The configuration is successful
573 */
574 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_2700, Function | MediumTest | Level3)
575 {
576 ASSERT_TRUE(component_ != nullptr);
577 OMX_VIDEO_CONFIG_BITRATETYPE param;
578 InitParam(param);
579 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_OUTPUT;
580 param.nEncodeBitrate = FRAMERATE;
581 auto ret = component_->SetConfig(component_, OMX_IndexConfigVideoBitrate, reinterpret_cast<int8_t *>(¶m),
582 sizeof(param));
583 ASSERT_EQ(ret, HDF_SUCCESS);
584 }
585 /**
586 * @tc.name HdfCodecHdiSetConfigTest_002
587 * @tc.number SUB_Driver_Codec_CodecHdi_2800
588 * @tc.desc Configure parameters. The port cannot be modified
589 */
590 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_2800, Function | MediumTest | Level3)
591 {
592 ASSERT_TRUE(component_ != nullptr);
593 OMX_VIDEO_CONFIG_BITRATETYPE param;
594 InitParam(param);
595 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_INPUT;
596 param.nEncodeBitrate = FRAMERATE;
597 auto ret = component_->SetConfig(component_, OMX_IndexConfigVideoBitrate, reinterpret_cast<int8_t *>(¶m),
598 sizeof(param));
599 ASSERT_NE(ret, HDF_SUCCESS);
600 }
601 /**
602 * @tc.name HdfCodecHdiSetConfigTest_003
603 * @tc.number SUB_Driver_Codec_CodecHdi_2900
604 * @tc.desc The input parameter is a null poin
605 */
606 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_2900, Function | MediumTest | Level3)
607 {
608 ASSERT_TRUE(component_ != nullptr);
609 auto ret = component_->SetConfig(component_, OMX_IndexConfigVideoBitrate, nullptr, 0);
610 ASSERT_NE(ret, HDF_SUCCESS);
611 }
612 /**
613 * @tc.name HdfCodecHdiSetConfigTest_004
614 * @tc.number SUB_Driver_Codec_CodecHdi_3000
615 * @tc.desc The input parameter index is not supported
616 */
617 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_3000, Function | MediumTest | Level3)
618 {
619 ASSERT_TRUE(component_ != nullptr);
620 OMX_VIDEO_CONFIG_BITRATETYPE param;
621 InitParam(param);
622 param.nPortIndex = (uint32_t)PortIndex::PORT_INDEX_OUTPUT;
623 auto ret =
624 component_->SetConfig(component_, OMX_IndexVideoStartUnused, reinterpret_cast<int8_t *>(¶m), sizeof(param));
625 ASSERT_NE(ret, HDF_SUCCESS);
626 }
627 #ifndef SUPPORT_OMX
628 /**
629 * @tc.name HdfCodecHdiGetExtensionIndexTest_001
630 * @tc.number SUB_Driver_Codec_CodecHdi_3100
631 * @tc.desc Obtaining the extended index normally
632 */
633 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_3100, Function | MediumTest | Level3)
634 {
635 ASSERT_TRUE(component_ != nullptr);
636 OMX_INDEXTYPE indexType;
637 auto ret =
638 component_->GetExtensionIndex(component_, "OMX.Topaz.index.param.extended_video", (uint32_t *)&indexType);
639 ASSERT_EQ(ret, HDF_SUCCESS);
640 }
641 #endif
642 /**
643 * @tc.name HdfCodecHdiGetExtensionIndexTest_002
644 * @tc.number SUB_Driver_Codec_CodecHdi_3200
645 * @tc.desc The parameter name is null pointer
646 */
647 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_3200, Function | MediumTest | Level3)
648 {
649 ASSERT_TRUE(component_ != nullptr);
650 OMX_INDEXTYPE indexType;
651 auto ret = component_->GetExtensionIndex(component_, nullptr, (uint32_t *)&indexType);
652 ASSERT_NE(ret, HDF_SUCCESS);
653 }
654 /**
655 * @tc.name HdfCodecHdiGetExtensionIndexTest_003
656 * @tc.number SUB_Driver_Codec_CodecHdi_3300
657 * @tc.desc Unsupported parameter
658 */
659 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_3300, Function | MediumTest | Level3)
660 {
661 ASSERT_TRUE(component_ != nullptr);
662 OMX_INDEXTYPE indexType;
663 auto ret = component_->GetExtensionIndex(component_, "OMX.Topaz.index.param.extended_test", (uint32_t *)&indexType);
664 ASSERT_NE(ret, HDF_SUCCESS);
665 }
666 /**
667 * @tc.name HdfCodecHdiGetExtensionIndexTest_004
668 * @tc.number SUB_Driver_Codec_CodecHdi_3400
669 * @tc.desc Index is null pointer
670 */
671 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_3400, Function | MediumTest | Level3)
672 {
673 ASSERT_TRUE(component_ != nullptr);
674 auto ret = component_->GetExtensionIndex(component_, "OMX.Topaz.index.param.extended_video", nullptr);
675 ASSERT_NE(ret, HDF_SUCCESS);
676 }
677 /**
678 * @tc.name HdfCodecHdiGetStateTest_001
679 * @tc.number SUB_Driver_Codec_CodecHdi_3500
680 * @tc.desc Reads the current status of the component
681 */
682 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_3500, Function | MediumTest | Level3)
683 {
684 ASSERT_TRUE(component_ != nullptr);
685 OMX_STATETYPE state;
686 auto ret = component_->GetState(component_, &state);
687 ASSERT_EQ(state, OMX_StateLoaded);
688 ASSERT_EQ(ret, HDF_SUCCESS);
689 }
690 /**
691 * @tc.name HdfCodecHdiGetStateTest_002
692 * @tc.number SUB_Driver_Codec_CodecHdi_3600
693 * @tc.desc The input parameter is a null pointer
694 */
695 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_3600, Function | MediumTest | Level3)
696 {
697 ASSERT_TRUE(component_ != nullptr);
698 auto ret = component_->GetState(component_, nullptr);
699 ASSERT_NE(ret, HDF_SUCCESS);
700 }
701 #ifndef SUPPORT_OMX
702 /**
703 * @tc.name HdfCodecHdiTunnelRequestTest_001
704 * @tc.number SUB_Driver_Codec_CodecHdi_3700
705 * @tc.desc The interface is not supported
706 */
707 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_3700, Function | MediumTest | Level3)
708 {
709 ASSERT_TRUE(component_ != nullptr);
710 const int32_t tunneledComp = 1002;
711 const uint32_t tunneledPort = 101;
712 OMX_TUNNELSETUPTYPE tunnelSetup;
713 tunnelSetup.eSupplier = OMX_BufferSupplyInput;
714
715 auto ret = component_->ComponentTunnelRequest(component_, (uint32_t)PortIndex::PORT_INDEX_OUTPUT, tunneledComp,
716 tunneledPort, &tunnelSetup);
717 ASSERT_NE(ret, HDF_SUCCESS);
718 }
719 #endif
720 /**
721 * @tc.name HdfCodecHdiLoadedToExecutingTest_001
722 * @tc.number SUB_Driver_Codec_CodecHdi_3800
723 * @tc.desc The status is changed to OMX_StateExecuting
724 */
725 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_3800, Function | MediumTest | Level3)
726 {
727 ASSERT_TRUE(component_ != nullptr);
728 auto ret = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateExecuting, nullptr, 0);
729 ASSERT_EQ(ret, HDF_SUCCESS);
730 }
731 /**
732 * @tc.name HdfCodecHdiAllocateBufferTest_001
733 * @tc.number SUB_Driver_Codec_CodecHdi_3900
734 * @tc.desc The input buffer type is CODEC_BUFFER_TYPE_INVALID
735 */
736 struct OmxCodecBuffer allocBuffer;
737 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_3900, Function | MediumTest | Level3)
738 {
739 ASSERT_TRUE(component_ != nullptr);
740 InitCodecBuffer(allocBuffer, CODEC_BUFFER_TYPE_INVALID, version_);
741 auto ret = component_->AllocateBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_INPUT, &allocBuffer);
742 ASSERT_NE(ret, HDF_SUCCESS);
743 }
744 /**
745 * @tc.name HdfCodecHdiAllocateBufferTest_002
746 * @tc.number SUB_Driver_Codec_CodecHdi_4100
747 * @tc.desc The input buffer type is CODEC_BUFFER_TYPE_VIRTUAL_ADDR
748 */
749 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_4100, Function | MediumTest | Level3)
750 {
751 ASSERT_TRUE(component_ != nullptr);
752 InitCodecBuffer(allocBuffer, CODEC_BUFFER_TYPE_VIRTUAL_ADDR, version_);
753 auto ret = component_->AllocateBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_INPUT, &allocBuffer);
754 ASSERT_NE(ret, HDF_SUCCESS);
755 }
756 /**
757 * @tc.name HdfCodecHdiAllocateBufferTest_003
758 * @tc.number SUB_Driver_Codec_CodecHdi_4200
759 * @tc.desc The output buffer type is CODEC_BUFFER_TYPE_INVALID
760 */
761 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_4200, Function | MediumTest | Level3)
762 {
763 ASSERT_TRUE(component_ != nullptr);
764 InitCodecBuffer(allocBuffer, CODEC_BUFFER_TYPE_INVALID, version_);
765 auto ret = component_->AllocateBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_OUTPUT, &allocBuffer);
766 ASSERT_NE(ret, HDF_SUCCESS);
767 }
768 /**
769 * @tc.name HdfCodecHdiAllocateBufferTest_004
770 * @tc.number SUB_Driver_Codec_CodecHdi_4300
771 * @tc.desc The output buffer type is CODEC_BUFFER_TYPE_VIRTUAL_ADDR
772 */
773 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_4300, Function | MediumTest | Level3)
774 {
775 ASSERT_TRUE(component_ != nullptr);
776 InitCodecBuffer(allocBuffer, CODEC_BUFFER_TYPE_VIRTUAL_ADDR, version_);
777 auto ret = component_->AllocateBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_OUTPUT, &allocBuffer);
778 ASSERT_NE(ret, HDF_SUCCESS);
779 }
780 /**
781 * @tc.name HdfCodecHdiUseBufferTest_001
782 * @tc.number SUB_Driver_Codec_CodecHdi_4400
783 * @tc.desc The input buffer type is CODEC_BUFFER_TYPE_INVALID
784 */
785 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_4400, Function | MediumTest | Level3)
786 {
787 ASSERT_TRUE(component_ != nullptr);
788 std::shared_ptr<OmxCodecBuffer> omxBuffer = std::make_shared<OmxCodecBuffer>();
789 ASSERT_TRUE(omxBuffer != nullptr);
790 omxBuffer->size = sizeof(OmxCodecBuffer);
791 omxBuffer->version = version_;
792 omxBuffer->bufferType = CODEC_BUFFER_TYPE_INVALID;
793 omxBuffer->bufferLen = 0;
794 omxBuffer->buffer = nullptr;
795 omxBuffer->allocLen = 0;
796 omxBuffer->fenceFd = -1;
797 omxBuffer->pts = 0;
798 omxBuffer->flag = 0;
799
800 auto err = component_->UseBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_INPUT, omxBuffer.get());
801 ASSERT_NE(err, HDF_SUCCESS);
802 }
803 /**
804 * @tc.name HdfCodecHdiUseBufferTest_002
805 * @tc.number SUB_Driver_Codec_CodecHdi_4500
806 * @tc.desc The output buffer type is CODEC_BUFFER_TYPE_INVALID
807 */
808 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_4500, Function | MediumTest | Level3)
809 {
810 ASSERT_TRUE(component_ != nullptr);
811 std::shared_ptr<OmxCodecBuffer> omxBuffer = std::make_shared<OmxCodecBuffer>();
812 ASSERT_TRUE(omxBuffer != nullptr);
813 omxBuffer->size = sizeof(OmxCodecBuffer);
814 omxBuffer->version = version_;
815 omxBuffer->bufferType = CODEC_BUFFER_TYPE_INVALID;
816 omxBuffer->bufferLen = 0;
817 omxBuffer->buffer = nullptr;
818 omxBuffer->allocLen = 0;
819 omxBuffer->fenceFd = -1;
820 omxBuffer->pts = 0;
821 omxBuffer->flag = 0;
822
823 auto err = component_->UseBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_OUTPUT, omxBuffer.get());
824 ASSERT_NE(err, HDF_SUCCESS);
825 }
826 /**
827 * @tc.name HdfCodecHdiUseBufferTest_003
828 * @tc.number SUB_Driver_Codec_CodecHdi_4600
829 * @tc.desc The input buffer type is CODEC_BUFFER_TYPE_VIRTUAL_ADDR
830 */
831 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_4600, Function | MediumTest | Level3)
832 {
833 ASSERT_TRUE(component_ != nullptr);
834 std::shared_ptr<OmxCodecBuffer> omxBuffer = std::make_shared<OmxCodecBuffer>();
835 ASSERT_TRUE(omxBuffer != nullptr);
836 omxBuffer->size = sizeof(OmxCodecBuffer);
837 omxBuffer->version = version_;
838 omxBuffer->bufferType = CODEC_BUFFER_TYPE_VIRTUAL_ADDR;
839 omxBuffer->bufferLen = 0;
840 omxBuffer->buffer = nullptr;
841 omxBuffer->allocLen = 0;
842 omxBuffer->fenceFd = -1;
843 omxBuffer->pts = 0;
844 omxBuffer->flag = 0;
845
846 auto err = component_->UseBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_INPUT, omxBuffer.get());
847 ASSERT_NE(err, HDF_SUCCESS);
848 }
849 /**
850 * @tc.name HdfCodecHdiUseBufferTest_004
851 * @tc.number SUB_Driver_Codec_CodecHdi_4700
852 * @tc.desc The output buffer type is CODEC_BUFFER_TYPE_VIRTUAL_ADDR
853 */
854 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_4700, Function | MediumTest | Level3)
855 {
856 ASSERT_TRUE(component_ != nullptr);
857 std::shared_ptr<OmxCodecBuffer> omxBuffer = std::make_shared<OmxCodecBuffer>();
858 ASSERT_TRUE(omxBuffer != nullptr);
859 omxBuffer->size = sizeof(OmxCodecBuffer);
860 omxBuffer->version = version_;
861 omxBuffer->bufferType = CODEC_BUFFER_TYPE_VIRTUAL_ADDR;
862 omxBuffer->bufferLen = 0;
863 omxBuffer->buffer = nullptr;
864 omxBuffer->allocLen = 0;
865 omxBuffer->fenceFd = -1;
866 omxBuffer->pts = 0;
867 omxBuffer->flag = 0;
868
869 auto err = component_->UseBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_OUTPUT, omxBuffer.get());
870 ASSERT_NE(err, HDF_SUCCESS);
871 }
872 #ifndef SUPPORT_OMX
873 /**
874 * @tc.name HdfCodecHdiUseBufferTest_005
875 * @tc.number SUB_Driver_Codec_CodecHdi_4800
876 * @tc.desc The intput buffer type is CODEC_BUFFER_TYPE_AVSHARE_MEM_FD
877 */
878 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_4800, Function | MediumTest | Level3)
879 {
880 ASSERT_TRUE(component_ != nullptr);
881 OMX_PARAM_PORTDEFINITIONTYPE param;
882 InitParam(param);
883 param.nPortIndex = (OMX_U32)PortIndex::PORT_INDEX_INPUT;
884 auto err = component_->GetParameter(component_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param));
885 ASSERT_EQ(err, HDF_SUCCESS);
886
887 int32_t bufferSize = param.nBufferSize;
888 int32_t bufferCount = param.nBufferCountActual;
889 auto ret = UseBufferOnPort(PortIndex::PORT_INDEX_INPUT, bufferCount, bufferSize);
890 ASSERT_TRUE(ret);
891 FreeBufferOnPort(PortIndex::PORT_INDEX_INPUT);
892 }
893 /**
894 * @tc.name HdfCodecHdiUseBufferTest_006
895 * @tc.number SUB_Driver_Codec_CodecHdi_4900
896 * @tc.desc The intput buffer type is CODEC_BUFFER_TYPE_HANDLE
897 */
898 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_4900, Function | MediumTest | Level3)
899 {
900 ASSERT_TRUE(component_ != nullptr);
901 auto err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateIdle, NULL, 0);
902 ASSERT_EQ(err, HDF_SUCCESS);
903
904 std::shared_ptr<OmxCodecBuffer> omxBuffer = std::make_shared<OmxCodecBuffer>();
905 ASSERT_TRUE(omxBuffer != nullptr);
906 BufferHandle *bufferHandle = nullptr;
907 InitBufferHandle(omxBuffer, &bufferHandle);
908 omxBuffer->bufferType = CODEC_BUFFER_TYPE_HANDLE;
909
910 err = component_->UseBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_INPUT, omxBuffer.get());
911 if (err != HDF_SUCCESS) {
912 HDF_LOGE("%{public}s failed to UseBuffer with input port", __func__);
913 omxBuffer = nullptr;
914 }
915 ASSERT_EQ(err, HDF_SUCCESS);
916 omxBuffer->bufferLen = 0;
917 std::shared_ptr<BufferInfo> bufferInfo = std::make_shared<BufferInfo>();
918 ASSERT_TRUE(bufferInfo != nullptr);
919 bufferInfo->omxBuffer = omxBuffer;
920 bufferInfo->bufferHandle = bufferHandle;
921 inputBuffers_.emplace(std::make_pair(omxBuffer->bufferId, bufferInfo));
922 FreeBufferOnPort(PortIndex::PORT_INDEX_INPUT);
923 }
924 /**
925 * @tc.name HdfCodecHdiUseBufferTest_007
926 * @tc.number SUB_Driver_Codec_CodecHdi_5000
927 * @tc.desc The output buffer type is CODEC_BUFFER_TYPE_AVSHARE_MEM_FD
928 */
929 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_5000, Function | MediumTest | Level3)
930 {
931 ASSERT_TRUE(component_ != nullptr);
932 OMX_PARAM_PORTDEFINITIONTYPE param;
933 InitParam(param);
934 param.nPortIndex = (OMX_U32)PortIndex::PORT_INDEX_OUTPUT;
935 auto err = component_->GetParameter(component_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param));
936 ASSERT_EQ(err, HDF_SUCCESS);
937
938 int32_t bufferSize = param.nBufferSize;
939 int32_t bufferCount = param.nBufferCountActual;
940 bool ret = UseBufferOnPort(PortIndex::PORT_INDEX_OUTPUT, bufferCount, bufferSize);
941 ASSERT_TRUE(ret);
942 ret = FreeBufferOnPort(PortIndex::PORT_INDEX_OUTPUT);
943 ASSERT_TRUE(ret);
944 }
945 /**
946 * @tc.name HdfCodecHdiUseBufferTest_008
947 * @tc.number SUB_Driver_Codec_CodecHdi_5100
948 * @tc.desc The output buffer type is CODEC_BUFFER_TYPE_DYNAMIC_HANDLE
949 */
950 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_5100, Function | MediumTest | Level3)
951 {
952 ASSERT_TRUE(component_ != nullptr);
953 auto err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateIdle, NULL, 0);
954 ASSERT_EQ(err, HDF_SUCCESS);
955 std::shared_ptr<OmxCodecBuffer> omxBuffer = std::make_shared<OmxCodecBuffer>();
956 ASSERT_TRUE(omxBuffer != nullptr);
957 omxBuffer->size = sizeof(OmxCodecBuffer);
958 omxBuffer->version = version_;
959 omxBuffer->bufferType = CODEC_BUFFER_TYPE_DYNAMIC_HANDLE;
960 omxBuffer->bufferLen = 0;
961 omxBuffer->buffer = nullptr;
962 omxBuffer->allocLen = 0;
963 omxBuffer->fenceFd = -1;
964 omxBuffer->pts = 0;
965 omxBuffer->flag = 0;
966
967 err = component_->UseBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_OUTPUT, omxBuffer.get());
968 if (err != HDF_SUCCESS) {
969 HDF_LOGE("%{public}s failed to UseBuffer with input port", __func__);
970 omxBuffer = nullptr;
971 }
972 ASSERT_EQ(err, HDF_SUCCESS);
973 omxBuffer->bufferLen = 0;
974 std::shared_ptr<BufferInfo> bufferInfo = std::make_shared<BufferInfo>();
975 ASSERT_TRUE(bufferInfo != nullptr);
976 bufferInfo->omxBuffer = omxBuffer;
977 outputBuffers_.emplace(std::make_pair(omxBuffer->bufferId, bufferInfo));
978 FreeBufferOnPort(PortIndex::PORT_INDEX_OUTPUT);
979 }
980 /**
981 * @tc.name HdfCodecHdiUseBufferTest_009
982 * @tc.number SUB_Driver_Codec_CodecHdi_5200
983 * @tc.desc The input buffer is full
984 */
985 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_5200, Function | MediumTest | Level3)
986 {
987 ASSERT_TRUE(component_ != nullptr);
988 OMX_PARAM_PORTDEFINITIONTYPE param;
989 InitParam(param);
990 param.nPortIndex = (OMX_U32)PortIndex::PORT_INDEX_INPUT;
991 auto err = component_->GetParameter(component_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param));
992 ASSERT_EQ(err, HDF_SUCCESS);
993
994 bool ret = UseBufferOnPort(PortIndex::PORT_INDEX_INPUT, param.nBufferCountActual, param.nBufferSize);
995 ASSERT_TRUE(ret);
996 ret = UseBufferOnPort(PortIndex::PORT_INDEX_INPUT, 1, param.nBufferSize);
997 FreeBufferOnPort(PortIndex::PORT_INDEX_INPUT);
998 ASSERT_FALSE(ret);
999 }
1000 /**
1001 * @tc.name HdfCodecHdiUseBufferTest_010
1002 * @tc.number SUB_Driver_Codec_CodecHdi_5300
1003 * @tc.desc The output buffer is full
1004 */
1005 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_5300, Function | MediumTest | Level3)
1006 {
1007 ASSERT_TRUE(component_ != nullptr);
1008 OMX_PARAM_PORTDEFINITIONTYPE param;
1009 InitParam(param);
1010 param.nPortIndex = (OMX_U32)PortIndex::PORT_INDEX_OUTPUT;
1011 auto err = component_->GetParameter(component_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param));
1012 ASSERT_EQ(err, HDF_SUCCESS);
1013 bool ret = UseBufferOnPort(PortIndex::PORT_INDEX_OUTPUT, param.nBufferCountActual, param.nBufferSize);
1014 ASSERT_TRUE(ret);
1015 ret = UseBufferOnPort(PortIndex::PORT_INDEX_OUTPUT, 1, param.nBufferSize);
1016 FreeBufferOnPort(PortIndex::PORT_INDEX_OUTPUT);
1017 ASSERT_FALSE(ret);
1018 }
1019 /**
1020 * @tc.name HdfCodecHdiAllocateBufferTest_005
1021 * @tc.number SUB_Driver_Codec_CodecHdi_5400
1022 * @tc.desc The input buffer is full
1023 */
1024 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_5400, Function | MediumTest | Level3)
1025 {
1026 ASSERT_TRUE(component_ != nullptr);
1027 auto err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateIdle, NULL, 0);
1028 ASSERT_EQ(err, HDF_SUCCESS);
1029 InitCodecBuffer(allocBuffer, CODEC_BUFFER_TYPE_AVSHARE_MEM_FD, version_);
1030 err = component_->AllocateBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_INPUT, &allocBuffer);
1031 ASSERT_EQ(err, HDF_SUCCESS);
1032 err = component_->FreeBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_INPUT, &allocBuffer);
1033 ASSERT_EQ(err, HDF_SUCCESS);
1034 }
1035 /**
1036 * @tc.name HdfCodecHdiAllocateBufferTest_006
1037 * @tc.number SUB_Driver_Codec_CodecHdi_5500
1038 * @tc.desc The output buffer is full
1039 */
1040 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_5500, Function | MediumTest | Level3)
1041 {
1042 ASSERT_TRUE(component_ != nullptr);
1043 auto err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateIdle, NULL, 0);
1044 ASSERT_EQ(err, HDF_SUCCESS);
1045 InitCodecBuffer(allocBuffer, CODEC_BUFFER_TYPE_AVSHARE_MEM_FD, version_);
1046 allocBuffer.type = READ_WRITE_TYPE;
1047 err = component_->AllocateBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_OUTPUT, &allocBuffer);
1048 ASSERT_EQ(err, HDF_SUCCESS);
1049 err = component_->FreeBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_OUTPUT, &allocBuffer);
1050 ASSERT_EQ(err, HDF_SUCCESS);
1051 }
1052 #endif
1053 /**
1054 * @tc.name HdfCodecHdiUseBufferTest_011
1055 * @tc.number SUB_Driver_Codec_CodecHdi_7200
1056 * @tc.desc The output buffer is full
1057 */
1058 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_7200, TestSize.Level1)
1059 {
1060 ASSERT_TRUE(component_ != nullptr);
1061 std::shared_ptr<OmxCodecBuffer> omxBuffer = std::make_shared<OmxCodecBuffer>();
1062 ASSERT_TRUE(omxBuffer != nullptr);
1063 BufferHandle *bufferHandle = nullptr;
1064 InitBufferHandle(omxBuffer, &bufferHandle);
1065 omxBuffer->bufferType = CODEC_BUFFER_TYPE_INVALID;
1066 auto err = component_->UseBuffer(component_, static_cast<uint32_t>(PortIndex::PORT_INDEX_INPUT), omxBuffer.get());
1067 ASSERT_NE(err, HDF_SUCCESS);
1068 }
1069
1070 /**
1071 * @tc.name HdfCodecHdiUseEglImageTest_001
1072 * @tc.number SUB_Driver_Codec_CodecHdi_5600
1073 * @tc.desc The interface is invoked successfully. The OMX does not support this function
1074 */
1075 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_5600, Function | MediumTest | Level3)
1076 {
1077 ASSERT_TRUE(component_ != nullptr);
1078 struct OmxCodecBuffer buffer;
1079 buffer.fenceFd = -1;
1080 buffer.version = version_;
1081 buffer.bufferType = CODEC_BUFFER_TYPE_AVSHARE_MEM_FD;
1082 buffer.allocLen = BUFFER_SIZE;
1083 buffer.buffer = 0;
1084 buffer.bufferLen = 0;
1085 buffer.pts = 0;
1086 buffer.flag = 0;
1087 buffer.type = READ_ONLY_TYPE;
1088 auto eglImage = std::make_unique<int8_t[]>(BUFFER_SIZE);
1089 ASSERT_TRUE(eglImage != nullptr);
1090 auto ret = component_->UseEglImage(component_, &buffer, (uint32_t)PortIndex::PORT_INDEX_INPUT, eglImage.get(),
1091 BUFFER_SIZE);
1092 ASSERT_NE(ret, HDF_SUCCESS);
1093 eglImage = nullptr;
1094 }
1095 /**
1096 * @tc.name HdfCodecHdiBufferFillAndEmptyTest_001
1097 * @tc.number SUB_Driver_Codec_CodecHdi_5800
1098 * @tc.desc FillThisBuffer test
1099 */
1100 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_5800, Function | MediumTest | Level3)
1101 {
1102 ASSERT_TRUE(component_ != nullptr);
1103 auto err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateIdle, NULL, 0);
1104 ASSERT_EQ(err, HDF_SUCCESS);
1105 OMX_PARAM_PORTDEFINITIONTYPE param;
1106 InitParam(param);
1107 param.nPortIndex = (OMX_U32)PortIndex::PORT_INDEX_INPUT;
1108 err = component_->GetParameter(component_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param));
1109 ASSERT_EQ(err, HDF_SUCCESS);
1110
1111 bool ret = UseBufferOnPort(PortIndex::PORT_INDEX_INPUT, param.nBufferCountActual, param.nBufferSize);
1112 ASSERT_TRUE(ret);
1113 InitParam(param);
1114 param.nPortIndex = (OMX_U32)PortIndex::PORT_INDEX_OUTPUT;
1115 err = component_->GetParameter(component_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param));
1116 ASSERT_EQ(err, HDF_SUCCESS);
1117 ret = UseBufferOnPort(PortIndex::PORT_INDEX_OUTPUT, param.nBufferCountActual, param.nBufferSize);
1118 ASSERT_TRUE(ret);
1119 err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateExecuting, NULL, 0);
1120 waitState(OMX_StateExecuting);
1121 auto iter = outputBuffers_.begin();
1122 if (iter != outputBuffers_.end()) {
1123 auto ret = component_->FillThisBuffer(component_, iter->second->omxBuffer.get());
1124 ASSERT_EQ(ret, HDF_SUCCESS);
1125 }
1126 iter = inputBuffers_.begin();
1127 if (iter != inputBuffers_.end()) {
1128 auto ret = component_->EmptyThisBuffer(component_, iter->second->omxBuffer.get());
1129 ASSERT_EQ(ret, HDF_SUCCESS);
1130 }
1131
1132 err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateIdle, nullptr, 0);
1133 waitState(OMX_StateIdle);
1134
1135 err = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateLoaded, nullptr, 0);
1136 FreeBufferOnPort(PortIndex::PORT_INDEX_INPUT);
1137 FreeBufferOnPort(PortIndex::PORT_INDEX_OUTPUT);
1138
1139 waitState(OMX_StateLoaded);
1140 }
1141 /**
1142 * @tc.name HdfCodecHdiFillThisBufferTest_002
1143 * @tc.number SUB_Driver_Codec_CodecHdi_5900
1144 * @tc.desc The buffer ID is incorrect
1145 */
1146 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_5900, Function | MediumTest | Level3)
1147 {
1148 ASSERT_TRUE(component_ != nullptr);
1149 allocBuffer.bufferType = CODEC_BUFFER_TYPE_AVSHARE_MEM_FD;
1150 allocBuffer.fenceFd = -1;
1151 allocBuffer.version = version_;
1152 allocBuffer.allocLen = BUFFER_SIZE;
1153 allocBuffer.buffer = 0;
1154 allocBuffer.bufferLen = 0;
1155 allocBuffer.pts = 0;
1156 allocBuffer.flag = 0;
1157 allocBuffer.type = READ_ONLY_TYPE;
1158 allocBuffer.bufferId = BUFFER_ID_ERROR;
1159 auto ret = component_->FillThisBuffer(component_, &allocBuffer);
1160 ASSERT_NE(ret, HDF_SUCCESS);
1161 }
1162 /**
1163 * @tc.name HdfCodecHdiEmptyThisBufferTest_001
1164 * @tc.number SUB_Driver_Codec_CodecHdi_6000
1165 * @tc.desc EmptyThisBuffer test
1166 */
1167 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_6000, Function | MediumTest | Level3)
1168 {
1169 ASSERT_TRUE(component_ != nullptr);
1170 allocBuffer.bufferType = CODEC_BUFFER_TYPE_AVSHARE_MEM_FD;
1171 allocBuffer.fenceFd = -1;
1172 allocBuffer.version = version_;
1173 allocBuffer.allocLen = BUFFER_SIZE;
1174 allocBuffer.buffer = 0;
1175 allocBuffer.bufferLen = 0;
1176 allocBuffer.pts = 0;
1177 allocBuffer.flag = 0;
1178 allocBuffer.type = READ_ONLY_TYPE;
1179 allocBuffer.bufferId = BUFFER_ID_ERROR;
1180 auto ret = component_->EmptyThisBuffer(component_, &allocBuffer);
1181 ASSERT_NE(ret, HDF_SUCCESS);
1182 }
1183 /**
1184 * @tc.name HdfCodecHdiSetCallbackTest_001
1185 * @tc.number SUB_Driver_Codec_CodecHdi_6200
1186 * @tc.desc Setting Component Callbacks
1187 */
1188 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_6200, Function | MediumTest | Level3)
1189 {
1190 ASSERT_TRUE(component_ != nullptr);
1191 if (callback_ != nullptr) {
1192 CodecCallbackTypeRelease(callback_);
1193 }
1194 callback_ = CodecCallbackTypeGet(nullptr);
1195 ASSERT_TRUE(callback_ != nullptr);
1196 auto ret = component_->SetCallbacks(component_, callback_, (int64_t)this);
1197 ASSERT_EQ(ret, HDF_SUCCESS);
1198 }
1199 #ifndef SUPPORT_OMX
1200 /**
1201 * @tc.name HdfCodecHdiSetCallbackTest_002
1202 * @tc.number SUB_Driver_Codec_CodecHdi_6300
1203 * @tc.desc The callback pointer is null
1204 */
1205 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_6300, Function | MediumTest | Level3)
1206 {
1207 ASSERT_TRUE(component_ != nullptr);
1208 uint8_t role[ROLE_LEN] = {0};
1209 auto ret = component_->ComponentRoleEnum(component_, role, ROLE_LEN, 0);
1210 ASSERT_EQ(ret, HDF_SUCCESS);
1211 }
1212 #endif
1213 /**
1214 * @tc.name HdfCodecHdiRoleEnumTest_001
1215 * @tc.number SUB_Driver_Codec_CodecHdi_6400
1216 * @tc.desc Obtaining Component Roles Based on Indexes
1217 */
1218 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_6400, Function | MediumTest | Level3)
1219 {
1220 ASSERT_TRUE(component_ != nullptr);
1221 auto ret = component_->ComponentRoleEnum(component_, nullptr, 0, 0);
1222 ASSERT_NE(ret, HDF_SUCCESS);
1223 }
1224 #ifndef SUPPORT_OMX
1225 /**
1226 * @tc.name HdfCodecHdiRoleEnumTest_002
1227 * @tc.number SUB_Driver_Codec_CodecHdi_6500
1228 * @tc.desc The role is null
1229 */
1230 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_6500, Function | MediumTest | Level3)
1231 {
1232 ASSERT_TRUE(component_ != nullptr);
1233 uint8_t role[ROLE_LEN] = {0};
1234 auto ret = component_->ComponentRoleEnum(component_, role, ROLE_LEN, MAX_ROLE_INDEX);
1235 ASSERT_NE(ret, HDF_SUCCESS);
1236 }
1237 /**
1238 * @tc.name HdfCodecHdiRoleEnumTest_003
1239 * @tc.number SUB_Driver_Codec_CodecHdi_6600
1240 * @tc.desc The index is too large
1241 */
1242 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_6600, Function | MediumTest | Level3)
1243 {
1244 ASSERT_TRUE(component_ != nullptr);
1245 auto ret = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateIdle, nullptr, 0);
1246 ASSERT_EQ(ret, HDF_SUCCESS);
1247 }
1248 #endif
1249 /**
1250 * @tc.name HdfCodecHdiExecutingToIdleTest_001
1251 * @tc.number SUB_Driver_Codec_CodecHdi_6700
1252 * @tc.desc The component enters the OMX_Idle state
1253 */
1254 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_6700, Function | MediumTest | Level3)
1255 {
1256 ASSERT_TRUE(component_ != nullptr);
1257 allocBuffer.bufferType = CODEC_BUFFER_TYPE_AVSHARE_MEM_FD;
1258 allocBuffer.fenceFd = -1;
1259 allocBuffer.version = version_;
1260 allocBuffer.allocLen = BUFFER_SIZE;
1261 allocBuffer.buffer = 0;
1262 allocBuffer.bufferLen = 0;
1263 allocBuffer.pts = 0;
1264 allocBuffer.flag = 0;
1265 allocBuffer.type = READ_ONLY_TYPE;
1266 allocBuffer.bufferId = BUFFER_ID_ERROR;
1267 auto ret = component_->FreeBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_OUTPUT, &allocBuffer);
1268 ASSERT_NE(ret, HDF_SUCCESS);
1269 }
1270 #ifndef SUPPORT_OMX
1271 /**
1272 * @tc.name HdfCodecHdiFreeBufferTest_001
1273 * @tc.number SUB_Driver_Codec_CodecHdi_6800
1274 * @tc.desc The buffer ID of the output port is incorrect
1275 */
1276 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_6800, Function | MediumTest | Level3)
1277 {
1278 ASSERT_TRUE(component_ != nullptr);
1279 OMX_PARAM_PORTDEFINITIONTYPE param;
1280 InitParam(param);
1281 param.nPortIndex = (OMX_U32)PortIndex::PORT_INDEX_OUTPUT;
1282 auto err = component_->GetParameter(component_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param));
1283 ASSERT_EQ(err, HDF_SUCCESS);
1284
1285 int32_t bufferSize = param.nBufferSize;
1286 int32_t bufferCount = param.nBufferCountActual;
1287 auto ret = UseBufferOnPort(PortIndex::PORT_INDEX_OUTPUT, bufferCount, bufferSize);
1288 ASSERT_TRUE(ret);
1289 ret = FreeBufferOnPort(PortIndex::PORT_INDEX_OUTPUT);
1290 ASSERT_TRUE(ret);
1291 }
1292 #endif
1293 /**
1294 * @tc.name HdfCodecHdiFreeBufferTest_002
1295 * @tc.number SUB_Driver_Codec_CodecHdi_6900
1296 * @tc.desc Test on normal release of the output port
1297 */
1298 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_6900, Function | MediumTest | Level3)
1299 {
1300 ASSERT_TRUE(component_ != nullptr);
1301 allocBuffer.bufferType = CODEC_BUFFER_TYPE_AVSHARE_MEM_FD;
1302 allocBuffer.fenceFd = -1;
1303 allocBuffer.version = version_;
1304 allocBuffer.allocLen = BUFFER_SIZE;
1305 allocBuffer.buffer = 0;
1306 allocBuffer.bufferLen = 0;
1307 allocBuffer.pts = 0;
1308 allocBuffer.flag = 0;
1309 allocBuffer.type = READ_ONLY_TYPE;
1310 allocBuffer.bufferId = BUFFER_ID_ERROR;
1311 auto ret = component_->FreeBuffer(component_, (uint32_t)PortIndex::PORT_INDEX_INPUT, &allocBuffer);
1312 ASSERT_NE(ret, HDF_SUCCESS);
1313 }
1314 #ifndef SUPPORT_OMX
1315 /**
1316 * @tc.name HdfCodecHdiFreeBufferTest_003
1317 * @tc.number SUB_Driver_Codec_CodecHdi_7000
1318 * @tc.desc The buffer ID of the input port is incorrect
1319 */
1320 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_7000, Function | MediumTest | Level3)
1321 {
1322 ASSERT_TRUE(component_ != nullptr);
1323 OMX_PARAM_PORTDEFINITIONTYPE param;
1324 InitParam(param);
1325 param.nPortIndex = (OMX_U32)PortIndex::PORT_INDEX_INPUT;
1326 auto err = component_->GetParameter(component_, OMX_IndexParamPortDefinition, (int8_t *)¶m, sizeof(param));
1327 ASSERT_EQ(err, HDF_SUCCESS);
1328
1329 int32_t bufferSize = param.nBufferSize;
1330 int32_t bufferCount = param.nBufferCountActual;
1331 auto ret = UseBufferOnPort(PortIndex::PORT_INDEX_INPUT, bufferCount, bufferSize);
1332 ASSERT_TRUE(ret);
1333 ret = FreeBufferOnPort(PortIndex::PORT_INDEX_INPUT);
1334 ASSERT_TRUE(ret);
1335 }
1336 // When ComponentDeInit, must change to Loaded State
1337 /**
1338 * @tc.name HdfCodecHdiFreeBufferTest_004
1339 * @tc.number SUB_Driver_Codec_CodecHdi_7100
1340 * @tc.desc Test on normal release of the input port
1341 */
1342 HWTEST_F(CodecHdiOmxTest, SUB_Driver_Codec_CodecHdi_7100, Function | MediumTest | Level3)
1343 {
1344 ASSERT_TRUE(component_ != nullptr);
1345 auto ret = component_->SendCommand(component_, OMX_CommandStateSet, OMX_StateLoaded, nullptr, 0);
1346 ASSERT_EQ(ret, HDF_SUCCESS);
1347 // State changed OMX_StateIdle when release all this buffer
1348 OMX_STATETYPE state = OMX_StateInvalid;
1349 do {
1350 usleep(100);
1351 ret = component_->GetState(component_, &state);
1352 ASSERT_EQ(ret, HDF_SUCCESS);
1353 } while (state != OMX_StateLoaded);
1354 ret = component_->ComponentDeInit(component_);
1355 ASSERT_EQ(ret, HDF_SUCCESS);
1356 }
1357 #endif
1358 } // namespace
1359