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 <string>
17 #include <thread>
18 #include "gtest/gtest.h"
19 #include "AudioDecoderDemoCommon.h"
20 
21 
22 using namespace std;
23 using namespace testing::ext;
24 using namespace OHOS;
25 using namespace OHOS::MediaAVCodec;
26 constexpr int32_t SIZE_7 = 7;
27 constexpr int32_t SIZE_5 = 5;
28 constexpr int32_t SIZE_4 = 4;
29 constexpr int32_t INDEX_0 = 0;
30 constexpr int32_t INDEX_1 = 1;
31 constexpr int32_t INDEX_2 = 2;
32 constexpr int32_t INDEX_3 = 3;
33 constexpr int32_t INDEX_4 = 4;
34 constexpr int32_t INDEX_5 = 5;
35 constexpr int32_t AMRWB_CHANNEL_COUNT = 1;
36 constexpr int32_t AMRWB_SAMPLE_RATE = 16000;
37 constexpr int32_t AMRNB_CHANNEL_COUNT = 1;
38 constexpr int32_t AMRNB_SAMPLE_RATE = 8000;
39 
40 namespace {
41     class NativeFunctionTest : public testing::Test {
42     public:
43         static void SetUpTestCase();
44         static void TearDownTestCase();
45         void SetUp() override;
46         void TearDown() override;
47     };
48 
SetUpTestCase()49     void NativeFunctionTest::SetUpTestCase() {}
TearDownTestCase()50     void NativeFunctionTest::TearDownTestCase() {}
SetUp()51     void NativeFunctionTest::SetUp() {}
TearDown()52     void NativeFunctionTest::TearDown() {}
53 
54     constexpr uint32_t DEFAULT_AAC_TYPE = 1;
55     int32_t testResult[16] = { -1 };
56 
SplitStringFully(const string & str,const string & separator)57     vector<string> SplitStringFully(const string& str, const string& separator)
58     {
59         vector<string> dest;
60         string substring;
61         string::size_type start = 0;
62         string::size_type index = str.find_first_of(separator, start);
63 
64         while (index != string::npos) {
65             substring = str.substr(start, index - start);
66             dest.push_back(substring);
67             start = str.find_first_not_of(separator, index);
68             if (start == string::npos) {
69                 return dest;
70             }
71             index = str.find_first_of(separator, start);
72         }
73         substring = str.substr(start);
74         dest.push_back(substring);
75 
76         return dest;
77     }
78 
string_replace(std::string & strBig,const std::string & strsrc,const std::string & strdst)79     void string_replace(std::string& strBig, const std::string& strsrc, const std::string& strdst)
80     {
81         std::string::size_type pos = 0;
82         std::string::size_type srclen = strsrc.size();
83         std::string::size_type dstlen = strdst.size();
84 
85         while ((pos = strBig.find(strsrc, pos)) != std::string::npos) {
86             strBig.replace(pos, srclen, strdst);
87             pos += dstlen;
88         }
89     }
90 
compareFile(string file1,string file2)91     bool compareFile(string file1, string file2)
92     {
93         string ans1, ans2;
94         (void)freopen(file1.c_str(), "r", stdin);
95         char c;
96         while (scanf_s("%c", &c, 1) != EOF) {
97             ans1 += c;
98         }
99         (void)fclose(stdin);
100 
101         (void)freopen(file2.c_str(), "r", stdin);
102         while (scanf_s("%c", &c, 1) != EOF) {
103             ans2 += c;
104         }
105         (void)fclose(stdin);
106 
107         if (ans1.size() != ans2.size()) {
108             return false;
109         }
110         for (uint32_t i = 0; i < ans1.size(); i++) {
111             if (ans1[i] != ans2[i]) {
112                 return false;
113             }
114         }
115         return true;
116     }
117 
getParamsByName(string decoderName,string inputFile,int32_t & channelCount,int32_t & sampleRate,long & bitrate)118     void getParamsByName(string decoderName, string inputFile, int32_t& channelCount,
119         int32_t& sampleRate, long& bitrate)
120     {
121         vector<string> dest = SplitStringFully(inputFile, "_");
122         if (decoderName == "OH.Media.Codec.Decoder.Audio.AAC") {
123             if (dest.size() < SIZE_7) {
124                 cout << "split error !!!" << endl;
125                 return;
126             }
127             channelCount = stoi(dest[INDEX_5]);
128             sampleRate = stoi(dest[INDEX_4]);
129 
130             string bitStr = dest[INDEX_3];
131             string_replace(bitStr, "k", "000");
132             bitrate = atol(bitStr.c_str());
133         } else if (decoderName == "OH.Media.Codec.Decoder.Audio.Mpeg") {
134             if (dest.size() < SIZE_5) {
135                 cout << "split error !!!" << endl;
136                 return;
137             }
138             channelCount = stoi(dest[INDEX_3]);
139             sampleRate = stoi(dest[INDEX_2]);
140 
141             string bitStr = dest[INDEX_1];
142             string_replace(bitStr, "k", "000");
143             bitrate = atol(bitStr.c_str());
144         } else if (decoderName == "OH.Media.Codec.Decoder.Audio.Flac") {
145             if (dest.size() < SIZE_4) {
146                 cout << "split error !!!" << endl;
147                 return;
148             }
149             channelCount = stoi(dest[INDEX_2]);
150             sampleRate = stoi(dest[INDEX_1]);
151 
152             string bitStr = dest[INDEX_1];
153             string_replace(bitStr, "k", "000");
154             bitrate = atol(bitStr.c_str());
155         } else {
156             if (dest.size() < SIZE_5) {
157                 cout << "split error !!!" << endl;
158                 return;
159             }
160             channelCount = stoi(dest[INDEX_3]);
161             sampleRate = stoi(dest[INDEX_2]);
162 
163             string bitStr = dest[INDEX_1];
164             string_replace(bitStr, "k", "000");
165             bitrate = atol(bitStr.c_str());
166         }
167     }
168 
runDecode(string decoderName,string inputFile,string outputFile,int32_t threadId)169     void runDecode(string decoderName, string inputFile, string outputFile, int32_t threadId)
170     {
171         AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
172         int32_t channelCount;
173         int32_t sampleRate;
174         long bitrate;
175         getParamsByName(decoderName, inputFile, channelCount, sampleRate, bitrate);
176         if (decoderName == "OH.Media.Codec.Decoder.Audio.AAC") {
177             OH_AVFormat* format = OH_AVFormat_Create();
178             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
179             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
180             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AAC_IS_ADTS, DEFAULT_AAC_TYPE);
181 
182             decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
183             OH_AVFormat_Destroy(format);
184         } else if (decoderName == "OH.Media.Codec.Decoder.Audio.Mpeg") {
185             OH_AVFormat* format = OH_AVFormat_Create();
186             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
187             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
188 
189             decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
190 
191             OH_AVFormat_Destroy(format);
192         } else if (decoderName == "OH.Media.Codec.Decoder.Audio.Flac") {
193             OH_AVFormat* format = OH_AVFormat_Create();
194             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
195             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
196             OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITS_PER_CODED_SAMPLE, OH_BitsPerSample::SAMPLE_S16P);
197             OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
198 
199             decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
200 
201             OH_AVFormat_Destroy(format);
202         } else if (decoderName == "OH.Media.Codec.Decoder.Audio.Amrwb") {
203             OH_AVFormat* format = OH_AVFormat_Create();
204             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, AMRWB_CHANNEL_COUNT);
205             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, AMRWB_SAMPLE_RATE);
206 
207             decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
208 
209             OH_AVFormat_Destroy(format);
210         } else if (decoderName == "OH.Media.Codec.Decoder.Audio.Amrnb") {
211             OH_AVFormat* format = OH_AVFormat_Create();
212             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, AMRNB_CHANNEL_COUNT);
213             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, AMRNB_SAMPLE_RATE);
214 
215             decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
216 
217             OH_AVFormat_Destroy(format);
218         } else {
219             OH_AVFormat* format = OH_AVFormat_Create();
220             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
221             OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
222 
223             decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
224             OH_AVFormat_Destroy(format);
225         }
226         testResult[threadId] = AV_ERR_OK;
227         delete decoderDemo;
228     }
229 }
230 
231 
232 /**
233  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_001
234  * @tc.name      : aac(different sample rate)
235  * @tc.desc      : function check
236  */
237 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_001, TestSize.Level2)
238 {
239     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
240     string decoderName = "OH.Media.Codec.Decoder.Audio.AAC";
241 
242     string fileList[] = {"fltp_aac_low_128k_7350_1_dayuhaitang.aac", "fltp_aac_low_128k_16000_1_dayuhaitang.aac",
243         "fltp_aac_low_128k_44100_1_dayuhaitang.aac", "fltp_aac_low_128k_48000_1_dayuhaitang.aac",
244         "fltp_aac_low_128k_96000_1_dayuhaitang.aac"};
245 
246     for (int i = 0; i < SIZE_5; i++)
247     {
248         vector<string> dest = SplitStringFully(fileList[i], "_");
249         if (dest.size() < SIZE_7)
250         {
251             cout << "split error !!!" << endl;
252             return;
253         }
254         int32_t channelCount = stoi(dest[INDEX_5]);
255         int32_t sampleRate = stoi(dest[INDEX_4]);
256 
257         string bitStr = dest[INDEX_3];
258         string_replace(bitStr, "k", "000");
259         long bitrate = atol(bitStr.c_str());
260 
261         OH_AVFormat* format = OH_AVFormat_Create();
262         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
263         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
264         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AAC_IS_ADTS, DEFAULT_AAC_TYPE);
265         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
266         ASSERT_NE(nullptr, format);
267 
268         string inputFile = fileList[i];
269         string outputFile = "FUNCTION_001_" + to_string(sampleRate) + ".pcm";
270 
271         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
272 
273         OH_AVFormat_Destroy(format);
274     }
275     delete decoderDemo;
276 }
277 
278 
279 /**
280  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_002
281  * @tc.name      : aac(different channel num)
282  * @tc.desc      : function check
283  */
284 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_002, TestSize.Level2)
285 {
286     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
287     string decoderName = "OH.Media.Codec.Decoder.Audio.AAC";
288 
289     string fileList[] = { "fltp_aac_low_128k_44100_1_dayuhaitang.aac", "fltp_aac_low_128k_44100_2_dayuhaitang.aac",
290     "fltp_aac_low_128k_44100_8_dayuhaitang.aac" };
291 
292     for (int i = 0; i < 3; i++)
293     {
294         vector<string> dest = SplitStringFully(fileList[i], "_");
295         if (dest.size() < SIZE_7)
296         {
297             cout << "split error !!!" << endl;
298             return;
299         }
300         int32_t channelCount = stoi(dest[INDEX_5]);
301         int32_t sampleRate = stoi(dest[INDEX_4]);
302 
303         string bitStr = dest[INDEX_3];
304         string_replace(bitStr, "k", "000");
305         long bitrate = atol(bitStr.c_str());
306 
307         OH_AVFormat* format = OH_AVFormat_Create();
308         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
309         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
310         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AAC_IS_ADTS, DEFAULT_AAC_TYPE);
311         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
312         ASSERT_NE(nullptr, format);
313 
314         string inputFile = fileList[i];
315         string outputFile = "FUNCTION_002_" + to_string(channelCount) + ".pcm";
316 
317         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
318 
319         OH_AVFormat_Destroy(format);
320     }
321     delete decoderDemo;
322 }
323 
324 
325 /**
326  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_003
327  * @tc.name      : aac(different bitrate)
328  * @tc.desc      : function check
329  */
330 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_003, TestSize.Level2)
331 {
332     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
333     string decoderName = "OH.Media.Codec.Decoder.Audio.AAC";
334 
335     string fileList[] = { "fltp_aac_low_32k_16000_2_dayuhaitang.aac", "fltp_aac_low_128k_44100_2_dayuhaitang.aac",
336     "fltp_aac_low_500k_96000_2_dayuhaitang.aac" };
337 
338     for (int i = 0; i < 3; i++)
339     {
340         vector<string> dest = SplitStringFully(fileList[i], "_");
341         if (dest.size() < SIZE_7)
342         {
343             cout << "split error !!!" << endl;
344             return;
345         }
346         int32_t channelCount = stoi(dest[INDEX_5]);
347         int32_t sampleRate = stoi(dest[INDEX_4]);
348 
349         string bitStr = dest[INDEX_3];
350         string_replace(bitStr, "k", "000");
351         long bitrate = atol(bitStr.c_str());
352 
353         OH_AVFormat* format = OH_AVFormat_Create();
354         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
355         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
356         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AAC_IS_ADTS, DEFAULT_AAC_TYPE);
357         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
358         ASSERT_NE(nullptr, format);
359 
360         string inputFile = fileList[i];
361         string outputFile = "FUNCTION_003_" + to_string(bitrate) + ".pcm";
362 
363         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
364 
365         OH_AVFormat_Destroy(format);
366     }
367     delete decoderDemo;
368 }
369 
370 
371 /**
372  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_004
373  * @tc.name      : mp3(different sample rate)
374  * @tc.desc      : function check
375  */
376 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_004, TestSize.Level2)
377 {
378     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
379     string decoderName = "OH.Media.Codec.Decoder.Audio.Mpeg";
380 
381     string fileList[] = { "fltp_40k_8000_2_dayuhaitang.mp3", "fltp_40k_16000_2_dayuhaitang.mp3",
382     "fltp_40k_44100_2_dayuhaitang.mp3", "fltp_40k_48000_2_dayuhaitang.mp3"};
383 
384     for (int i = 0; i < 4; i++)
385     {
386         vector<string> dest = SplitStringFully(fileList[i], "_");
387         if (dest.size() < SIZE_5)
388         {
389             cout << "split error !!!" << endl;
390             return;
391         }
392         int32_t channelCount = stoi(dest[INDEX_3]);
393         int32_t sampleRate = stoi(dest[INDEX_2]);
394 
395         string bitStr = dest[INDEX_1];
396         string_replace(bitStr, "k", "000");
397         long bitrate = atol(bitStr.c_str());
398 
399         OH_AVFormat* format = OH_AVFormat_Create();
400         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
401         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
402         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
403         ASSERT_NE(nullptr, format);
404 
405         string inputFile = fileList[i];
406         string outputFile = "FUNCTION_004_" + to_string(sampleRate) + ".pcm";
407 
408         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
409 
410         OH_AVFormat_Destroy(format);
411     }
412     delete decoderDemo;
413 }
414 
415 
416 /**
417  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_005
418  * @tc.name      : mp3(different sample format)
419  * @tc.desc      : function check
420  */
421 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_005, TestSize.Level2)
422 {
423     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
424     string decoderName = "OH.Media.Codec.Decoder.Audio.Mpeg";
425 
426     string fileList[] = { "fltp_128k_48000_2_dayuhaitang.mp3", "s16p_128k_48000_2_dayuhaitang.mp3"};
427 
428     for (int i = 0; i < 2; i++)
429     {
430         vector<string> dest = SplitStringFully(fileList[i], "_");
431         if (dest.size() < SIZE_5)
432         {
433             cout << "split error !!!" << endl;
434             return;
435         }
436         int32_t channelCount = stoi(dest[INDEX_3]);
437         int32_t sampleRate = stoi(dest[INDEX_2]);
438 
439         string bitStr = dest[INDEX_1];
440         string_replace(bitStr, "k", "000");
441         long bitrate = atol(bitStr.c_str());
442         string sampleFormat = dest[INDEX_0];
443 
444         OH_AVFormat* format = OH_AVFormat_Create();
445         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
446         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
447         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
448         ASSERT_NE(nullptr, format);
449 
450         string inputFile = fileList[i];
451         string outputFile = "FUNCTION_005_" + sampleFormat + ".pcm";
452 
453         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
454 
455         OH_AVFormat_Destroy(format);
456     }
457     delete decoderDemo;
458 }
459 
460 
461 /**
462  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_006
463  * @tc.name      : mp3(different channel num)
464  * @tc.desc      : function check
465  */
466 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_006, TestSize.Level2)
467 {
468     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
469     string decoderName = "OH.Media.Codec.Decoder.Audio.Mpeg";
470 
471     string fileList[] = { "fltp_128k_44100_1_dayuhaitang.mp3", "fltp_128k_44100_2_dayuhaitang.mp3" };
472 
473     for (int i = 0; i < 2; i++)
474     {
475         vector<string> dest = SplitStringFully(fileList[i], "_");
476         if (dest.size() < SIZE_5)
477         {
478             cout << "split error !!!" << endl;
479             return;
480         }
481         int32_t channelCount = stoi(dest[INDEX_3]);
482         int32_t sampleRate = stoi(dest[INDEX_2]);
483 
484         string bitStr = dest[INDEX_1];
485         string_replace(bitStr, "k", "000");
486         long bitrate = atol(bitStr.c_str());
487 
488         OH_AVFormat* format = OH_AVFormat_Create();
489         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
490         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
491         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
492         ASSERT_NE(nullptr, format);
493 
494         string inputFile = fileList[i];
495         string outputFile = "FUNCTION_006_" + to_string(channelCount) + ".pcm";
496 
497         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
498 
499         OH_AVFormat_Destroy(format);
500     }
501     delete decoderDemo;
502 }
503 
504 
505 /**
506  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_007
507  * @tc.name      : mp3(different bitrate)
508  * @tc.desc      : function check
509  */
510 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_007, TestSize.Level2)
511 {
512     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
513     string decoderName = "OH.Media.Codec.Decoder.Audio.Mpeg";
514 
515     string fileList[] = { "fltp_40k_44100_2_dayuhaitang.mp3", "fltp_128k_44100_2_dayuhaitang.mp3",
516     "fltp_320k_44100_2_dayuhaitang.mp3"};
517 
518     for (int i = 0; i < 3; i++)
519     {
520         vector<string> dest = SplitStringFully(fileList[i], "_");
521         if (dest.size() < SIZE_5)
522         {
523             cout << "split error !!!" << endl;
524             return;
525         }
526         int32_t channelCount = stoi(dest[INDEX_3]);
527         int32_t sampleRate = stoi(dest[INDEX_2]);
528 
529         string bitStr = dest[INDEX_1];
530         string_replace(bitStr, "k", "000");
531         long bitrate = atol(bitStr.c_str());
532 
533         OH_AVFormat* format = OH_AVFormat_Create();
534         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
535         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
536         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
537         ASSERT_NE(nullptr, format);
538 
539         string inputFile = fileList[i];
540         string outputFile = "FUNCTION_007_" + to_string(bitrate) + ".pcm";
541 
542         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
543 
544         OH_AVFormat_Destroy(format);
545     }
546     delete decoderDemo;
547 }
548 
549 
550 /**
551  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_008
552  * @tc.name      : flac(different sample rate)
553  * @tc.desc      : function check
554  */
555 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_008, TestSize.Level2)
556 {
557     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
558     string decoderName = "OH.Media.Codec.Decoder.Audio.Flac";
559 
560     string fileList[] = { "s16_8000_2_dayuhaitang.flac", "s16_16000_2_dayuhaitang.flac",
561     "s16_44100_2_dayuhaitang.flac", "s16_48000_2_dayuhaitang.flac"};
562 
563     for (int i = 0; i < SIZE_4; i++)
564     {
565         vector<string> dest = SplitStringFully(fileList[i], "_");
566         if (dest.size() < 4)
567         {
568             cout << "split error !!!" << endl;
569             return;
570         }
571         int32_t channelCount = stoi(dest[INDEX_2]);
572         int32_t sampleRate = stoi(dest[INDEX_1]);
573 
574         string bitStr = dest[INDEX_1];
575         string_replace(bitStr, "k", "000");
576         long bitrate = atol(bitStr.c_str());
577 
578         OH_AVFormat* format = OH_AVFormat_Create();
579         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
580         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
581         OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITS_PER_CODED_SAMPLE, OH_BitsPerSample::SAMPLE_S16P);
582         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
583         ASSERT_NE(nullptr, format);
584 
585         string inputFile = fileList[i];
586         string outputFile = "FUNCTION_008_" + to_string(sampleRate) + ".pcm";
587 
588         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
589 
590         OH_AVFormat_Destroy(format);
591     }
592     delete decoderDemo;
593 }
594 
595 
596 /**
597  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_009
598  * @tc.name      : flac(different sample format)
599  * @tc.desc      : function check
600  */
601 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_009, TestSize.Level2)
602 {
603     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
604     string decoderName = "OH.Media.Codec.Decoder.Audio.Flac";
605 
606     string fileList[] = { "s16_48000_2_dayuhaitang.flac", "s32_48000_2_dayuhaitang.flac"};
607 
608     for (int i = 0; i < 2; i++)
609     {
610         vector<string> dest = SplitStringFully(fileList[i], "_");
611         if (dest.size() < 4)
612         {
613             cout << "split error !!!" << endl;
614             return;
615         }
616         int32_t channelCount = stoi(dest[INDEX_2]);
617         int32_t sampleRate = stoi(dest[INDEX_1]);
618 
619         string bitStr = dest[INDEX_1];
620         string_replace(bitStr, "k", "000");
621         long bitrate = atol(bitStr.c_str());
622         string sampleFormat = dest[INDEX_0];
623 
624         OH_AVFormat* format = OH_AVFormat_Create();
625         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
626         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
627         OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITS_PER_CODED_SAMPLE, OH_BitsPerSample::SAMPLE_S16P);
628         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
629         ASSERT_NE(nullptr, format);
630 
631         string inputFile = fileList[i];
632         string outputFile = "FUNCTION_009_" + sampleFormat + ".pcm";
633 
634         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
635 
636         OH_AVFormat_Destroy(format);
637     }
638     delete decoderDemo;
639 }
640 
641 
642 /**
643  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_010
644  * @tc.name      : flac(different channel num)
645  * @tc.desc      : function check
646  */
647 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_010, TestSize.Level2)
648 {
649     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
650     string decoderName = "OH.Media.Codec.Decoder.Audio.Flac";
651 
652     string fileList[] = { "s16_48000_1_dayuhaitang.flac", "s16_48000_2_dayuhaitang.flac",
653     "s16_48000_8_dayuhaitang.flac"};
654 
655     for (int i = 0; i < 3; i++)
656     {
657         vector<string> dest = SplitStringFully(fileList[i], "_");
658         if (dest.size() < 4)
659         {
660             cout << "split error !!!" << endl;
661             return;
662         }
663         int32_t channelCount = stoi(dest[INDEX_2]);
664         int32_t sampleRate = stoi(dest[INDEX_1]);
665 
666         string bitStr = dest[INDEX_1];
667         string_replace(bitStr, "k", "000");
668         long bitrate = atol(bitStr.c_str());
669 
670         OH_AVFormat* format = OH_AVFormat_Create();
671         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
672         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
673         OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITS_PER_CODED_SAMPLE, OH_BitsPerSample::SAMPLE_S16P);
674         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
675         ASSERT_NE(nullptr, format);
676 
677         string inputFile = fileList[i];
678         string outputFile = "FUNCTION_010_" + to_string(channelCount) + ".pcm";
679 
680         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
681 
682         OH_AVFormat_Destroy(format);
683     }
684     delete decoderDemo;
685 }
686 
687 
688 /**
689  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_011
690  * @tc.name      : vorbis(different sample rate)
691  * @tc.desc      : function check
692  */
693 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_011, TestSize.Level2)
694 {
695     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
696     string decoderName = "OH.Media.Codec.Decoder.Audio.Vorbis";
697 
698     string fileList[] = { "fltp_45k_8000_2_dayuhaitang.ogg", "fltp_45k_16000_2_dayuhaitang.ogg",
699     "fltp_45k_44100_2_dayuhaitang.ogg", "fltp_45k_48000_2_dayuhaitang.ogg",
700     "fltp_280k_96000_2_dayuhaitang.ogg"};
701 
702     for (int i = 0; i < 5; i++)
703     {
704         vector<string> dest = SplitStringFully(fileList[i], "_");
705         if (dest.size() < 5)
706         {
707             cout << "split error !!!" << endl;
708             return;
709         }
710         int32_t channelCount = stoi(dest[INDEX_3]);
711         int32_t sampleRate = stoi(dest[INDEX_2]);
712 
713         string bitStr = dest[INDEX_1];
714         string_replace(bitStr, "k", "000");
715         long bitrate = atol(bitStr.c_str());
716 
717         OH_AVFormat* format = OH_AVFormat_Create();
718         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
719         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
720         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
721         ASSERT_NE(nullptr, format);
722 
723         string inputFile = fileList[i];
724         string outputFile = "FUNCTION_011_" + to_string(sampleRate) + ".pcm";
725 
726         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
727 
728         OH_AVFormat_Destroy(format);
729     }
730     delete decoderDemo;
731 }
732 
733 
734 /**
735  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_012
736  * @tc.name      : vorbis(different channel num)
737  * @tc.desc      : function check
738  */
739 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_012, TestSize.Level2)
740 {
741     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
742     string decoderName = "OH.Media.Codec.Decoder.Audio.Vorbis";
743 
744     string fileList[] = { "fltp_128k_48000_1_dayuhaitang.ogg", "fltp_128k_48000_2_dayuhaitang.ogg",
745     "fltp_500k_48000_8_dayuhaitang.ogg"};
746 
747     for (int i = 0; i < 3; i++)
748     {
749         vector<string> dest = SplitStringFully(fileList[i], "_");
750         if (dest.size() < SIZE_5)
751         {
752             cout << "split error !!!" << endl;
753             return;
754         }
755         int32_t channelCount = stoi(dest[INDEX_3]);
756         int32_t sampleRate = stoi(dest[INDEX_2]);
757 
758         string bitStr = dest[INDEX_1];
759         string_replace(bitStr, "k", "000");
760         long bitrate = atol(bitStr.c_str());
761 
762         OH_AVFormat* format = OH_AVFormat_Create();
763         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
764         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
765         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
766         ASSERT_NE(nullptr, format);
767 
768         string inputFile = fileList[i];
769         string outputFile = "FUNCTION_012_" + to_string(channelCount) + ".pcm";
770 
771         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
772 
773         OH_AVFormat_Destroy(format);
774     }
775     delete decoderDemo;
776 }
777 
778 
779 /**
780  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_013
781  * @tc.name      : vorbis(different bitrate)
782  * @tc.desc      : function check
783  */
784 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_013, TestSize.Level2)
785 {
786     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
787     string decoderName = "OH.Media.Codec.Decoder.Audio.Vorbis";
788 
789     string fileList[] = { "fltp_45k_48000_2_dayuhaitang.ogg", "fltp_128k_48000_2_dayuhaitang.ogg",
790     "fltp_500k_48000_2_dayuhaitang.ogg" };
791 
792     for (int i = 0; i < 3; i++)
793     {
794         vector<string> dest = SplitStringFully(fileList[i], "_");
795         if (dest.size() < SIZE_5)
796         {
797             cout << "split error !!!" << endl;
798             return;
799         }
800         int32_t channelCount = stoi(dest[INDEX_3]);
801         int32_t sampleRate = stoi(dest[INDEX_2]);
802 
803         string bitStr = dest[INDEX_1];
804         string_replace(bitStr, "k", "000");
805         long bitrate = atol(bitStr.c_str());
806 
807         OH_AVFormat* format = OH_AVFormat_Create();
808         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
809         OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
810         OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
811         ASSERT_NE(nullptr, format);
812 
813         string inputFile = fileList[i];
814         string outputFile = "FUNCTION_013_" + to_string(bitrate) + ".pcm";
815 
816         decoderDemo->NativeRunCase(inputFile, outputFile, decoderName.c_str(), format);
817 
818         OH_AVFormat_Destroy(format);
819     }
820     delete decoderDemo;
821 }
822 
823 
824 /**
825  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_014
826  * @tc.name      : Flush(AAC)
827  * @tc.desc      : function check
828  */
829 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_014, TestSize.Level2)
830 {
831     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
832     string decoderName = "OH.Media.Codec.Decoder.Audio.AAC";
833 
834     string inputFile = "fltp_aac_low_128k_16000_1_dayuhaitang.aac";
835     string firstOutputFile = "FUNCTION_014_1.pcm";
836     string secondOutputFile = "FUNCTION_014_2.pcm";
837 
838     vector<string> dest = SplitStringFully(inputFile, "_");
839     if (dest.size() < SIZE_7)
840     {
841         cout << "split error !!!" << endl;
842         return;
843     }
844     int32_t channelCount = stoi(dest[INDEX_5]);
845     int32_t sampleRate = stoi(dest[INDEX_4]);
846 
847     string bitStr = dest[INDEX_3];
848     string_replace(bitStr, "k", "000");
849     long bitrate = atol(bitStr.c_str());
850 
851     OH_AVFormat* format = OH_AVFormat_Create();
852     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
853     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
854     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AAC_IS_ADTS, DEFAULT_AAC_TYPE);
855     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
856 
857     decoderDemo->NativeRunCaseFlush(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
858 
859     bool isSame = compareFile(firstOutputFile, secondOutputFile);
860     ASSERT_EQ(true, isSame);
861 
862     OH_AVFormat_Destroy(format);
863     delete decoderDemo;
864 }
865 
866 
867 /**
868  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_015
869  * @tc.name      : Flush(mp3)
870  * @tc.desc      : function check
871  */
872 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_015, TestSize.Level2)
873 {
874     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
875     string decoderName = "OH.Media.Codec.Decoder.Audio.Mpeg";
876 
877     string inputFile = "fltp_40k_16000_2_dayuhaitang.mp3";
878     string firstOutputFile = "FUNCTION_015_1.pcm";
879     string secondOutputFile = "FUNCTION_015_2.pcm";
880 
881     vector<string> dest = SplitStringFully(inputFile, "_");
882     if (dest.size() < SIZE_5)
883     {
884         cout << "split error !!!" << endl;
885         return;
886     }
887     int32_t channelCount = stoi(dest[INDEX_3]);
888     int32_t sampleRate = stoi(dest[INDEX_2]);
889 
890     string bitStr = dest[INDEX_1];
891     string_replace(bitStr, "k", "000");
892     long bitrate = atol(bitStr.c_str());
893 
894     OH_AVFormat* format = OH_AVFormat_Create();
895     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
896     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
897     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
898 
899     decoderDemo->NativeRunCaseFlush(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
900 
901     bool isSame = compareFile(firstOutputFile, secondOutputFile);
902     ASSERT_EQ(true, isSame);
903 
904     OH_AVFormat_Destroy(format);
905     delete decoderDemo;
906 }
907 
908 
909 /**
910  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_016
911  * @tc.name      : Flush(flac)
912  * @tc.desc      : function check
913  */
914 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_016, TestSize.Level2)
915 {
916     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
917     string decoderName = "OH.Media.Codec.Decoder.Audio.Flac";
918 
919     string inputFile = "s16_8000_2_dayuhaitang.flac";
920     string firstOutputFile = "FUNCTION_016_1.pcm";
921     string secondOutputFile = "FUNCTION_016_2.pcm";
922 
923     vector<string> dest = SplitStringFully(inputFile, "_");
924     if (dest.size() < 4)
925     {
926         cout << "split error !!!" << endl;
927         return;
928     }
929     int32_t channelCount = stoi(dest[INDEX_2]);
930     int32_t sampleRate = stoi(dest[INDEX_1]);
931 
932     string bitStr = dest[INDEX_1];
933     string_replace(bitStr, "k", "000");
934     long bitrate = atol(bitStr.c_str());
935 
936     OH_AVFormat* format = OH_AVFormat_Create();
937     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
938     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
939     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
940     OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITS_PER_CODED_SAMPLE, OH_BitsPerSample::SAMPLE_S16P);
941 
942     decoderDemo->NativeRunCaseFlush(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
943 
944     bool isSame = compareFile(firstOutputFile, secondOutputFile);
945     ASSERT_EQ(true, isSame);
946 
947     OH_AVFormat_Destroy(format);
948     delete decoderDemo;
949 }
950 
951 
952 /**
953  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_017
954  * @tc.name      : Flush(vorbis)
955  * @tc.desc      : function check
956  */
957 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_017, TestSize.Level2)
958 {
959     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
960     string decoderName = "OH.Media.Codec.Decoder.Audio.Vorbis";
961 
962     string inputFile = "fltp_45k_8000_2_dayuhaitang.ogg";
963     string firstOutputFile = "FUNCTION_017_1.pcm";
964     string secondOutputFile = "FUNCTION_017_2.pcm";
965 
966     vector<string> dest = SplitStringFully(inputFile, "_");
967     if (dest.size() < 5)
968     {
969         cout << "split error !!!" << endl;
970         return;
971     }
972     int32_t channelCount = stoi(dest[INDEX_3]);
973     int32_t sampleRate = stoi(dest[INDEX_2]);
974 
975     string bitStr = dest[INDEX_1];
976     string_replace(bitStr, "k", "000");
977     long bitrate = atol(bitStr.c_str());
978 
979     OH_AVFormat* format = OH_AVFormat_Create();
980     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
981     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
982     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
983 
984     decoderDemo->NativeRunCaseFlush(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
985 
986     bool isSame = compareFile(firstOutputFile, secondOutputFile);
987     ASSERT_EQ(true, isSame);
988 
989     OH_AVFormat_Destroy(format);
990     delete decoderDemo;
991 }
992 
993 /**
994  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_017
995  * @tc.name      : Flush(amrwb)
996  * @tc.desc      : function check
997  */
998 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_FLUSH_AMRWB, TestSize.Level2)
999 {
1000     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1001     string decoderName = "OH.Media.Codec.Decoder.Audio.Amrwb";
1002 
1003     string inputFile = "voice_amrwb_23850.amr";
1004     string firstOutputFile = "FUNCTION_FLUSH_AMRWB_1.pcm";
1005     string secondOutputFile = "FUNCTION_FLUSH_AMRWB_2.pcm";
1006 
1007     int32_t channelCount = AMRWB_CHANNEL_COUNT;
1008     int32_t sampleRate = AMRWB_SAMPLE_RATE;
1009 
1010     OH_AVFormat* format = OH_AVFormat_Create();
1011     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
1012     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
1013 
1014     decoderDemo->NativeRunCaseFlush(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
1015 
1016     bool isSame = compareFile(firstOutputFile, secondOutputFile);
1017     ASSERT_EQ(true, isSame);
1018 
1019     OH_AVFormat_Destroy(format);
1020     delete decoderDemo;
1021 }
1022 
1023 /**
1024  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_017
1025  * @tc.name      : Flush(amrnb)
1026  * @tc.desc      : function check
1027  */
1028 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_FLUSH_AMRNB, TestSize.Level2)
1029 {
1030     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1031     string decoderName = "OH.Media.Codec.Decoder.Audio.Amrnb";
1032 
1033     string inputFile = "voice_amrnb_12200.amr";
1034     string firstOutputFile = "FUNCTION_FLUSH_AMRNB_1.pcm";
1035     string secondOutputFile = "FUNCTION_FLUSH_AMRNB_2.pcm";
1036 
1037     int32_t channelCount = AMRNB_CHANNEL_COUNT;
1038     int32_t sampleRate = AMRNB_SAMPLE_RATE;
1039 
1040     OH_AVFormat* format = OH_AVFormat_Create();
1041     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
1042     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
1043 
1044     decoderDemo->NativeRunCaseFlush(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
1045 
1046     bool isSame = compareFile(firstOutputFile, secondOutputFile);
1047     ASSERT_EQ(true, isSame);
1048 
1049     OH_AVFormat_Destroy(format);
1050     delete decoderDemo;
1051 }
1052 
1053 /**
1054  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_018
1055  * @tc.name      : Reset(AAC)
1056  * @tc.desc      : function check
1057  */
1058 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_018, TestSize.Level2)
1059 {
1060     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1061     string decoderName = "OH.Media.Codec.Decoder.Audio.AAC";
1062 
1063     string inputFile = "fltp_aac_low_128k_16000_1_dayuhaitang.aac";
1064     string firstOutputFile = "FUNCTION_018_1.pcm";
1065     string secondOutputFile = "FUNCTION_018_2.pcm";
1066 
1067     vector<string> dest = SplitStringFully(inputFile, "_");
1068     if (dest.size() < 7)
1069     {
1070         cout << "split error !!!" << endl;
1071         return;
1072     }
1073     int32_t channelCount = stoi(dest[INDEX_5]);
1074     int32_t sampleRate = stoi(dest[INDEX_4]);
1075 
1076     string bitStr = dest[INDEX_3];
1077     string_replace(bitStr, "k", "000");
1078     long bitrate = atol(bitStr.c_str());
1079 
1080     OH_AVFormat* format = OH_AVFormat_Create();
1081     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
1082     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
1083     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AAC_IS_ADTS, DEFAULT_AAC_TYPE);
1084     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
1085 
1086     decoderDemo->NativeRunCaseReset(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
1087 
1088     bool isSame = compareFile(firstOutputFile, secondOutputFile);
1089     ASSERT_EQ(true, isSame);
1090 
1091     OH_AVFormat_Destroy(format);
1092     delete decoderDemo;
1093 }
1094 
1095 
1096 /**
1097  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_019
1098  * @tc.name      : Reset(mp3)
1099  * @tc.desc      : function check
1100  */
1101 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_019, TestSize.Level2)
1102 {
1103     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1104     string decoderName = "OH.Media.Codec.Decoder.Audio.Mpeg";
1105 
1106     string inputFile = "fltp_40k_16000_2_dayuhaitang.mp3";
1107     string firstOutputFile = "FUNCTION_019_1.pcm";
1108     string secondOutputFile = "FUNCTION_019_2.pcm";
1109 
1110     vector<string> dest = SplitStringFully(inputFile, "_");
1111     if (dest.size() < 5)
1112     {
1113         cout << "split error !!!" << endl;
1114         return;
1115     }
1116     int32_t channelCount = stoi(dest[INDEX_3]);
1117     int32_t sampleRate = stoi(dest[INDEX_2]);
1118 
1119     string bitStr = dest[INDEX_1];
1120     string_replace(bitStr, "k", "000");
1121     long bitrate = atol(bitStr.c_str());
1122 
1123     OH_AVFormat* format = OH_AVFormat_Create();
1124     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
1125     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
1126     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
1127 
1128     decoderDemo->NativeRunCaseReset(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
1129 
1130     bool isSame = compareFile(firstOutputFile, secondOutputFile);
1131     ASSERT_EQ(true, isSame);
1132 
1133     OH_AVFormat_Destroy(format);
1134     delete decoderDemo;
1135 }
1136 
1137 
1138 /**
1139  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_020
1140  * @tc.name      : Reset(flac)
1141  * @tc.desc      : function check
1142  */
1143 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_020, TestSize.Level2)
1144 {
1145     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1146     string decoderName = "OH.Media.Codec.Decoder.Audio.Flac";
1147 
1148     string inputFile = "s16_8000_2_dayuhaitang.flac";
1149     string firstOutputFile = "FUNCTION_020_1.pcm";
1150     string secondOutputFile = "FUNCTION_020_2.pcm";
1151 
1152     vector<string> dest = SplitStringFully(inputFile, "_");
1153     if (dest.size() < 4)
1154     {
1155         cout << "split error !!!" << endl;
1156         return;
1157     }
1158     int32_t channelCount = stoi(dest[INDEX_2]);
1159     int32_t sampleRate = stoi(dest[INDEX_1]);
1160 
1161     string bitStr = dest[INDEX_1];
1162     string_replace(bitStr, "k", "000");
1163     long bitrate = atol(bitStr.c_str());
1164 
1165     OH_AVFormat* format = OH_AVFormat_Create();
1166     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
1167     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
1168     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
1169     OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITS_PER_CODED_SAMPLE, OH_BitsPerSample::SAMPLE_S16P);
1170 
1171     decoderDemo->NativeRunCaseReset(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
1172 
1173     bool isSame = compareFile(firstOutputFile, secondOutputFile);
1174     ASSERT_EQ(true, isSame);
1175 
1176     OH_AVFormat_Destroy(format);
1177     delete decoderDemo;
1178 }
1179 
1180 
1181 /**
1182  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_021
1183  * @tc.name      : Reset(vorbis)
1184  * @tc.desc      : function check
1185  */
1186 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_021, TestSize.Level2)
1187 {
1188     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1189     string decoderName = "OH.Media.Codec.Decoder.Audio.Vorbis";
1190 
1191     string inputFile = "fltp_45k_48000_2_dayuhaitang.ogg";
1192     string firstOutputFile = "FUNCTION_021_1.pcm";
1193     string secondOutputFile = "FUNCTION_021_2.pcm";
1194 
1195     vector<string> dest = SplitStringFully(inputFile, "_");
1196     if (dest.size() < 5)
1197     {
1198         cout << "split error !!!" << endl;
1199         return;
1200     }
1201     int32_t channelCount = stoi(dest[INDEX_3]);
1202     int32_t sampleRate = stoi(dest[INDEX_2]);
1203 
1204     string bitStr = dest[INDEX_1];
1205     string_replace(bitStr, "k", "000");
1206     long bitrate = atol(bitStr.c_str());
1207 
1208     OH_AVFormat* format = OH_AVFormat_Create();
1209     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
1210     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
1211     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
1212 
1213     decoderDemo->NativeRunCaseReset(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
1214 
1215     bool isSame = compareFile(firstOutputFile, secondOutputFile);
1216     ASSERT_EQ(true, isSame);
1217 
1218     OH_AVFormat_Destroy(format);
1219     delete decoderDemo;
1220 }
1221 
1222 /**
1223  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_021
1224  * @tc.name      : Reset(Amrwb)
1225  * @tc.desc      : function check
1226  */
1227 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_AMRWB_RESET, TestSize.Level2)
1228 {
1229     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1230     string decoderName = "OH.Media.Codec.Decoder.Audio.Amrwb";
1231 
1232     string inputFile = "voice_amrwb_23850.amr";
1233     string firstOutputFile = "FUNCTION_AMRWB_RESET_1.pcm";
1234     string secondOutputFile = "FUNCTION_AMRWB_RESET_2.pcm";
1235 
1236     OH_AVFormat* format = OH_AVFormat_Create();
1237     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, AMRWB_CHANNEL_COUNT);
1238     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, AMRWB_SAMPLE_RATE);
1239 
1240     decoderDemo->NativeRunCaseReset(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
1241 
1242     bool isSame = compareFile(firstOutputFile, secondOutputFile);
1243     ASSERT_EQ(true, isSame);
1244 
1245     OH_AVFormat_Destroy(format);
1246     delete decoderDemo;
1247 }
1248 
1249 /**
1250  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_021
1251  * @tc.name      : Reset(Amrnb)
1252  * @tc.desc      : function check
1253  */
1254 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_AMRNB_RESET, TestSize.Level2)
1255 {
1256     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1257     string decoderName = "OH.Media.Codec.Decoder.Audio.Amrnb";
1258 
1259     string inputFile = "voice_amrnb_12200.amr";
1260     string firstOutputFile = "FUNCTION_AMRNB_RESET_1.pcm";
1261     string secondOutputFile = "FUNCTION_AMRNB_RESET_2.pcm";
1262 
1263     OH_AVFormat* format = OH_AVFormat_Create();
1264     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, AMRNB_CHANNEL_COUNT);
1265     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, AMRNB_SAMPLE_RATE);
1266 
1267     decoderDemo->NativeRunCaseReset(inputFile, firstOutputFile, secondOutputFile, decoderName.c_str(), format);
1268 
1269     bool isSame = compareFile(firstOutputFile, secondOutputFile);
1270     ASSERT_EQ(true, isSame);
1271 
1272     OH_AVFormat_Destroy(format);
1273     delete decoderDemo;
1274 }
1275 
1276 /**
1277  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_022
1278  * @tc.name      : OH_AudioDecoder_GetOutputDescription
1279  * @tc.desc      : function check
1280  */
1281 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_022, TestSize.Level2)
1282 {
1283     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1284     string decoderName = "OH.Media.Codec.Decoder.Audio.AAC";
1285 
1286     string inputFile = "fltp_aac_low_128k_16000_1_dayuhaitang.aac";
1287     string outputFile = "FUNCTION_018_1.pcm";
1288 
1289     vector<string> dest = SplitStringFully(inputFile, "_");
1290     if (dest.size() < 7)
1291     {
1292         cout << "split error !!!" << endl;
1293         return;
1294     }
1295     int32_t channelCount = stoi(dest[INDEX_5]);
1296     int32_t sampleRate = stoi(dest[INDEX_4]);
1297 
1298     string bitStr = dest[INDEX_3];
1299     string_replace(bitStr, "k", "000");
1300     long bitrate = atol(bitStr.c_str());
1301 
1302     OH_AVFormat* format = OH_AVFormat_Create();
1303     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, channelCount);
1304     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, sampleRate);
1305     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AAC_IS_ADTS, DEFAULT_AAC_TYPE);
1306     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitrate);
1307 
1308     OH_AVFormat* formatGet = decoderDemo->NativeRunCaseGetOutputDescription(inputFile,
1309     outputFile, decoderName.c_str(), format);
1310     ASSERT_NE(nullptr, formatGet);
1311 
1312     int32_t channelNum_Get;
1313     int32_t sampleRate_Get;
1314     int64_t bitrate_Get;
1315     OH_AVFormat_GetIntValue(formatGet, OH_MD_KEY_AUD_CHANNEL_COUNT, &channelNum_Get);
1316     OH_AVFormat_GetIntValue(formatGet, OH_MD_KEY_AUD_SAMPLE_RATE, &sampleRate_Get);
1317     OH_AVFormat_GetLongValue(formatGet, OH_MD_KEY_BITRATE, &bitrate_Get);
1318     ASSERT_EQ(channelCount, channelNum_Get);
1319     ASSERT_EQ(sampleRate, sampleRate_Get);
1320     ASSERT_EQ(bitrate, bitrate_Get);
1321 
1322     OH_AVFormat_Destroy(format);
1323     delete decoderDemo;
1324 }
1325 
1326 
1327 /**
1328  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_023
1329  * @tc.name      : AAC(thread)
1330  * @tc.desc      : Function test
1331  */
1332 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_023, TestSize.Level2)
1333 {
1334     vector<thread> threadVec;
1335     string decoderName = "OH.Media.Codec.Decoder.Audio.AAC";
1336 
1337     string inputFile = "fltp_aac_low_128k_16000_1_dayuhaitang.aac";
1338 
1339     for (int32_t i = 0; i < 16; i++)
1340     {
1341         string outputFile = "FUNCTION_023_" + to_string(i) + ".pcm";
1342         threadVec.push_back(thread(runDecode, decoderName, inputFile, outputFile, i));
1343     }
1344     for (uint32_t i = 0; i < threadVec.size(); i++)
1345     {
1346         threadVec[i].join();
1347     }
1348     for (int32_t i = 0; i < 16; i++)
1349     {
1350         ASSERT_EQ(AV_ERR_OK, testResult[i]);
1351     }
1352 }
1353 
1354 
1355 /**
1356  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_024
1357  * @tc.name      : MP3(thread)
1358  * @tc.desc      : Function test
1359  */
1360 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_024, TestSize.Level2)
1361 {
1362     vector<thread> threadVec;
1363     string decoderName = "OH.Media.Codec.Decoder.Audio.Mpeg";
1364 
1365     string inputFile = "fltp_40k_16000_2_dayuhaitang.mp3";
1366 
1367     for (int32_t i = 0; i < 16; i++)
1368     {
1369         string outputFile = "FUNCTION_024_" + to_string(i) + ".pcm";
1370         threadVec.push_back(thread(runDecode, decoderName, inputFile, outputFile, i));
1371     }
1372     for (uint32_t i = 0; i < threadVec.size(); i++)
1373     {
1374         threadVec[i].join();
1375     }
1376     for (int32_t i = 0; i < 16; i++)
1377     {
1378         ASSERT_EQ(AV_ERR_OK, testResult[i]);
1379     }
1380 }
1381 
1382 
1383 /**
1384  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_025
1385  * @tc.name      : Flac(thread)
1386  * @tc.desc      : Function test
1387  */
1388 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_025, TestSize.Level2)
1389 {
1390     vector<thread> threadVec;
1391     string decoderName = "OH.Media.Codec.Decoder.Audio.Flac";
1392 
1393     string inputFile = "s16_8000_2_dayuhaitang.flac";
1394 
1395     for (int32_t i = 0; i < 16; i++)
1396     {
1397         string outputFile = "FUNCTION_025_" + to_string(i) + ".pcm";
1398         threadVec.push_back(thread(runDecode, decoderName, inputFile, outputFile, i));
1399     }
1400     for (uint32_t i = 0; i < threadVec.size(); i++)
1401     {
1402         threadVec[i].join();
1403     }
1404     for (int32_t i = 0; i < 16; i++)
1405     {
1406         ASSERT_EQ(AV_ERR_OK, testResult[i]);
1407     }
1408 }
1409 
1410 
1411 /**
1412  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_026
1413  * @tc.name      : Vorbis(thread)
1414  * @tc.desc      : Function test
1415  */
1416 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_026, TestSize.Level2)
1417 {
1418     vector<thread> threadVec;
1419     string decoderName = "OH.Media.Codec.Decoder.Audio.Vorbis";
1420 
1421     string inputFile = "fltp_45k_48000_2_dayuhaitang.ogg";
1422 
1423     for (int32_t i = 0; i < 16; i++)
1424     {
1425         string outputFile = "FUNCTION_026_" + to_string(i) + ".pcm";
1426         threadVec.push_back(thread(runDecode, decoderName, inputFile, outputFile, i));
1427     }
1428     for (uint32_t i = 0; i < threadVec.size(); i++)
1429     {
1430         threadVec[i].join();
1431     }
1432     for (int32_t i = 0; i < 16; i++)
1433     {
1434         ASSERT_EQ(AV_ERR_OK, testResult[i]);
1435     }
1436 }
1437 
1438 /**
1439  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_026
1440  * @tc.name      : Amrwb(thread)
1441  * @tc.desc      : Function test
1442  */
1443 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_THREAD_AMRWB, TestSize.Level2)
1444 {
1445     vector<thread> threadVec;
1446     string decoderName = "OH.Media.Codec.Decoder.Audio.Amrwb";
1447 
1448     string inputFile = "voice_amrwb_23850.amr";
1449 
1450     for (int32_t i = 0; i < 16; i++)
1451     {
1452         string outputFile = "FUNCTION_THREAD_AMRWB_" + to_string(i) + ".pcm";
1453         threadVec.push_back(thread(runDecode, decoderName, inputFile, outputFile, i));
1454     }
1455     for (uint32_t i = 0; i < threadVec.size(); i++)
1456     {
1457         threadVec[i].join();
1458     }
1459     for (int32_t i = 0; i < 16; i++)
1460     {
1461         ASSERT_EQ(AV_ERR_OK, testResult[i]);
1462     }
1463 }
1464 
1465 /**
1466  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_026
1467  * @tc.name      : Amrnb(thread)
1468  * @tc.desc      : Function test
1469  */
1470 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_THREAD_AMRNB, TestSize.Level2)
1471 {
1472     vector<thread> threadVec;
1473     string decoderName = "OH.Media.Codec.Decoder.Audio.Amrnb";
1474 
1475     string inputFile = "voice_amrnb_12200.amr";
1476 
1477     for (int32_t i = 0; i < 16; i++)
1478     {
1479         string outputFile = "FUNCTION_THREAD_AMRNB_" + to_string(i) + ".pcm";
1480         threadVec.push_back(thread(runDecode, decoderName, inputFile, outputFile, i));
1481     }
1482     for (uint32_t i = 0; i < threadVec.size(); i++)
1483     {
1484         threadVec[i].join();
1485     }
1486     for (int32_t i = 0; i < 16; i++)
1487     {
1488         ASSERT_EQ(AV_ERR_OK, testResult[i]);
1489     }
1490 }
1491 
1492 /**
1493  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_100
1494  * @tc.name      : AAC
1495  * @tc.desc      : Function test
1496  */
1497 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_100, TestSize.Level2)
1498 {
1499     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1500     string decoderName = "OH.Media.Codec.Decoder.Audio.AAC";
1501 
1502     string inputFile = "wmxq_01_2.0.BIN.aac";
1503     string outputFile = "FUNCTION_100.pcm";
1504 
1505     OH_AVFormat* format = OH_AVFormat_Create();
1506     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, 2);
1507     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, 48000);
1508     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AAC_IS_ADTS, DEFAULT_AAC_TYPE);
1509     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, 192000);
1510     ASSERT_NE(nullptr, format);
1511 
1512     decoderDemo->NativeRunCasePerformance(inputFile, outputFile, decoderName.c_str(), format);
1513 
1514     OH_AVFormat_Destroy(format);
1515     delete decoderDemo;
1516 }
1517 
1518 
1519 /**
1520  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_200
1521  * @tc.name      : MP3
1522  * @tc.desc      : Function test
1523  */
1524 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_200, TestSize.Level2)
1525 {
1526     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1527     string decoderName = "OH.Media.Codec.Decoder.Audio.Mpeg";
1528 
1529     string inputFile = "B_Bird_on_a_wire_L.mp3";
1530     string outputFile = "FUNCTION_200.pcm";
1531 
1532     OH_AVFormat* format = OH_AVFormat_Create();
1533     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, 1);
1534     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, 48000);
1535     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, 192000);
1536     ASSERT_NE(nullptr, format);
1537 
1538     decoderDemo->NativeRunCasePerformance(inputFile, outputFile, decoderName.c_str(), format);
1539 
1540     OH_AVFormat_Destroy(format);
1541     delete decoderDemo;
1542 }
1543 
1544 
1545 /**
1546  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_300
1547  * @tc.name      : FLAC
1548  * @tc.desc      : Function test
1549  */
1550 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_300, TestSize.Level2)
1551 {
1552     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1553     string decoderName = "OH.Media.Codec.Decoder.Audio.Flac";
1554 
1555     string inputFile = "B_Bird_on_a_wire_1.flac";
1556     string outputFile = "FUNCTION_300.pcm";
1557 
1558     OH_AVFormat* format = OH_AVFormat_Create();
1559     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, 1);
1560     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, 48000);
1561     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, 435000);
1562     OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITS_PER_CODED_SAMPLE, OH_BitsPerSample::SAMPLE_S16P);
1563     ASSERT_NE(nullptr, format);
1564 
1565     decoderDemo->NativeRunCasePerformance(inputFile, outputFile, decoderName.c_str(), format);
1566 
1567     OH_AVFormat_Destroy(format);
1568     delete decoderDemo;
1569 }
1570 
1571 
1572 /**
1573  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_301
1574  * @tc.name      : FLAC(free)
1575  * @tc.desc      : Function test
1576  */
1577 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_301, TestSize.Level2)
1578 {
1579     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1580     string decoderName = "OH.Media.Codec.Decoder.Audio.Flac";
1581 
1582     string inputFile = "free_loss.flac";
1583     string outputFile = "FUNCTION_301.pcm";
1584 
1585     OH_AVFormat* format = OH_AVFormat_Create();
1586     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, 1);
1587     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, 96000);
1588     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, 622000);
1589     OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITS_PER_CODED_SAMPLE, OH_BitsPerSample::SAMPLE_S16P);
1590     ASSERT_NE(nullptr, format);
1591 
1592     decoderDemo->NativeRunCasePerformance(inputFile, outputFile, decoderName.c_str(), format);
1593 
1594     OH_AVFormat_Destroy(format);
1595     delete decoderDemo;
1596 }
1597 
1598 /**
1599  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_302
1600  * @tc.name      : FLAC
1601  * @tc.desc      : Function test
1602  */
1603 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_302, TestSize.Level2)
1604 {
1605     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1606     string decoderName = "OH.Media.Codec.Decoder.Audio.Flac";
1607 
1608     string inputFile = "FUNCTION_202.dat";
1609     string outputFile = "FUNCTION_302.pcm";
1610 
1611     OH_AVFormat* format = OH_AVFormat_Create();
1612     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, 1);
1613     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, 48000);
1614     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, 435000);
1615     OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITS_PER_CODED_SAMPLE, OH_BitsPerSample::SAMPLE_S16P);
1616     ASSERT_NE(nullptr, format);
1617 
1618     decoderDemo->TestRunCase(inputFile, outputFile, decoderName.c_str(), format);
1619 
1620     OH_AVFormat_Destroy(format);
1621     delete decoderDemo;
1622 }
1623 
1624 /**
1625  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_303
1626  * @tc.name      : FLAC
1627  * @tc.desc      : Function test
1628  */
1629 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_303, TestSize.Level2)
1630 {
1631     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1632     string decoderName = "OH.Media.Codec.Decoder.Audio.Flac";
1633 
1634     string inputFile = "FUNCTION_203.dat";
1635     string outputFile = "FUNCTION_303.pcm";
1636 
1637     OH_AVFormat* format = OH_AVFormat_Create();
1638     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, 1);
1639     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, 96000);
1640     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, 622000);
1641     OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITS_PER_CODED_SAMPLE, OH_BitsPerSample::SAMPLE_S16P);
1642     ASSERT_NE(nullptr, format);
1643 
1644     decoderDemo->TestRunCase(inputFile, outputFile, decoderName.c_str(), format);
1645 
1646     OH_AVFormat_Destroy(format);
1647     delete decoderDemo;
1648 }
1649 
1650 
1651 /**
1652  * @tc.number    : SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_400
1653  * @tc.name      : Vorbis
1654  * @tc.desc      : Function test
1655  */
1656 HWTEST_F(NativeFunctionTest, SUB_MULTIMEDIA_AUDIO_DECODER_FUNCTION_400, TestSize.Level2)
1657 {
1658     AudioDecoderDemo* decoderDemo = new AudioDecoderDemo();
1659     string decoderName = "OH.Media.Codec.Decoder.Audio.Vorbis";
1660 
1661     string inputFile = "B_Bird_on_a_wire_L.ogg";
1662     string outputFile = "FUNCTION_400.pcm";
1663 
1664     OH_AVFormat* format = OH_AVFormat_Create();
1665     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_CHANNEL_COUNT, 1);
1666     OH_AVFormat_SetIntValue(format, OH_MD_KEY_AUD_SAMPLE_RATE, 48000);
1667     OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, 480000);
1668     ASSERT_NE(nullptr, format);
1669 
1670     decoderDemo->NativeRunCasePerformance(inputFile, outputFile, decoderName.c_str(), format);
1671 
1672     OH_AVFormat_Destroy(format);
1673     delete decoderDemo;
1674 }