1 /*
2 * Copyright (C) 2025 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 <iostream>
17 #include <cstdio>
18 #include <atomic>
19 #include <fstream>
20 #include <thread>
21 #include <mutex>
22 #include <queue>
23 #include <string>
24
25 #include "gtest/gtest.h"
26 #include "videodec_inner_sample.h"
27 #include "avcodec_video_decoder.h"
28 #include "meta/format.h"
29 #include "avcodec_errors.h"
30 #include "avcodec_common.h"
31 #include "native_avcapability.h"
32
33 using namespace std;
34 using namespace OHOS;
35 using namespace OHOS::MediaAVCodec;
36 using namespace testing::ext;
37
38 namespace {
39 class HevcswdecInnerApiNdkTest : public testing::Test {
40 public:
41 // SetUpTestCase: Called before all test cases
42 static void SetUpTestCase(void);
43 // TearDownTestCase: Called after all test case
44 static void TearDownTestCase(void);
45 // SetUp: Called before each test cases
46 void SetUp() override;
47 // TearDown: Called after each test cases
48 void TearDown() override;
49 protected:
50 const char *INP_DIR_1080_30 = "/data/test/media/1920_1080_30.h265";
51 };
52
53 std::shared_ptr<AVCodecVideoDecoder> vdec_ = nullptr;
54 std::shared_ptr<VDecInnerSignal> signal_ = nullptr;
55 std::string g_invalidCodecMime = "avdec_h265";
56 std::string g_codecMime = "video/hevc";
57 std::string g_codecName = "";
58
59 constexpr uint32_t DEFAULT_WIDTH = 1920;
60 constexpr uint32_t DEFAULT_HEIGHT = 1080;
61 constexpr double DEFAULT_FRAME_RATE = 30.0;
62
SetUpTestCase()63 void HevcswdecInnerApiNdkTest::SetUpTestCase()
64 {
65 OH_AVCapability *cap = OH_AVCodec_GetCapabilityByCategory(g_codecMime.c_str(), false, SOFTWARE);
66 const char *tmpCodecName = OH_AVCapability_GetName(cap);
67 g_codecName = tmpCodecName;
68 cout << "g_codecName: " << g_codecName << endl;
69 }
70
TearDownTestCase()71 void HevcswdecInnerApiNdkTest::TearDownTestCase() {}
72
SetUp()73 void HevcswdecInnerApiNdkTest::SetUp()
74 {
75 signal_ = make_shared<VDecInnerSignal>();
76 }
77
TearDown()78 void HevcswdecInnerApiNdkTest::TearDown()
79 {
80 if (signal_) {
81 signal_ = nullptr;
82 }
83
84 if (vdec_ != nullptr) {
85 vdec_->Release();
86 vdec_ = nullptr;
87 }
88 }
89 } // namespace
90
91 namespace {
92 /**
93 * @tc.number : VIDEO_HWDEC_ILLEGAL_PARA_0100
94 * @tc.name : CreateByMime para1 error
95 * @tc.desc : param test
96 */
97 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_ILLEGAL_PARA_0100, TestSize.Level2)
98 {
99 if (!access("/system/lib64/media/", 0)) {
100 vdec_ = VideoDecoderFactory::CreateByMime("");
101 ASSERT_EQ(nullptr, vdec_);
102 }
103 }
104
105 /**
106 * @tc.number : VIDEO_HWDEC_ILLEGAL_PARA_0300
107 * @tc.name : CreateByName para error
108 * @tc.desc : param test
109 */
110 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_ILLEGAL_PARA_0300, TestSize.Level2)
111 {
112 if (!access("/system/lib64/media/", 0)) {
113 vdec_ = VideoDecoderFactory::CreateByName("");
114 ASSERT_EQ(nullptr, vdec_);
115 }
116 }
117
118 /**
119 * @tc.number : VIDEO_HWDEC_ILLEGAL_PARA_0500
120 * @tc.name : SetCallback para error
121 * @tc.desc : para test
122 */
123 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_ILLEGAL_PARA_0500, TestSize.Level2)
124 {
125 if (!access("/system/lib64/media/", 0)) {
126 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
127 ASSERT_NE(nullptr, vdec_);
128
129 std::shared_ptr<VDecInnerCallback> cb_ = make_shared<VDecInnerCallback>(nullptr);
130 int32_t ret = vdec_->SetCallback(cb_);
131 ASSERT_EQ(AVCS_ERR_OK, ret);
132 }
133 }
134
135 /**
136 * @tc.number : VIDEO_HWDEC_ILLEGAL_PARA_0600
137 * @tc.name : SetOutputSurface para error
138 * @tc.desc : param test
139 */
140 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_ILLEGAL_PARA_0600, TestSize.Level2)
141 {
142 if (!access("/system/lib64/media/", 0)) {
143 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
144 ASSERT_NE(nullptr, vdec_);
145 ASSERT_EQ(AVCS_ERR_NO_MEMORY, vdec_->SetOutputSurface(nullptr));
146 }
147 }
148
149 /**
150 * @tc.number : VIDEO_HWDEC_ILLEGAL_PARA_0700
151 * @tc.name : CreateByName para error
152 * @tc.desc : param test
153 */
154 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_ILLEGAL_PARA_0700, TestSize.Level2)
155 {
156 if (!access("/system/lib64/media/", 0)) {
157 vdec_ = VideoDecoderFactory::CreateByName(g_invalidCodecMime);
158 ASSERT_EQ(nullptr, vdec_);
159 }
160 }
161
162 /**
163 * @tc.number : VIDEO_HWDEC_ILLEGAL_PARA_0800
164 * @tc.name : CreateByMime para error
165 * @tc.desc : param test
166 */
167 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_ILLEGAL_PARA_0800, TestSize.Level2)
168 {
169 if (!access("/system/lib64/media/", 0)) {
170 vdec_ = VideoDecoderFactory::CreateByMime(g_invalidCodecMime);
171 ASSERT_EQ(nullptr, vdec_);
172 }
173 }
174
175 /**
176 * @tc.number : VIDEO_HWDEC_ILLEGAL_PARA_0900
177 * @tc.name : ReleaseOutputBuffer para error
178 * @tc.desc : param test
179 */
180 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_ILLEGAL_PARA_0900, TestSize.Level2)
181 {
182 if (!access("/system/lib64/media/", 0)) {
183 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
184 ASSERT_NE(nullptr, vdec_);
185 ASSERT_EQ(AVCS_ERR_INVALID_STATE, vdec_->ReleaseOutputBuffer(0, true));
186 }
187 }
188
189 /**
190 * @tc.number : VIDEO_HWDEC_ILLEGAL_PARA_1000
191 * @tc.name : ReleaseOutputBuffer para error
192 * @tc.desc : param test
193 */
194 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_ILLEGAL_PARA_1000, TestSize.Level2)
195 {
196 if (!access("/system/lib64/media/", 0)) {
197 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
198 ASSERT_NE(nullptr, vdec_);
199 ASSERT_EQ(AVCS_ERR_INVALID_STATE, vdec_->ReleaseOutputBuffer(0, false));
200 }
201 }
202
203 /**
204 * @tc.number : VIDEO_HWDEC_ILLEGAL_PARA_1100
205 * @tc.name : ReleaseOutputBuffer para error
206 * @tc.desc : param test
207 */
208 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_ILLEGAL_PARA_1100, TestSize.Level2)
209 {
210 if (!access("/system/lib64/media/", 0)) {
211 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
212 ASSERT_NE(nullptr, vdec_);
213 ASSERT_EQ(AVCS_ERR_INVALID_STATE, vdec_->ReleaseOutputBuffer(-1, false));
214 }
215 }
216
217 /**
218 * @tc.number : VIDEO_HWDEC_ILLEGAL_PARA_1200
219 * @tc.name : QueueInputBuffer para error
220 * @tc.desc : param test
221 */
222 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_ILLEGAL_PARA_1200, TestSize.Level2)
223 {
224 if (!access("/system/lib64/media/", 0)) {
225 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
226 ASSERT_NE(nullptr, vdec_);
227
228 AVCodecBufferInfo info;
229 info.presentationTimeUs = -1;
230 info.size = -1;
231 info.offset = -1;
232 AVCodecBufferFlag flag = AVCODEC_BUFFER_FLAG_EOS;
233 ASSERT_EQ(AVCS_ERR_INVALID_STATE, vdec_->QueueInputBuffer(0, info, flag));
234 }
235 }
236
237 /**
238 * @tc.number : VIDEO_HWDEC_API_0100
239 * @tc.name : CreateByName CreateByName
240 * @tc.desc : api test
241 */
242 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_0100, TestSize.Level2)
243 {
244 if (!access("/system/lib64/media/", 0)) {
245 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
246 ASSERT_NE(nullptr, vdec_);
247
248 std::shared_ptr<AVCodecVideoDecoder> vdec_2 = VideoDecoderFactory::CreateByName(g_codecName);
249 ASSERT_NE(nullptr, vdec_2);
250 ASSERT_EQ(AVCS_ERR_OK, vdec_2->Release());
251 vdec_2 = nullptr;
252 }
253 }
254
255 /**
256 * @tc.number : VIDEO_HWDEC_API_0200
257 * @tc.name : create configure configure
258 * @tc.desc : api test
259 */
260 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_0200, TestSize.Level2)
261 {
262 if (!access("/system/lib64/media/", 0)) {
263 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
264 ASSERT_NE(nullptr, vdec_);
265
266 Format format;
267 format.PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH);
268 format.PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT);
269 format.PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, static_cast<int32_t>(VideoPixelFormat::NV12));
270 format.PutDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
271
272 ASSERT_EQ(AVCS_ERR_OK, vdec_->Configure(format));
273 ASSERT_EQ(AVCS_ERR_INVALID_STATE, vdec_->Configure(format));
274 }
275 }
276
277 /**
278 * @tc.number : VIDEO_HWDEC_API_0300
279 * @tc.name : create configure start start
280 * @tc.desc : api test
281 */
282 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_0300, TestSize.Level2)
283 {
284 if (!access("/system/lib64/media/", 0)) {
285 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
286 ASSERT_NE(nullptr, vdec_);
287
288 Format format;
289 format.PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH);
290 format.PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT);
291 format.PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, static_cast<int32_t>(VideoPixelFormat::NV12));
292 format.PutDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
293
294 ASSERT_EQ(AVCS_ERR_OK, vdec_->Configure(format));
295 ASSERT_EQ(AVCS_ERR_OK, vdec_->Start());
296 ASSERT_EQ(AVCS_ERR_INVALID_STATE, vdec_->Start());
297 }
298 }
299
300 /**
301 * @tc.number : VIDEO_HWDEC_API_0400
302 * @tc.name : create configure start stop stop
303 * @tc.desc : api test
304 */
305 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_0400, TestSize.Level2)
306 {
307 if (!access("/system/lib64/media/", 0)) {
308 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
309 ASSERT_NE(nullptr, vdec_);
310
311 Format format;
312 format.PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH);
313 format.PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT);
314 format.PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, static_cast<int32_t>(VideoPixelFormat::NV12));
315 format.PutDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
316
317 ASSERT_EQ(AVCS_ERR_OK, vdec_->Configure(format));
318 ASSERT_EQ(AVCS_ERR_OK, vdec_->Start());
319 ASSERT_EQ(AVCS_ERR_OK, vdec_->Stop());
320 ASSERT_EQ(AVCS_ERR_OK, vdec_->Stop());
321 }
322 }
323
324 /**
325 * @tc.number : VIDEO_HWDEC_API_0500
326 * @tc.name : create configure start stop reset reset
327 * @tc.desc : api test
328 */
329 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_0500, TestSize.Level2)
330 {
331 if (!access("/system/lib64/media/", 0)) {
332 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
333 ASSERT_NE(nullptr, vdec_);
334
335 Format format;
336 format.PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH);
337 format.PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT);
338 format.PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, static_cast<int32_t>(VideoPixelFormat::NV12));
339 format.PutDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
340
341 ASSERT_EQ(AVCS_ERR_OK, vdec_->Configure(format));
342 ASSERT_EQ(AVCS_ERR_OK, vdec_->Start());
343 ASSERT_EQ(AVCS_ERR_OK, vdec_->Stop());
344 ASSERT_EQ(AVCS_ERR_OK, vdec_->Reset());
345 ASSERT_EQ(AVCS_ERR_OK, vdec_->Reset());
346 }
347 }
348
349 /**
350 * @tc.number : VIDEO_HWDEC_API_0600
351 * @tc.name : create configure start EOS EOS
352 * @tc.desc : api test
353 */
354 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_0600, TestSize.Level2)
355 {
356 if (!access("/system/lib64/media/", 0)) {
357 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
358 ASSERT_NE(nullptr, vdec_);
359
360 Format format;
361 int32_t ret = AVCS_ERR_OK;
362 format.PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH);
363 format.PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT);
364 format.PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, static_cast<int32_t>(VideoPixelFormat::NV12));
365 format.PutDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
366 ASSERT_EQ(AVCS_ERR_OK, vdec_->Configure(format));
367
368 std::shared_ptr<VDecInnerCallback> cb_ = make_shared<VDecInnerCallback>(signal_);
369 ASSERT_EQ(AVCS_ERR_OK, vdec_->SetCallback(cb_));
370 ASSERT_EQ(AVCS_ERR_OK, vdec_->Start());
371 int kTestFrameCount = 2;
372 for (int i = 0; i < kTestFrameCount; i++) {
373 {
374 std::unique_lock<std::mutex> lock(signal_->inMutex_);
375 bool hasData = signal_->inCond_.wait_for(lock, std::chrono::seconds(5),
__anon0f8441900302() 376 [&]() { return !signal_->inIdxQueue_.empty(); });
377 ASSERT_TRUE(hasData);
378
379 uint32_t bufferIndex = signal_->inIdxQueue_.front();
380 signal_->inIdxQueue_.pop();
381
382 std::cout << "Processing buffer slot: " << bufferIndex << std::endl;
383 ret = vdec_->QueueInputBuffer(bufferIndex);
384 if (ret != AVCS_ERR_OK) {
385 signal_->inIdxQueue_.push(bufferIndex);
386 ASSERT_EQ(AVCS_ERR_OK, ret);
387 }
388 }
389 }
390 }
391 }
392
393 /**
394 * @tc.number : VIDEO_HWDEC_API_0700
395 * @tc.name : create configure start flush flush
396 * @tc.desc : api test
397 */
398 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_0700, TestSize.Level2)
399 {
400 if (!access("/system/lib64/media/", 0)) {
401 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
402 ASSERT_NE(nullptr, vdec_);
403
404 Format format;
405 format.PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH);
406 format.PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT);
407 format.PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, static_cast<int32_t>(VideoPixelFormat::NV12));
408 format.PutDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
409
410 ASSERT_EQ(AVCS_ERR_OK, vdec_->Configure(format));
411 ASSERT_EQ(AVCS_ERR_OK, vdec_->Start());
412 ASSERT_EQ(AVCS_ERR_OK, vdec_->Flush());
413 ASSERT_EQ(AVCS_ERR_OK, vdec_->Flush());
414 }
415 }
416
417 /**
418 * @tc.number : VIDEO_HWDEC_API_0800
419 * @tc.name : create configure start stop release
420 * @tc.desc : api test
421 */
422 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_0800, TestSize.Level2)
423 {
424 if (!access("/system/lib64/media/", 0)) {
425 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
426 ASSERT_NE(nullptr, vdec_);
427
428 Format format;
429 format.PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH);
430 format.PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT);
431 format.PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, static_cast<int32_t>(VideoPixelFormat::NV12));
432 format.PutDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
433
434 ASSERT_EQ(AVCS_ERR_OK, vdec_->Configure(format));
435 ASSERT_EQ(AVCS_ERR_OK, vdec_->Start());
436 ASSERT_EQ(AVCS_ERR_OK, vdec_->Stop());
437 ASSERT_EQ(AVCS_ERR_OK, vdec_->Release());
438 vdec_ = nullptr;
439 }
440 }
441
442 /**
443 * @tc.number : VIDEO_HWDEC_API_0900
444 * @tc.name : create create
445 * @tc.desc : api test
446 */
447 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_0900, TestSize.Level2)
448 {
449 if (!access("/system/lib64/media/", 0)) {
450 vdec_ = VideoDecoderFactory::CreateByMime(g_codecMime);
451 ASSERT_NE(nullptr, vdec_);
452
453 std::shared_ptr<AVCodecVideoDecoder> vdec_2 = VideoDecoderFactory::CreateByMime(g_codecMime);
454 ASSERT_NE(nullptr, vdec_2);
455 ASSERT_EQ(AVCS_ERR_OK, vdec_2->Release());
456 vdec_2 = nullptr;
457 }
458 }
459
460 /**
461 * @tc.number : VIDEO_HWDEC_API_1000
462 * @tc.name : repeat SetCallback
463 * @tc.desc : api test
464 */
465 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_1000, TestSize.Level2)
466 {
467 if (!access("/system/lib64/media/", 0)) {
468 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
469 ASSERT_NE(nullptr, vdec_);
470
471 std::shared_ptr<VDecInnerCallback> cb_ = make_shared<VDecInnerCallback>(nullptr);
472 ASSERT_EQ(AVCS_ERR_OK, vdec_->SetCallback(cb_));
473 ASSERT_EQ(AVCS_ERR_OK, vdec_->SetCallback(cb_));
474 }
475 }
476
477 /**
478 * @tc.number : VIDEO_HWDEC_API_1100
479 * @tc.name : repeat GetOutputFormat
480 * @tc.desc : api test
481 */
482 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_1100, TestSize.Level2)
483 {
484 if (!access("/system/lib64/media/", 0)) {
485 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
486 ASSERT_NE(nullptr, vdec_);
487
488 Format format;
489 ASSERT_EQ(AVCS_ERR_OK, vdec_->GetOutputFormat(format));
490 ASSERT_EQ(AVCS_ERR_OK, vdec_->GetOutputFormat(format));
491 }
492 }
493
494 /**
495 * @tc.number : VIDEO_HWDEC_API_1200
496 * @tc.name : repeat SetParameter
497 * @tc.desc : api test
498 */
499 HWTEST_F(HevcswdecInnerApiNdkTest, VIDEO_HWDEC_API_1200, TestSize.Level2)
500 {
501 if (!access("/system/lib64/media/", 0)) {
502 vdec_ = VideoDecoderFactory::CreateByName(g_codecName);
503 ASSERT_NE(nullptr, vdec_);
504
505 Format format;
506 format.PutIntValue(MediaDescriptionKey::MD_KEY_WIDTH, DEFAULT_WIDTH);
507 format.PutIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, DEFAULT_HEIGHT);
508 format.PutIntValue(MediaDescriptionKey::MD_KEY_PIXEL_FORMAT, static_cast<int32_t>(VideoPixelFormat::NV12));
509 format.PutDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, DEFAULT_FRAME_RATE);
510
511 ASSERT_EQ(AVCS_ERR_INVALID_STATE, vdec_->SetParameter(format));
512 ASSERT_EQ(AVCS_ERR_INVALID_STATE, vdec_->SetParameter(format));
513 }
514 }
515
516 /**
517 * @tc.number : API11_VIDEO_SWDEC_FUNCTION_1300
518 * @tc.name : Normal decoding process
519 * @tc.desc : api test
520 */
521 HWTEST_F(HevcswdecInnerApiNdkTest, API11_VIDEO_SWDEC_FUNCTION_1300, TestSize.Level2)
522 {
523 if (!access("/system/lib64/media/", 0)) {
524 shared_ptr<VDecNdkInnerSample> vDecSample = make_shared<VDecNdkInnerSample>();
525 vDecSample->INP_DIR = INP_DIR_1080_30;
526 vDecSample->DEFAULT_WIDTH = 1920;
527 vDecSample->DEFAULT_HEIGHT = 1080;
528 vDecSample->DEFAULT_FRAME_RATE = 30;
529 vDecSample->SF_OUTPUT = false;
530 ASSERT_EQ(AVCS_ERR_OK, vDecSample->RunVideoDecoder(g_codecName));
531 vDecSample->WaitForEOS();
532 }
533 }
534 } // namespace