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