• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "gtest/gtest.h"
17 
18 #include "native_avcodec_base.h"
19 #include "native_avdemuxer.h"
20 #include "native_avformat.h"
21 #include "native_avsource.h"
22 #include "native_avmemory.h"
23 #include "meta/meta_key.h"
24 #include "meta/meta.h"
25 #include "av_common.h"
26 
27 #include <iostream>
28 #include <cstdio>
29 #include <string>
30 #include <fcntl.h>
31 #include <cmath>
32 #include <thread>
33 
34 using namespace std;
35 using namespace OHOS;
36 using namespace OHOS::Media;
37 using namespace testing::ext;
38 
39 namespace OHOS {
40 namespace Media {
41 class DemuxerFunc2NdkTest : public testing::Test {
42 public:
43     // SetUpTestCase: Called before all test cases
44     static void SetUpTestCase(void);
45     // TearDownTestCase: Called after all test case
46     static void TearDownTestCase(void);
47     // SetUp: Called before each test cases
48     void SetUp(void);
49     // TearDown: Called after each test cases
50     void TearDown(void);
51 };
52 
53 static OH_AVMemory *memory = nullptr;
54 static OH_AVSource *source = nullptr;
55 static OH_AVDemuxer *demuxer = nullptr;
56 static OH_AVFormat *sourceFormat = nullptr;
57 static OH_AVFormat *trackFormat = nullptr;
58 static OH_AVBuffer *avBuffer = nullptr;
59 static OH_AVFormat *format = nullptr;
60 static int32_t g_trackCount;
61 static int32_t g_width = 3840;
62 static int32_t g_height = 2160;
63 constexpr int32_t THOUSAND = 1000.0;
64 constexpr int32_t TRACKNUM_0 = 0;
65 constexpr int32_t TRACKNUM_1 = 1;
66 constexpr int32_t TRACKNUM_2 = 2;
67 constexpr int32_t TRACKNUM_3 = 3;
68 constexpr int32_t TRACKNUM_4 = 4;
69 constexpr int32_t TRACKFRAME_231 = 231;
70 constexpr int32_t TRACKFRAME_431 = 431;
71 constexpr int32_t TRACKFRAME_16 = 16;
72 constexpr int32_t TRACKFRAME_77 = 77;
73 constexpr int32_t TRACKFRAME_223 = 223;
74 constexpr int32_t TRACKFRAME_417 = 417;
75 constexpr int64_t VIDEOTRACKSEEK = 900000;
76 constexpr int64_t AUDIOTRACKSEEK = 130604;
77 int32_t g_unselect = -1;
78 int g_trackType = 0;
79 const std::string TRACK_REF_TYPE_DEPTH = "vdep";
80 const std::string TRACK_REF_TYPE_PREY = "auxl";
81 const std::string TRACK_REF_TYPE_CDSC = "cdsc";
82 const std::string AUXILIARY_DEPTH_TRACK_KEY = "com.openharmony.moviemode.depth";
83 const std::string AUXILIARY_PREY_TRACK_KEY = "com.openharmony.moviemode.prey";
84 const std::string TIMED_METADATA_KEY = "timed_metadata";
85 bool g_isRefult = false;
86 bool g_initResult = false;
87 
SetUpTestCase()88 void DemuxerFunc2NdkTest::SetUpTestCase() {}
TearDownTestCase()89 void DemuxerFunc2NdkTest::TearDownTestCase() {}
SetUp()90 void DemuxerFunc2NdkTest::SetUp()
91 {
92     g_isRefult = false;
93     g_initResult = false;
94     g_unselect = -1;
95     memory = OH_AVMemory_Create(g_width * g_height);
96     g_trackCount = 0;
97 }
TearDown()98 void DemuxerFunc2NdkTest::TearDown()
99 {
100     if (trackFormat != nullptr) {
101         OH_AVFormat_Destroy(trackFormat);
102         trackFormat = nullptr;
103     }
104 
105     if (sourceFormat != nullptr) {
106         OH_AVFormat_Destroy(sourceFormat);
107         sourceFormat = nullptr;
108     }
109 
110     if (memory != nullptr) {
111         OH_AVMemory_Destroy(memory);
112         memory = nullptr;
113     }
114     if (source != nullptr) {
115         OH_AVSource_Destroy(source);
116         source = nullptr;
117     }
118     if (demuxer != nullptr) {
119         OH_AVDemuxer_Destroy(demuxer);
120         demuxer = nullptr;
121     }
122     if (avBuffer != nullptr) {
123         OH_AVBuffer_Destroy(avBuffer);
124         avBuffer = nullptr;
125     }
126     if (format != nullptr) {
127         OH_AVFormat_Destroy(format);
128         format = nullptr;
129     }
130 }
131 } // namespace Media
132 } // namespace OHOS
GetFileSize(const char * fileName)133 static int64_t GetFileSize(const char *fileName)
134 {
135     int64_t fileSize = 0;
136     if (fileName != nullptr) {
137         struct stat fileStatus {};
138         if (stat(fileName, &fileStatus) == 0) {
139             fileSize = static_cast<int64_t>(fileStatus.st_size);
140         }
141     }
142     return fileSize;
143 }
144 
OpenFile(const char * fileName,int fd,OH_AVSource ** src,OH_AVDemuxer ** audioDemuxer)145 static void OpenFile(const char *fileName, int fd, OH_AVSource **src, OH_AVDemuxer **audioDemuxer)
146 {
147     int64_t size = GetFileSize(fileName);
148     cout << fileName << "----------------------" << fd << "---------" << size << endl;
149     *src = OH_AVSource_CreateWithFD(fd, 0, size);
150     ASSERT_NE(*src, nullptr);
151 
152     *audioDemuxer = OH_AVDemuxer_CreateWithSource(*src);
153     ASSERT_NE(*audioDemuxer, nullptr);
154 }
155 
CheckTrackCount(OH_AVFormat ** srcFormat,OH_AVSource * src,int32_t * trackCount,int trackNum)156 static void CheckTrackCount(OH_AVFormat **srcFormat, OH_AVSource *src, int32_t *trackCount, int trackNum)
157 {
158     *srcFormat = OH_AVSource_GetSourceFormat(src);
159     ASSERT_TRUE(OH_AVFormat_GetIntValue(*srcFormat, OH_MD_KEY_TRACK_COUNT, trackCount));
160     ASSERT_EQ(trackNum, *trackCount);
161 }
162 
CheckTrackSelect(int32_t trackCount,OH_AVDemuxer * audioDemuxer)163 static void CheckTrackSelect(int32_t trackCount, OH_AVDemuxer *audioDemuxer)
164 {
165     for (int32_t index = 0; index < g_trackCount; index++) {
166         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, index));
167     }
168 }
169 
CountAudioFrames(OH_AVDemuxer * audioDemuxer,OH_AVMemory * mem,int32_t trackCount,int audioFrameNum,int audioKeyNum)170 static void CountAudioFrames(OH_AVDemuxer *audioDemuxer, OH_AVMemory *mem,
171                              int32_t trackCount, int audioFrameNum, int audioKeyNum)
172 {
173     int audioFrame = 0;
174     int keyCount = 0;
175     bool audioIsEnd = false;
176     OH_AVCodecBufferAttr attr;
177 
178     while (!audioIsEnd) {
179         for (int32_t index = 0; index < trackCount; index++) {
180             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSample(audioDemuxer, index, mem, &attr));
181             if (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_EOS) {
182                 audioIsEnd = true;
183                 cout << audioFrame << "    audio is end !!!!!!!!!!!!!!!" << endl;
184                 continue;
185             }
186 
187             audioFrame++;
188             if (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_SYNC_FRAME) {
189                 keyCount++;
190             }
191         }
192     }
193     ASSERT_EQ(audioFrame, audioFrameNum);
194     ASSERT_EQ(keyCount, audioKeyNum);
195 }
196 
SetVideoValue(OH_AVCodecBufferAttr attr,bool & videoIsEnd,int & videoFrame)197 static void SetVideoValue(OH_AVCodecBufferAttr attr, bool &videoIsEnd, int &videoFrame)
198 {
199     if (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_EOS) {
200         videoIsEnd = true;
201         cout << videoFrame << "   video is end !!!!!!!!!!!!!!!" << endl;
202     } else {
203         videoFrame++;
204         cout << "video track !!!!!" << endl;
205     }
206 }
InitFile(const char * file,int32_t trackNum,int & fd)207 static void InitFile(const char *file, int32_t trackNum, int &fd)
208 {
209     g_initResult = false;
210     fd = open(file, O_RDONLY);
211     int64_t size = GetFileSize(file);
212     cout << file << "----------------------" << fd << "---------" << size << endl;
213     source = OH_AVSource_CreateWithFD(fd, 0, size);
214     ASSERT_NE(source, nullptr);
215 
216     demuxer = OH_AVDemuxer_CreateWithSource(source);
217     ASSERT_NE(demuxer, nullptr);
218 
219     sourceFormat = OH_AVSource_GetSourceFormat(source);
220     ASSERT_TRUE(OH_AVFormat_GetIntValue(sourceFormat, OH_MD_KEY_TRACK_COUNT, &g_trackCount));
221     ASSERT_EQ(trackNum, g_trackCount);
222     for (int32_t index = 0; index < g_trackCount; index++) {
223         if (g_unselect != index) {
224             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, index));
225         }
226     }
227     avBuffer = OH_AVBuffer_Create(size);
228     ASSERT_NE(avBuffer, nullptr);
229     g_initResult = true;
230 }
231 
GetDepthTrack()232 static void GetDepthTrack()
233 {
234     g_isRefult = false;
235     const char *trackRefType = nullptr;
236     const char *trackdescription = nullptr;
237     int32_t *trackIdsDepth = nullptr;
238     size_t bufferSize;
239     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
240     ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_DEPTH.c_str()));
241     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
242     ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_DEPTH_TRACK_KEY.c_str()));
243     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
244         trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
245     ASSERT_EQ(TRACKNUM_2, bufferSize);
246     ASSERT_EQ(TRACKNUM_1, trackIdsDepth[TRACKNUM_0]);
247     ASSERT_EQ(TRACKNUM_3, trackIdsDepth[TRACKNUM_1]);
248     g_isRefult = true;
249 }
250 
GetPreyTrack()251 static void GetPreyTrack()
252 {
253     g_isRefult = false;
254     const char *trackRefType = nullptr;
255     const char *trackdescription = nullptr;
256     int32_t *trackIdsPrey = nullptr;
257     size_t bufferSize;
258     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
259     ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_PREY.c_str()));
260     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
261     ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_PREY_TRACK_KEY.c_str()));
262     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
263         trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsPrey, &bufferSize));
264     ASSERT_EQ(TRACKNUM_1, bufferSize);
265     ASSERT_EQ(TRACKNUM_2, trackIdsPrey[TRACKNUM_0]);
266     g_isRefult = true;
267 }
268 
GetTimedMetaTrack()269 static void GetTimedMetaTrack()
270 {
271     g_isRefult = false;
272     const char *trackRefType = nullptr;
273     const char *trackdescription = nullptr;
274     int32_t *trackIdsDepth = nullptr;
275     size_t bufferSize;
276     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
277     ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_CDSC.c_str()));
278     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
279     ASSERT_EQ(0, strcmp(trackdescription, TIMED_METADATA_KEY.c_str()));
280     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
281         trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
282     ASSERT_EQ(TRACKNUM_1, bufferSize);
283     ASSERT_EQ(TRACKNUM_1, trackIdsDepth[TRACKNUM_0]);
284     g_isRefult = true;
285 }
286 
GetDepthAndIdsTrack()287 static void GetDepthAndIdsTrack()
288 {
289     g_isRefult = false;
290     const char *trackRefType = nullptr;
291     const char *trackdescription = nullptr;
292     int32_t *trackIdsDepth = nullptr;
293     size_t bufferSize;
294     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
295     ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_DEPTH.c_str()));
296     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
297     ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_DEPTH_TRACK_KEY.c_str()));
298     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
299         trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
300     ASSERT_EQ(TRACKNUM_3, bufferSize);
301     ASSERT_EQ(TRACKNUM_0, trackIdsDepth[TRACKNUM_0]);
302     ASSERT_EQ(TRACKNUM_2, trackIdsDepth[TRACKNUM_1]);
303     ASSERT_EQ(TRACKNUM_3, trackIdsDepth[TRACKNUM_2]);
304     g_isRefult = true;
305 }
306 
GetPreyAndIdsTrack()307 static void GetPreyAndIdsTrack()
308 {
309     g_isRefult = false;
310     const char *trackRefType = nullptr;
311     const char *trackdescription = nullptr;
312     int32_t *trackIdsPrey = nullptr;
313     size_t bufferSize;
314     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
315     ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_PREY.c_str()));
316     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
317     ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_PREY_TRACK_KEY.c_str()));
318     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
319         trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsPrey, &bufferSize));
320     ASSERT_EQ(TRACKNUM_2, bufferSize);
321     ASSERT_EQ(TRACKNUM_0, trackIdsPrey[TRACKNUM_0]);
322     ASSERT_EQ(TRACKNUM_1, trackIdsPrey[TRACKNUM_1]);
323     g_isRefult = true;
324 }
325 /**
326  * @tc.number    : SUB_MEDIA_DEMUXER_VTT_6100
327  * @tc.name      : create vtt demuxer with error file -- alternating Up and Down Times
328  * @tc.desc      : function test
329  */
330 HWTEST_F(DemuxerFunc2NdkTest, SUB_MEDIA_DEMUXER_VTT_6100, TestSize.Level2)
331 {
332     OH_AVCodecBufferAttr attr;
333     const char* mimeType = nullptr;
334     const char *file = "/data/test/media/vtt_6100.vtt";
335     int fd = open(file, O_RDONLY);
336     int64_t size = GetFileSize(file);
337     cout << file << "----------------------" << fd << "---------" << size << endl;
338     source = OH_AVSource_CreateWithFD(fd, 0, size);
339     ASSERT_NE(source, nullptr);
340     demuxer = OH_AVDemuxer_CreateWithSource(source);
341     ASSERT_NE(demuxer, nullptr);
342     sourceFormat = OH_AVSource_GetSourceFormat(source);
343     trackFormat = OH_AVSource_GetTrackFormat(source, 0);
344     ASSERT_NE(trackFormat, nullptr);
345     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, &mimeType));
346     ASSERT_EQ(0, strcmp(mimeType, OH_AVCODEC_MIMETYPE_SUBTITLE_WEBVTT));
347     ASSERT_TRUE(OH_AVFormat_GetIntValue(sourceFormat, OH_MD_KEY_TRACK_COUNT, &g_trackCount));
348     ASSERT_EQ(1, g_trackCount);
349     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, 0));
350     int tarckType = 0;
351     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &tarckType));
352     ASSERT_EQ(tarckType, MEDIA_TYPE_SUBTITLE);
353     while (true) {
354         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSample(demuxer, 0, memory, &attr));
355         if (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_EOS) {
356             cout << "   vtt is end !!!!!!!!!!!!!!!" << endl;
357             break;
358         }
359         uint8_t *data = OH_AVMemory_GetAddr(memory);
360         cout << "subtitle"<< "----------------" << data << "-----------------" << endl;
361     }
362     close(fd);
363 }
364 
365 /**
366  * @tc.number    : DEMUXER_META_0090
367  * @tc.name      : demuxer meta info, souce is null
368  * @tc.desc      : function test
369  */
370 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_META_0090, TestSize.Level0)
371 {
372     OH_AVFormat *metaFormat= OH_AVSource_GetCustomMetadataFormat(nullptr);
373     ASSERT_EQ(metaFormat, nullptr);
374 }
375 
376 /**
377  * @tc.number    : DEMUXER_WAV_ALAW_FUNC_0001
378  * @tc.name      : DEMUXER_WAV_ALAW_FUNC_0001
379  * @tc.desc      : function test
380  */
381 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_WAV_ALAW_FUNC_0001, TestSize.Level2)
382 {
383     const char *file = "/data/test/media/audio/wav_alaw_410_8b_1.wav";
384     int fd = open(file, O_RDONLY);
385     OpenFile(file, fd, &source, &demuxer);
386     CheckTrackCount(&sourceFormat, source, &g_trackCount, 1);
387     CheckTrackSelect(g_trackCount, demuxer);
388     CountAudioFrames(demuxer, memory, g_trackCount, 1, 1);
389     close(fd);
390 }
391 
392 /**
393  * @tc.number    : DEMUXER_WAV_ALAW_FUNC_0002
394  * @tc.name      : DEMUXER_WAV_ALAW_FUNC_0002
395  * @tc.desc      : function test
396  */
397 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_WAV_ALAW_FUNC_0002, TestSize.Level2)
398 {
399     int64_t seekTime = 0;
400     const char *file = "/data/test/media/audio/wav_alaw_410_8b_1.wav";
401     int fd = open(file, O_RDONLY);
402     OpenFile(file, fd, &source, &demuxer);
403     CheckTrackCount(&sourceFormat, source, &g_trackCount, 1);
404     CheckTrackSelect(g_trackCount, demuxer);
405     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SeekToTime(demuxer, seekTime, SEEK_MODE_NEXT_SYNC));
406     CountAudioFrames(demuxer, memory, g_trackCount, 1, 1);
407     close(fd);
408 }
409 
410 /**
411  * @tc.number    : DEMUXER_WAV_ALAW_FUNC_0003
412  * @tc.name      : DEMUXER_WAV_ALAW_FUNC_0003
413  * @tc.desc      : function test
414  */
415 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_WAV_ALAW_FUNC_0003, TestSize.Level0)
416 {
417     const char *file = "/data/test/media/audio/wav_alaw_8K_8b_2.wav";
418     int fd = open(file, O_RDONLY);
419     OpenFile(file, fd, &source, &demuxer);
420     CheckTrackCount(&sourceFormat, source, &g_trackCount, 1);
421     CheckTrackSelect(g_trackCount, demuxer);
422     CountAudioFrames(demuxer, memory, g_trackCount, 20, 20);
423     close(fd);
424 }
425 
426 /**
427  * @tc.number    : DEMUXER_WAV_ALAW_FUNC_0004
428  * @tc.name      : DEMUXER_WAV_ALAW_FUNC_0004
429  * @tc.desc      : function test
430  */
431 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_WAV_ALAW_FUNC_0004, TestSize.Level1)
432 {
433     int32_t seekTime = 2304000;
434     int32_t thousand = 1000;
435     const char *file = "/data/test/media/audio/wav_alaw_8K_8b_2.wav";
436     int fd = open(file, O_RDONLY);
437     OpenFile(file, fd, &source, &demuxer);
438     CheckTrackCount(&sourceFormat, source, &g_trackCount, 1);
439     CheckTrackSelect(g_trackCount, demuxer);
440     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SeekToTime(demuxer, seekTime / thousand, SEEK_MODE_PREVIOUS_SYNC));
441     CountAudioFrames(demuxer, memory, g_trackCount, 11, 11);
442     close(fd);
443 }
444 
445 /**
446  * @tc.number    : DEMUXER_WAV_ALAW_FUNC_0005
447  * @tc.name      : DEMUXER_WAV_ALAW_FUNC_0005
448  * @tc.desc      : function test
449  */
450 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_WAV_ALAW_FUNC_0005, TestSize.Level2)
451 {
452     const char *file = "/data/test/media/audio/wav_alaw_16K_8b_2.wav";
453     int fd = open(file, O_RDONLY);
454     OpenFile(file, fd, &source, &demuxer);
455     CheckTrackCount(&sourceFormat, source, &g_trackCount, 1);
456     CheckTrackSelect(g_trackCount, demuxer);
457     CountAudioFrames(demuxer, memory, g_trackCount, 40, 40);
458     close(fd);
459 }
460 
461 /**
462  * @tc.number    : DEMUXER_WAV_ALAW_FUNC_0006
463  * @tc.name      : DEMUXER_WAV_ALAW_FUNC_0006
464  * @tc.desc      : function test
465  */
466 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_WAV_ALAW_FUNC_0006, TestSize.Level2)
467 {
468     int32_t seekTime = 2432000;
469     int32_t thousand = 1000;
470     const char *file = "/data/test/media/audio/wav_alaw_16K_8b_2.wav";
471     int fd = open(file, O_RDONLY);
472     OpenFile(file, fd, &source, &demuxer);
473     CheckTrackCount(&sourceFormat, source, &g_trackCount, 1);
474     CheckTrackSelect(g_trackCount, demuxer);
475     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SeekToTime(demuxer, seekTime / thousand, SEEK_MODE_CLOSEST_SYNC));
476     CountAudioFrames(demuxer, memory, g_trackCount, 21, 21);
477     close(fd);
478 }
479 
480 /**
481  * @tc.number    : DEMUXER_WAV_ALAW_FUNC_0007
482  * @tc.name      : DEMUXER_WAV_ALAW_FUNC_0007
483  * @tc.desc      : function test
484  */
485 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_WAV_ALAW_FUNC_0007, TestSize.Level2)
486 {
487     const char *file = "/data/test/media/audio/wav_alaw_48K_8b_1.wav";
488     int fd = open(file, O_RDONLY);
489     OpenFile(file, fd, &source, &demuxer);
490     CheckTrackCount(&sourceFormat, source, &g_trackCount, 1);
491     CheckTrackSelect(g_trackCount, demuxer);
492     CountAudioFrames(demuxer, memory, g_trackCount, 59, 59);
493     close(fd);
494 }
495 
496 /**
497  * @tc.number    : DEMUXER_WAV_ALAW_FUNC_0008
498  * @tc.name      : DEMUXER_WAV_ALAW_FUNC_0008
499  * @tc.desc      : function test
500  */
501 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_WAV_ALAW_FUNC_0008, TestSize.Level2)
502 {
503     int32_t seekTime = 2816000;
504     int32_t thousand = 1000;
505     const char *file = "/data/test/media/audio/wav_alaw_48K_8b_1.wav";
506     int fd = open(file, O_RDONLY);
507     OpenFile(file, fd, &source, &demuxer);
508     CheckTrackCount(&sourceFormat, source, &g_trackCount, 1);
509     CheckTrackSelect(g_trackCount, demuxer);
510     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SeekToTime(demuxer, seekTime / thousand, SEEK_MODE_NEXT_SYNC));
511     CountAudioFrames(demuxer, memory, g_trackCount, 26, 26);
512     close(fd);
513 }
514 
515 /**
516  * @tc.number    : DEMUXER_WAV_ALAW_FUNC_0009
517  * @tc.name      : DEMUXER_WAV_ALAW_FUNC_0009
518  * @tc.desc      : function test
519  */
520 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_WAV_ALAW_FUNC_0009, TestSize.Level2)
521 {
522     const char *file = "/data/test/media/audio/wav_alaw_768001_8b_2.wav";
523     int fd = open(file, O_RDONLY);
524     OpenFile(file, fd, &source, &demuxer);
525     CheckTrackCount(&sourceFormat, source, &g_trackCount, 1);
526     CheckTrackSelect(g_trackCount, demuxer);
527     CountAudioFrames(demuxer, memory, g_trackCount, 1876, 1876);
528     close(fd);
529 }
530 
531 /**
532  * @tc.number    : DEMUXER_WAV_ALAW_FUNC_0010
533  * @tc.name      : DEMUXER_WAV_ALAW_FUNC_0010
534  * @tc.desc      : function test
535  */
536 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_WAV_ALAW_FUNC_0010, TestSize.Level2)
537 {
538     int32_t seekTime = 4973326;
539     int32_t thousand = 1000;
540     const char *file = "/data/test/media/audio/wav_alaw_768001_8b_2.wav";
541     int fd = open(file, O_RDONLY);
542     OpenFile(file, fd, &source, &demuxer);
543     CheckTrackCount(&sourceFormat, source, &g_trackCount, 1);
544     CheckTrackSelect(g_trackCount, demuxer);
545     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SeekToTime(demuxer, seekTime / thousand, SEEK_MODE_PREVIOUS_SYNC));
546     CountAudioFrames(demuxer, memory, g_trackCount, 11, 11);
547     close(fd);
548 }
549 /**
550  * @tc.number    : DEMUXER_FUNCTION_TRACK_0010
551  * @tc.name      : DEMUXER_FUNCTION_TRACK_0010
552  * @tc.desc      : function test
553  */
554 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0010, TestSize.Level1)
555 {
556     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
557     int fd = 0;
558     InitFile(file, TRACKNUM_4, fd);
559     ASSERT_TRUE(g_initResult);
560     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
561     ASSERT_NE(trackFormat, nullptr);
562     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
563     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
564     if (fd >= 0) {
565         close(fd);
566         fd = -1;
567     }
568 }
569 
570 /**
571  * @tc.number    : DEMUXER_FUNCTION_TRACK_0020
572  * @tc.name      : DEMUXER_FUNCTION_TRACK_0020
573  * @tc.desc      : function test
574  */
575 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0020, TestSize.Level1)
576 {
577     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
578     int fd = 0;
579     InitFile(file, TRACKNUM_4, fd);
580     ASSERT_TRUE(g_initResult);
581     const char *trackRefType = nullptr;
582     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
583     ASSERT_NE(trackFormat, nullptr);
584     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
585     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
586     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
587     ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_DEPTH.c_str()));
588     OH_AVFormat_Destroy(trackFormat);
589 
590     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
591     ASSERT_NE(trackFormat, nullptr);
592     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
593     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
594     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
595     ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_PREY.c_str()));
596     if (fd >= 0) {
597         close(fd);
598         fd = -1;
599     }
600 }
601 
602 /**
603  * @tc.number    : DEMUXER_FUNCTION_TRACK_0030
604  * @tc.name      : DEMUXER_FUNCTION_TRACK_0030
605  * @tc.desc      : function test
606  */
607 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0030, TestSize.Level1)
608 {
609     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
610     int fd = 0;
611     InitFile(file, TRACKNUM_4, fd);
612     ASSERT_TRUE(g_initResult);
613     const char *trackdescription = nullptr;
614     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
615     ASSERT_NE(trackFormat, nullptr);
616     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
617     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
618     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
619     ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_DEPTH_TRACK_KEY.c_str()));
620     OH_AVFormat_Destroy(trackFormat);
621 
622     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
623     ASSERT_NE(trackFormat, nullptr);
624     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
625     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
626     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
627     ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_PREY_TRACK_KEY.c_str()));
628     if (fd >= 0) {
629         close(fd);
630         fd = -1;
631     }
632 }
633 
634 /**
635  * @tc.number    : DEMUXER_FUNCTION_TRACK_0040
636  * @tc.name      : DEMUXER_FUNCTION_TRACK_0040
637  * @tc.desc      : function test
638  */
639 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0040, TestSize.Level1)
640 {
641     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
642     int fd = 0;
643     InitFile(file, TRACKNUM_4, fd);
644     ASSERT_TRUE(g_initResult);
645     int32_t *trackIdsDepth = nullptr;
646     int32_t *trackIdsPrey = nullptr;
647     size_t bufferSize;
648     int bufferSizeResult = 3;
649     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
650     ASSERT_NE(trackFormat, nullptr);
651     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
652     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
653     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
654     ASSERT_EQ(bufferSizeResult, bufferSize);
655     OH_AVFormat_Destroy(trackFormat);
656 
657     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
658     ASSERT_NE(trackFormat, nullptr);
659     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
660     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
661     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsPrey, &bufferSize));
662     bufferSizeResult = 2;
663     ASSERT_EQ(bufferSizeResult, bufferSize);
664     if (fd >= 0) {
665         close(fd);
666         fd = -1;
667     }
668 }
669 
670 /**
671  * @tc.number    : DEMUXER_FUNCTION_TRACK_0050
672  * @tc.name      : DEMUXER_FUNCTION_TRACK_0050
673  * @tc.desc      : function test
674  */
675 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0050, TestSize.Level0)
676 {
677     int32_t *trackIdsDepth = nullptr;
678     size_t bufferSize;
679     ASSERT_FALSE(OH_AVFormat_GetIntBuffer(nullptr, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
680 }
681 
682 /**
683  * @tc.number    : DEMUXER_FUNCTION_TRACK_0060
684  * @tc.name      : DEMUXER_FUNCTION_TRACK_0060
685  * @tc.desc      : function test
686  */
687 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0060, TestSize.Level0)
688 {
689     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
690     int fd = 0;
691     InitFile(file, TRACKNUM_4, fd);
692     ASSERT_TRUE(g_initResult);
693     int32_t *trackIdsDepth = nullptr;
694     size_t bufferSize;
695     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
696     ASSERT_NE(trackFormat, nullptr);
697     ASSERT_FALSE(OH_AVFormat_GetIntBuffer(trackFormat, nullptr, &trackIdsDepth, &bufferSize));
698     if (fd >= 0) {
699         close(fd);
700         fd = -1;
701     }
702 }
703 
704 /**
705  * @tc.number    : DEMUXER_FUNCTION_TRACK_0061
706  * @tc.name      : DEMUXER_FUNCTION_TRACK_0061
707  * @tc.desc      : function test
708  */
709 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0061, TestSize.Level0)
710 {
711     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
712     int fd = 0;
713     InitFile(file, TRACKNUM_4, fd);
714     ASSERT_TRUE(g_initResult);
715     int32_t *trackIdsDepth = nullptr;
716     size_t bufferSize;
717     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
718     ASSERT_NE(trackFormat, nullptr);
719     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
720     int bufferSizeResult = 3;
721     ASSERT_EQ(bufferSizeResult, bufferSize);
722     ASSERT_EQ(TRACKNUM_0, trackIdsDepth[TRACKNUM_0]);
723     ASSERT_EQ(TRACKNUM_2, trackIdsDepth[TRACKNUM_1]);
724     ASSERT_EQ(TRACKNUM_3, trackIdsDepth[TRACKNUM_2]);
725     if (fd >= 0) {
726         close(fd);
727         fd = -1;
728     }
729 }
730 
731 /**
732  * @tc.number    : DEMUXER_FUNCTION_TRACK_0070
733  * @tc.name      : DEMUXER_FUNCTION_TRACK_0070
734  * @tc.desc      : function test
735  */
736 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0070, TestSize.Level2)
737 {
738     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
739     int fd = 0;
740     InitFile(file, TRACKNUM_4, fd);
741     ASSERT_TRUE(g_initResult);
742     const char *trackRefType = nullptr;
743     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
744     ASSERT_NE(trackFormat, nullptr);
745     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
746     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
747     int intData = 0;
748     double doubleData;
749     int64_t longData = 0;
750     ASSERT_FALSE(OH_AVFormat_GetDoubleValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &doubleData));
751     ASSERT_FALSE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &intData));
752     ASSERT_FALSE(OH_AVFormat_GetLongValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &longData));
753     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
754     ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_DEPTH.c_str()));
755     if (fd >= 0) {
756         close(fd);
757         fd = -1;
758     }
759 }
760 
761 /**
762  * @tc.number    : DEMUXER_FUNCTION_TRACK_0080
763  * @tc.name      : DEMUXER_FUNCTION_TRACK_0080
764  * @tc.desc      : function test
765  */
766 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0080, TestSize.Level2)
767 {
768     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
769     int fd = 0;
770     InitFile(file, TRACKNUM_4, fd);
771     ASSERT_TRUE(g_initResult);
772     const char *trackdescription = nullptr;
773     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
774     ASSERT_NE(trackFormat, nullptr);
775     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
776     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
777     int intData = 0;
778     double doubleData;
779     int64_t longData = 0;
780     ASSERT_FALSE(OH_AVFormat_GetDoubleValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &doubleData));
781     ASSERT_FALSE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &intData));
782     ASSERT_FALSE(OH_AVFormat_GetLongValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &longData));
783     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
784     ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_DEPTH_TRACK_KEY.c_str()));
785     if (fd >= 0) {
786         close(fd);
787         fd = -1;
788     }
789 }
790 
791 /**
792  * @tc.number    : DEMUXER_FUNCTION_TRACK_0090
793  * @tc.name      : DEMUXER_FUNCTION_TRACK_0090
794  * @tc.desc      : function test
795  */
796 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0090, TestSize.Level2)
797 {
798     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
799     int fd = 0;
800     InitFile(file, TRACKNUM_4, fd);
801     ASSERT_TRUE(g_initResult);
802     int32_t *trackIdsDepth = nullptr;
803     size_t bufferSize;
804     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
805     ASSERT_NE(trackFormat, nullptr);
806     int intData = 0;
807     double doubleData;
808     int64_t longData = 0;
809     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
810     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
811     ASSERT_FALSE(OH_AVFormat_GetDoubleValue(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &doubleData));
812     ASSERT_FALSE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &intData));
813     ASSERT_FALSE(OH_AVFormat_GetLongValue(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &longData));
814     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
815     int bufferSizeResult = 3;
816     ASSERT_EQ(bufferSizeResult, bufferSize);
817     ASSERT_EQ(TRACKNUM_0, trackIdsDepth[TRACKNUM_0]);
818     ASSERT_EQ(TRACKNUM_2, trackIdsDepth[TRACKNUM_1]);
819     ASSERT_EQ(TRACKNUM_3, trackIdsDepth[TRACKNUM_2]);
820     if (fd >= 0) {
821         close(fd);
822         fd = -1;
823     }
824 }
825 
826 /**
827  * @tc.number    : DEMUXER_FUNCTION_TRACK_0130
828  * @tc.name      : DEMUXER_FUNCTION_TRACK_0130
829  * @tc.desc      : function test
830  */
831 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0130, TestSize.Level3)
832 {
833     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
834     int fd = 0;
835     InitFile(file, TRACKNUM_4, fd);
836     ASSERT_TRUE(g_initResult);
837     bool videoIsEnd1 = false;
838     bool videoIsEnd2 = false;
839     bool videoIsEnd3 = false;
840     int videoFrame1 = 0;
841     int videoFrame2 = 0;
842     int videoFrame3 = 0;
843     OH_AVCodecBufferAttr bufferAttr;
844     while (!videoIsEnd1 || !videoIsEnd2 || !videoIsEnd3) {
845         for (int32_t index = 0; index < g_trackCount; index++) {
846             trackFormat = OH_AVSource_GetTrackFormat(source, index);
847             ASSERT_NE(trackFormat, nullptr);
848             ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
849             if ((videoIsEnd1 && (index == TRACKNUM_1)) || (videoIsEnd2 && (index == TRACKNUM_2)) ||
850              (videoIsEnd3 && (index == TRACKNUM_3))) {
851                 continue;
852             }
853             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, index, avBuffer));
854             ASSERT_NE(avBuffer, nullptr);
855             ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
856             if (index == TRACKNUM_1 && g_trackType == MEDIA_TYPE_AUXILIARY) {
857                 GetDepthAndIdsTrack();
858                 ASSERT_TRUE(g_isRefult);
859                 SetVideoValue(bufferAttr, videoIsEnd1, videoFrame1);
860             } else if (index == TRACKNUM_2 && g_trackType == MEDIA_TYPE_AUXILIARY) {
861                 GetPreyAndIdsTrack();
862                 ASSERT_TRUE(g_isRefult);
863                 SetVideoValue(bufferAttr, videoIsEnd2, videoFrame2);
864             } else if (index == TRACKNUM_3 && g_trackType == MEDIA_TYPE_TIMED_METADATA) {
865                 GetTimedMetaTrack();
866                 ASSERT_TRUE(g_isRefult);
867                 SetVideoValue(bufferAttr, videoIsEnd3, videoFrame3);
868             }
869             OH_AVFormat_Destroy(trackFormat);
870             trackFormat = nullptr;
871         }
872     }
873     ASSERT_EQ(videoFrame3, TRACKFRAME_16);
874     ASSERT_EQ(videoFrame2, TRACKFRAME_16);
875     ASSERT_EQ(videoFrame1, TRACKFRAME_77);
876     if (fd >= 0) {
877         close(fd);
878         fd = -1;
879     }
880 }
881 
882 /**
883  * @tc.number    : DEMUXER_FUNCTION_TRACK_0140
884  * @tc.name      : DEMUXER_FUNCTION_TRACK_0140
885  * @tc.desc      : function test
886  */
887 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0140, TestSize.Level3)
888 {
889     const char *file = "/data/test/media/Muxer_Auxiliary_01.mp4";
890     int fd = 0;
891     InitFile(file, TRACKNUM_4, fd);
892     ASSERT_TRUE(g_initResult);
893     bool videoIsEnd1 = false;
894     bool videoIsEnd2 = false;
895     bool videoIsEnd3 = false;
896     int videoFrame1 = 0;
897     int videoFrame2 = 0;
898     int videoFrame3 = 0;
899     OH_AVCodecBufferAttr bufferAttr;
900     while (!videoIsEnd1 || !videoIsEnd2 || !videoIsEnd3) {
901         for (int32_t index = 0; index < g_trackCount; index++) {
902             trackFormat = OH_AVSource_GetTrackFormat(source, index);
903             ASSERT_NE(trackFormat, nullptr);
904             ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
905             if ((videoIsEnd1 && (index == TRACKNUM_1)) || (videoIsEnd2 && (index == TRACKNUM_2)) ||
906              (videoIsEnd3 && (index == TRACKNUM_3))) {
907                 continue;
908             }
909             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, index, avBuffer));
910             ASSERT_NE(avBuffer, nullptr);
911             ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
912             if (index == TRACKNUM_1 && g_trackType == MEDIA_TYPE_AUXILIARY) {
913                 GetDepthTrack();
914                 ASSERT_TRUE(g_isRefult);
915                 SetVideoValue(bufferAttr, videoIsEnd1, videoFrame1);
916             } else if (index == TRACKNUM_2 && g_trackType == MEDIA_TYPE_AUXILIARY) {
917                 GetPreyTrack();
918                 ASSERT_TRUE(g_isRefult);
919                 SetVideoValue(bufferAttr, videoIsEnd2, videoFrame2);
920             } else if (index == TRACKNUM_3 && g_trackType == MEDIA_TYPE_TIMED_METADATA) {
921                 GetTimedMetaTrack();
922                 ASSERT_TRUE(g_isRefult);
923                 SetVideoValue(bufferAttr, videoIsEnd3, videoFrame3);
924             }
925             OH_AVFormat_Destroy(trackFormat);
926             trackFormat = nullptr;
927         }
928     }
929     ASSERT_EQ(videoFrame3, TRACKFRAME_16);
930     ASSERT_EQ(videoFrame2, TRACKFRAME_16);
931     ASSERT_EQ(videoFrame1, TRACKFRAME_77);
932     if (fd >= 0) {
933         close(fd);
934         fd = -1;
935     }
936 }
937 
938 /**
939  * @tc.number    : DEMUXER_FUNCTION_TRACK_0150
940  * @tc.name      : DEMUXER_FUNCTION_TRACK_0150
941  * @tc.desc      : function test
942  */
943 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0150, TestSize.Level3)
944 {
945     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
946     int fd = 0;
947     InitFile(file, TRACKNUM_4, fd);
948     ASSERT_TRUE(g_initResult);
949     bool videoIsEnd = false;
950     int videoFrame = 0;
951     OH_AVCodecBufferAttr bufferAttr;
952     const char *trackRefType = nullptr;
953     const char *trackdescription = nullptr;
954     int32_t *trackIdsDepth = nullptr;
955     size_t bufferSize;
956     while (!videoIsEnd) {
957         trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_3);
958         ASSERT_NE(trackFormat, nullptr);
959         ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
960         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, TRACKNUM_3, avBuffer));
961         ASSERT_NE(avBuffer, nullptr);
962         ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
963         if (g_trackType == MEDIA_TYPE_TIMED_METADATA) {
964             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
965             ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_CDSC.c_str()));
966             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
967             ASSERT_EQ(0, strcmp(trackdescription, TIMED_METADATA_KEY.c_str()));
968             ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
969                 trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
970             ASSERT_EQ(TRACKNUM_1, bufferSize);
971             ASSERT_EQ(TRACKNUM_1, trackIdsDepth[TRACKNUM_0]);
972             SetVideoValue(bufferAttr, videoIsEnd, videoFrame);
973         }
974         OH_AVFormat_Destroy(trackFormat);
975         trackFormat = nullptr;
976     }
977     ASSERT_EQ(videoFrame, TRACKFRAME_16);
978     if (fd >= 0) {
979         close(fd);
980         fd = -1;
981     }
982 }
983 
984 /**
985  * @tc.number    : DEMUXER_FUNCTION_TRACK_0160
986  * @tc.name      : DEMUXER_FUNCTION_TRACK_0160
987  * @tc.desc      : function test
988  */
989 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0160, TestSize.Level3)
990 {
991     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
992     int fd = 0;
993     InitFile(file, TRACKNUM_4, fd);
994     ASSERT_TRUE(g_initResult);
995     bool videoIsEnd = false;
996     int videoFrame = 0;
997     OH_AVCodecBufferAttr bufferAttr;
998     const char *trackRefType = nullptr;
999     const char *trackdescription = nullptr;
1000     int32_t *trackIdsPrey = nullptr;
1001     size_t bufferSize;
1002     while (!videoIsEnd) {
1003         trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
1004         ASSERT_NE(trackFormat, nullptr);
1005         ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1006         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, TRACKNUM_2, avBuffer));
1007         ASSERT_NE(avBuffer, nullptr);
1008         ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
1009         if (g_trackType == MEDIA_TYPE_AUXILIARY) {
1010             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1011             ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_PREY.c_str()));
1012             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1013             ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_PREY_TRACK_KEY.c_str()));
1014             ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
1015                 trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsPrey, &bufferSize));
1016             ASSERT_EQ(TRACKNUM_2, bufferSize);
1017             ASSERT_EQ(TRACKNUM_0, trackIdsPrey[TRACKNUM_0]);
1018             ASSERT_EQ(TRACKNUM_1, trackIdsPrey[TRACKNUM_1]);
1019             SetVideoValue(bufferAttr, videoIsEnd, videoFrame);
1020         }
1021         OH_AVFormat_Destroy(trackFormat);
1022         trackFormat = nullptr;
1023     }
1024     ASSERT_EQ(videoFrame, TRACKFRAME_16);
1025     if (fd >= 0) {
1026         close(fd);
1027         fd = -1;
1028     }
1029 }
1030 
1031 /**
1032  * @tc.number    : DEMUXER_FUNCTION_TRACK_0170
1033  * @tc.name      : DEMUXER_FUNCTION_TRACK_0170
1034  * @tc.desc      : function test
1035  */
1036 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0170, TestSize.Level3)
1037 {
1038     const char *file = "/data/test/media/Muxer_Auxiliary_04.mp4";
1039     int fd = 0;
1040     g_unselect = 0;
1041     InitFile(file, TRACKNUM_3, fd);
1042     ASSERT_TRUE(g_initResult);
1043     bool videoIsEnd = false;
1044     int videoFrame = 0;
1045     OH_AVCodecBufferAttr bufferAttr;
1046     const char *trackRefType = nullptr;
1047     const char *trackdescription = nullptr;
1048     int32_t *trackIdsPrey = nullptr;
1049     size_t bufferSize;
1050     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SeekToTime(demuxer, VIDEOTRACKSEEK / THOUSAND, SEEK_MODE_NEXT_SYNC));
1051     while (!videoIsEnd) {
1052         trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
1053         ASSERT_NE(trackFormat, nullptr);
1054         ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1055         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, TRACKNUM_2, avBuffer));
1056         ASSERT_NE(avBuffer, nullptr);
1057         ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
1058         if (g_trackType == MEDIA_TYPE_AUXILIARY) {
1059             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1060             ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_PREY.c_str()));
1061             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1062             ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_PREY_TRACK_KEY.c_str()));
1063             ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
1064                 trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsPrey, &bufferSize));
1065             ASSERT_EQ(TRACKNUM_1, bufferSize);
1066             ASSERT_EQ(TRACKNUM_2, trackIdsPrey[TRACKNUM_0]);
1067             SetVideoValue(bufferAttr, videoIsEnd, videoFrame);
1068         }
1069         OH_AVFormat_Destroy(trackFormat);
1070         trackFormat = nullptr;
1071     }
1072     if (fd >= 0) {
1073         close(fd);
1074         fd = -1;
1075     }
1076 }
1077 
1078 /**
1079  * @tc.number    : DEMUXER_FUNCTION_TRACK_0180
1080  * @tc.name      : DEMUXER_FUNCTION_TRACK_0180
1081  * @tc.desc      : function test
1082  */
1083 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0180, TestSize.Level3)
1084 {
1085     const char *file = "/data/test/media/Muxer_Auxiliary.mp4";
1086     int fd = 0;
1087     InitFile(file, TRACKNUM_4, fd);
1088     ASSERT_TRUE(g_initResult);
1089     bool videoIsEnd = false;
1090     int videoFrame = 0;
1091     OH_AVCodecBufferAttr bufferAttr;
1092     const char *trackRefType = nullptr;
1093     const char *trackdescription = nullptr;
1094     int32_t *trackIdsDepth = nullptr;
1095     size_t bufferSize;
1096     while (!videoIsEnd) {
1097         trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1098         ASSERT_NE(trackFormat, nullptr);
1099         ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1100         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, TRACKNUM_1, avBuffer));
1101         ASSERT_NE(avBuffer, nullptr);
1102         ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
1103         if (g_trackType == MEDIA_TYPE_AUXILIARY) {
1104             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1105             ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_DEPTH.c_str()));
1106             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1107             ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_DEPTH_TRACK_KEY.c_str()));
1108             ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
1109                 trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
1110             ASSERT_EQ(TRACKNUM_3, bufferSize);
1111             ASSERT_EQ(TRACKNUM_0, trackIdsDepth[TRACKNUM_0]);
1112             ASSERT_EQ(TRACKNUM_2, trackIdsDepth[TRACKNUM_1]);
1113             ASSERT_EQ(TRACKNUM_3, trackIdsDepth[TRACKNUM_2]);
1114             SetVideoValue(bufferAttr, videoIsEnd, videoFrame);
1115         }
1116         OH_AVFormat_Destroy(trackFormat);
1117         trackFormat = nullptr;
1118     }
1119     ASSERT_EQ(videoFrame, TRACKFRAME_77);
1120     if (fd >= 0) {
1121         close(fd);
1122         fd = -1;
1123     }
1124 }
1125 
1126 /**
1127  * @tc.number    : DEMUXER_FUNCTION_TRACK_0190
1128  * @tc.name      : DEMUXER_FUNCTION_TRACK_0190
1129  * @tc.desc      : function test
1130  */
1131 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_TRACK_0190, TestSize.Level3)
1132 {
1133     const char *file = "/data/test/media/Muxer_Auxiliary_04.mp4";
1134     int fd = 0;
1135     g_unselect = 0;
1136     InitFile(file, TRACKNUM_3, fd);
1137     ASSERT_TRUE(g_initResult);
1138     bool videoIsEnd = false;
1139     int videoFrame = 0;
1140     OH_AVCodecBufferAttr bufferAttr;
1141     const char *trackRefType = nullptr;
1142     const char *trackdescription = nullptr;
1143     int32_t *trackIdsDepth = nullptr;
1144     size_t bufferSize;
1145     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SeekToTime(demuxer, VIDEOTRACKSEEK / THOUSAND, SEEK_MODE_NEXT_SYNC));
1146     while (!videoIsEnd) {
1147         trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1148         ASSERT_NE(trackFormat, nullptr);
1149         ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1150         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, TRACKNUM_1, avBuffer));
1151         ASSERT_NE(avBuffer, nullptr);
1152         ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
1153         if (g_trackType == MEDIA_TYPE_AUXILIARY) {
1154             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1155             ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_DEPTH.c_str()));
1156             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1157             ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_DEPTH_TRACK_KEY.c_str()));
1158             ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
1159                 trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
1160             ASSERT_EQ(TRACKNUM_1, bufferSize);
1161             ASSERT_EQ(TRACKNUM_1, trackIdsDepth[TRACKNUM_0]);
1162             SetVideoValue(bufferAttr, videoIsEnd, videoFrame);
1163         }
1164         OH_AVFormat_Destroy(trackFormat);
1165         trackFormat = nullptr;
1166     }
1167     if (fd >= 0) {
1168         close(fd);
1169         fd = -1;
1170     }
1171 }
1172 
1173 /**
1174  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0010
1175  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0010
1176  * @tc.desc      : function test
1177  */
1178 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0010, TestSize.Level1)
1179 {
1180     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1181     int fd = 0;
1182     InitFile(file, TRACKNUM_4, fd);
1183     ASSERT_TRUE(g_initResult);
1184     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
1185     ASSERT_NE(trackFormat, nullptr);
1186     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1187     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
1188     if (fd >= 0) {
1189         close(fd);
1190         fd = -1;
1191     }
1192 }
1193 
1194 /**
1195  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0020
1196  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0020
1197  * @tc.desc      : function test
1198  */
1199 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0020, TestSize.Level1)
1200 {
1201     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1202     int fd = 0;
1203     InitFile(file, TRACKNUM_4, fd);
1204     ASSERT_TRUE(g_initResult);
1205     const char *trackRefType = nullptr;
1206     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1207     ASSERT_NE(trackFormat, nullptr);
1208     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1209     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
1210     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1211     ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_DEPTH.c_str()));
1212     OH_AVFormat_Destroy(trackFormat);
1213 
1214     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
1215     ASSERT_NE(trackFormat, nullptr);
1216     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1217     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
1218     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1219     ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_PREY.c_str()));
1220     if (fd >= 0) {
1221         close(fd);
1222         fd = -1;
1223     }
1224 }
1225 
1226 /**
1227  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0030
1228  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0030
1229  * @tc.desc      : function test
1230  */
1231 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0030, TestSize.Level1)
1232 {
1233     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1234     int fd = 0;
1235     InitFile(file, TRACKNUM_4, fd);
1236     ASSERT_TRUE(g_initResult);
1237     const char *trackdescription = nullptr;
1238     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1239     ASSERT_NE(trackFormat, nullptr);
1240     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1241     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
1242     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1243     ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_DEPTH_TRACK_KEY.c_str()));
1244     OH_AVFormat_Destroy(trackFormat);
1245 
1246     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
1247     ASSERT_NE(trackFormat, nullptr);
1248     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1249     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
1250     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1251     ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_PREY_TRACK_KEY.c_str()));
1252     if (fd >= 0) {
1253         close(fd);
1254         fd = -1;
1255     }
1256 }
1257 
1258 /**
1259  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0040
1260  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0040
1261  * @tc.desc      : function test
1262  */
1263 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0040, TestSize.Level1)
1264 {
1265     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1266     int fd = 0;
1267     InitFile(file, TRACKNUM_4, fd);
1268     ASSERT_TRUE(g_initResult);
1269     int32_t *trackIdsDepth = nullptr;
1270     int32_t *trackIdsPrey = nullptr;
1271     size_t bufferSize;
1272     int bufferSizeResult = 3;
1273     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1274     ASSERT_NE(trackFormat, nullptr);
1275     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1276     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
1277     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
1278     ASSERT_EQ(bufferSizeResult, bufferSize);
1279     OH_AVFormat_Destroy(trackFormat);
1280 
1281     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
1282     ASSERT_NE(trackFormat, nullptr);
1283     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1284     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
1285     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsPrey, &bufferSize));
1286     bufferSizeResult = 2;
1287     ASSERT_EQ(bufferSizeResult, bufferSize);
1288     if (fd >= 0) {
1289         close(fd);
1290         fd = -1;
1291     }
1292 }
1293 
1294 /**
1295  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0050
1296  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0050
1297  * @tc.desc      : function test
1298  */
1299 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0050, TestSize.Level0)
1300 {
1301     int32_t *trackIdsDepth = nullptr;
1302     size_t bufferSize;
1303     ASSERT_FALSE(OH_AVFormat_GetIntBuffer(nullptr, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
1304 }
1305 
1306 /**
1307  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0060
1308  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0060
1309  * @tc.desc      : function test
1310  */
1311 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0060, TestSize.Level0)
1312 {
1313     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1314     int fd = 0;
1315     InitFile(file, TRACKNUM_4, fd);
1316     ASSERT_TRUE(g_initResult);
1317     int32_t *trackIdsDepth = nullptr;
1318     size_t bufferSize;
1319     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1320     ASSERT_NE(trackFormat, nullptr);
1321     ASSERT_FALSE(OH_AVFormat_GetIntBuffer(trackFormat, nullptr, &trackIdsDepth, &bufferSize));
1322     if (fd >= 0) {
1323         close(fd);
1324         fd = -1;
1325     }
1326 }
1327 
1328 /**
1329  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0061
1330  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0061
1331  * @tc.desc      : function test
1332  */
1333 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0061, TestSize.Level0)
1334 {
1335     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1336     int fd = 0;
1337     InitFile(file, TRACKNUM_4, fd);
1338     ASSERT_TRUE(g_initResult);
1339     int32_t *trackIdsDepth = nullptr;
1340     size_t bufferSize;
1341     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1342     ASSERT_NE(trackFormat, nullptr);
1343     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
1344     int bufferSizeResult = 3;
1345     ASSERT_EQ(bufferSizeResult, bufferSize);
1346     ASSERT_EQ(TRACKNUM_0, trackIdsDepth[TRACKNUM_0]);
1347     ASSERT_EQ(TRACKNUM_2, trackIdsDepth[TRACKNUM_1]);
1348     ASSERT_EQ(TRACKNUM_3, trackIdsDepth[TRACKNUM_2]);
1349     if (fd >= 0) {
1350         close(fd);
1351         fd = -1;
1352     }
1353 }
1354 
1355 /**
1356  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0070
1357  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0070
1358  * @tc.desc      : function test
1359  */
1360 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0070, TestSize.Level2)
1361 {
1362     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1363     int fd = 0;
1364     InitFile(file, TRACKNUM_4, fd);
1365     ASSERT_TRUE(g_initResult);
1366     const char *trackRefType = nullptr;
1367     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1368     ASSERT_NE(trackFormat, nullptr);
1369     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1370     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
1371     int intData = 0;
1372     double doubleData;
1373     int64_t longData = 0;
1374     ASSERT_FALSE(OH_AVFormat_GetDoubleValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &doubleData));
1375     ASSERT_FALSE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &intData));
1376     ASSERT_FALSE(OH_AVFormat_GetLongValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &longData));
1377     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1378     ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_DEPTH.c_str()));
1379     if (fd >= 0) {
1380         close(fd);
1381         fd = -1;
1382     }
1383 }
1384 
1385 /**
1386  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0080
1387  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0080
1388  * @tc.desc      : function test
1389  */
1390 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0080, TestSize.Level2)
1391 {
1392     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1393     int fd = 0;
1394     InitFile(file, TRACKNUM_4, fd);
1395     ASSERT_TRUE(g_initResult);
1396     const char *trackdescription = nullptr;
1397     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1398     ASSERT_NE(trackFormat, nullptr);
1399     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1400     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
1401     int intData = 0;
1402     double doubleData;
1403     int64_t longData = 0;
1404     ASSERT_FALSE(OH_AVFormat_GetDoubleValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &doubleData));
1405     ASSERT_FALSE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &intData));
1406     ASSERT_FALSE(OH_AVFormat_GetLongValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &longData));
1407     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1408     ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_DEPTH_TRACK_KEY.c_str()));
1409     if (fd >= 0) {
1410         close(fd);
1411         fd = -1;
1412     }
1413 }
1414 
1415 /**
1416  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0090
1417  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0090
1418  * @tc.desc      : function test
1419  */
1420 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0090, TestSize.Level2)
1421 {
1422     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1423     int fd = 0;
1424     InitFile(file, TRACKNUM_4, fd);
1425     ASSERT_TRUE(g_initResult);
1426     int32_t *trackIdsDepth = nullptr;
1427     size_t bufferSize;
1428     trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1429     ASSERT_NE(trackFormat, nullptr);
1430     int intData = 0;
1431     double doubleData;
1432     int64_t longData = 0;
1433     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1434     ASSERT_EQ(g_trackType, MEDIA_TYPE_AUXILIARY);
1435     ASSERT_FALSE(OH_AVFormat_GetDoubleValue(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &doubleData));
1436     ASSERT_FALSE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &intData));
1437     ASSERT_FALSE(OH_AVFormat_GetLongValue(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &longData));
1438     ASSERT_TRUE(OH_AVFormat_GetIntBuffer(trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
1439     int bufferSizeResult = 3;
1440     ASSERT_EQ(bufferSizeResult, bufferSize);
1441     ASSERT_EQ(TRACKNUM_0, trackIdsDepth[TRACKNUM_0]);
1442     ASSERT_EQ(TRACKNUM_2, trackIdsDepth[TRACKNUM_1]);
1443     ASSERT_EQ(TRACKNUM_3, trackIdsDepth[TRACKNUM_2]);
1444     if (fd >= 0) {
1445         close(fd);
1446         fd = -1;
1447     }
1448 }
1449 
1450 /**
1451  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0130
1452  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0130
1453  * @tc.desc      : function test
1454  */
1455 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0130, TestSize.Level3)
1456 {
1457     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1458     int fd = 0;
1459     InitFile(file, TRACKNUM_4, fd);
1460     ASSERT_TRUE(g_initResult);
1461     bool videoIsEnd1 = false;
1462     bool videoIsEnd2 = false;
1463     bool videoIsEnd3 = false;
1464     int videoFrame1 = 0;
1465     int videoFrame2 = 0;
1466     int videoFrame3 = 0;
1467     OH_AVCodecBufferAttr bufferAttr;
1468     while (!videoIsEnd1 || !videoIsEnd2 || !videoIsEnd3) {
1469         for (int32_t index = 0; index < g_trackCount; index++) {
1470             trackFormat = OH_AVSource_GetTrackFormat(source, index);
1471             ASSERT_NE(trackFormat, nullptr);
1472             ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1473             if ((videoIsEnd1 && (index == TRACKNUM_1)) || (videoIsEnd2 && (index == TRACKNUM_2)) ||
1474              (videoIsEnd3 && (index == TRACKNUM_3))) {
1475                 continue;
1476             }
1477             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, index, avBuffer));
1478             ASSERT_NE(avBuffer, nullptr);
1479             ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
1480             if (index == TRACKNUM_1 && g_trackType == MEDIA_TYPE_AUXILIARY) {
1481                 GetDepthAndIdsTrack();
1482                 ASSERT_TRUE(g_isRefult);
1483                 SetVideoValue(bufferAttr, videoIsEnd1, videoFrame1);
1484             } else if (index == TRACKNUM_2 && g_trackType == MEDIA_TYPE_AUXILIARY) {
1485                 GetPreyAndIdsTrack();
1486                 ASSERT_TRUE(g_isRefult);
1487                 SetVideoValue(bufferAttr, videoIsEnd2, videoFrame2);
1488             } else if (index == TRACKNUM_3 && g_trackType == MEDIA_TYPE_TIMED_METADATA) {
1489                 GetTimedMetaTrack();
1490                 ASSERT_TRUE(g_isRefult);
1491                 SetVideoValue(bufferAttr, videoIsEnd3, videoFrame3);
1492             }
1493             OH_AVFormat_Destroy(trackFormat);
1494             trackFormat = nullptr;
1495         }
1496     }
1497     ASSERT_EQ(videoFrame3, TRACKFRAME_231);
1498     ASSERT_EQ(videoFrame2, TRACKFRAME_431);
1499     ASSERT_EQ(videoFrame1, TRACKFRAME_431);
1500     if (fd >= 0) {
1501         close(fd);
1502         fd = -1;
1503     }
1504 }
1505 
1506 /**
1507  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0140
1508  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0140
1509  * @tc.desc      : function test
1510  */
1511 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0140, TestSize.Level3)
1512 {
1513     const char *file = "/data/test/media/Muxer_Auxiliary_03.mp4";
1514     int fd = 0;
1515     InitFile(file, TRACKNUM_4, fd);
1516     ASSERT_TRUE(g_initResult);
1517     bool videoIsEnd1 = false;
1518     bool videoIsEnd2 = false;
1519     bool videoIsEnd3 = false;
1520     int videoFrame1 = 0;
1521     int videoFrame2 = 0;
1522     int videoFrame3 = 0;
1523     OH_AVCodecBufferAttr bufferAttr;
1524     while (!videoIsEnd1 || !videoIsEnd2 || !videoIsEnd3) {
1525         for (int32_t index = 0; index < g_trackCount; index++) {
1526             trackFormat = OH_AVSource_GetTrackFormat(source, index);
1527             ASSERT_NE(trackFormat, nullptr);
1528             ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1529             if ((videoIsEnd1 && (index == TRACKNUM_1)) || (videoIsEnd2 && (index == TRACKNUM_2)) ||
1530              (videoIsEnd3 && (index == TRACKNUM_3))) {
1531                 continue;
1532             }
1533             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, index, avBuffer));
1534             ASSERT_NE(avBuffer, nullptr);
1535             ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
1536             if (index == TRACKNUM_1 && g_trackType == MEDIA_TYPE_AUXILIARY) {
1537                 GetDepthTrack();
1538                 ASSERT_TRUE(g_isRefult);
1539                 SetVideoValue(bufferAttr, videoIsEnd1, videoFrame1);
1540             } else if (index == TRACKNUM_2 && g_trackType == MEDIA_TYPE_AUXILIARY) {
1541                 GetPreyTrack();
1542                 ASSERT_TRUE(g_isRefult);
1543                 SetVideoValue(bufferAttr, videoIsEnd2, videoFrame2);
1544             } else if (index == TRACKNUM_3 && g_trackType == MEDIA_TYPE_TIMED_METADATA) {
1545                 GetTimedMetaTrack();
1546                 ASSERT_TRUE(g_isRefult);
1547                 SetVideoValue(bufferAttr, videoIsEnd3, videoFrame3);
1548             }
1549             OH_AVFormat_Destroy(trackFormat);
1550             trackFormat = nullptr;
1551         }
1552     }
1553     ASSERT_EQ(videoFrame3, TRACKFRAME_223);
1554     ASSERT_EQ(videoFrame2, TRACKFRAME_417);
1555     ASSERT_EQ(videoFrame1, TRACKFRAME_417);
1556     if (fd >= 0) {
1557         close(fd);
1558         fd = -1;
1559     }
1560 }
1561 
1562 /**
1563  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0150
1564  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0150
1565  * @tc.desc      : function test
1566  */
1567 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0150, TestSize.Level3)
1568 {
1569     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1570     int fd = 0;
1571     InitFile(file, TRACKNUM_4, fd);
1572     ASSERT_TRUE(g_initResult);
1573     bool videoIsEnd = false;
1574     int videoFrame = 0;
1575     OH_AVCodecBufferAttr bufferAttr;
1576     const char *trackRefType = nullptr;
1577     const char *trackdescription = nullptr;
1578     int32_t *trackIdsDepth = nullptr;
1579     size_t bufferSize;
1580     while (!videoIsEnd) {
1581         trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_3);
1582         ASSERT_NE(trackFormat, nullptr);
1583         ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1584         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, TRACKNUM_3, avBuffer));
1585         ASSERT_NE(avBuffer, nullptr);
1586         ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
1587         if (g_trackType == MEDIA_TYPE_TIMED_METADATA) {
1588             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1589             ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_CDSC.c_str()));
1590             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1591             ASSERT_EQ(0, strcmp(trackdescription, TIMED_METADATA_KEY.c_str()));
1592             ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
1593                 trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
1594             ASSERT_EQ(TRACKNUM_1, bufferSize);
1595             ASSERT_EQ(TRACKNUM_1, trackIdsDepth[TRACKNUM_0]);
1596             SetVideoValue(bufferAttr, videoIsEnd, videoFrame);
1597         }
1598         OH_AVFormat_Destroy(trackFormat);
1599         trackFormat = nullptr;
1600     }
1601     ASSERT_EQ(videoFrame, TRACKFRAME_231);
1602     if (fd >= 0) {
1603         close(fd);
1604         fd = -1;
1605     }
1606 }
1607 
1608 /**
1609  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0160
1610  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0160
1611  * @tc.desc      : function test
1612  */
1613 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0160, TestSize.Level3)
1614 {
1615     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1616     int fd = 0;
1617     InitFile(file, TRACKNUM_4, fd);
1618     ASSERT_TRUE(g_initResult);
1619     bool videoIsEnd = false;
1620     int videoFrame = 0;
1621     OH_AVCodecBufferAttr bufferAttr;
1622     const char *trackRefType = nullptr;
1623     const char *trackdescription = nullptr;
1624     int32_t *trackIdsPrey = nullptr;
1625     size_t bufferSize;
1626     while (!videoIsEnd) {
1627         trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
1628         ASSERT_NE(trackFormat, nullptr);
1629         ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1630         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, TRACKNUM_2, avBuffer));
1631         ASSERT_NE(avBuffer, nullptr);
1632         ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
1633         if (g_trackType == MEDIA_TYPE_AUXILIARY) {
1634             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1635             ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_PREY.c_str()));
1636             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1637             ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_PREY_TRACK_KEY.c_str()));
1638             ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
1639                 trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsPrey, &bufferSize));
1640             ASSERT_EQ(TRACKNUM_2, bufferSize);
1641             ASSERT_EQ(TRACKNUM_0, trackIdsPrey[TRACKNUM_0]);
1642             ASSERT_EQ(TRACKNUM_1, trackIdsPrey[TRACKNUM_1]);
1643             SetVideoValue(bufferAttr, videoIsEnd, videoFrame);
1644         }
1645         OH_AVFormat_Destroy(trackFormat);
1646         trackFormat = nullptr;
1647     }
1648     ASSERT_EQ(videoFrame, TRACKFRAME_431);
1649     if (fd >= 0) {
1650         close(fd);
1651         fd = -1;
1652     }
1653 }
1654 
1655 /**
1656  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0170
1657  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0170
1658  * @tc.desc      : function test
1659  */
1660 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0170, TestSize.Level3)
1661 {
1662     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1663     int fd = 0;
1664     InitFile(file, TRACKNUM_4, fd);
1665     ASSERT_TRUE(g_initResult);
1666     bool videoIsEnd = false;
1667     int videoFrame = 0;
1668     OH_AVCodecBufferAttr bufferAttr;
1669     const char *trackRefType = nullptr;
1670     const char *trackdescription = nullptr;
1671     int32_t *trackIdsPrey = nullptr;
1672     size_t bufferSize;
1673     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SeekToTime(demuxer, AUDIOTRACKSEEK / THOUSAND, SEEK_MODE_NEXT_SYNC));
1674     while (!videoIsEnd) {
1675         trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_2);
1676         ASSERT_NE(trackFormat, nullptr);
1677         ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1678         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, TRACKNUM_2, avBuffer));
1679         ASSERT_NE(avBuffer, nullptr);
1680         ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
1681         if (g_trackType == MEDIA_TYPE_AUXILIARY) {
1682             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1683             ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_PREY.c_str()));
1684             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1685             ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_PREY_TRACK_KEY.c_str()));
1686             ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
1687                 trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsPrey, &bufferSize));
1688             ASSERT_EQ(TRACKNUM_2, bufferSize);
1689             ASSERT_EQ(TRACKNUM_0, trackIdsPrey[TRACKNUM_0]);
1690             ASSERT_EQ(TRACKNUM_1, trackIdsPrey[TRACKNUM_1]);
1691             SetVideoValue(bufferAttr, videoIsEnd, videoFrame);
1692         }
1693         OH_AVFormat_Destroy(trackFormat);
1694         trackFormat = nullptr;
1695     }
1696     if (fd >= 0) {
1697         close(fd);
1698         fd = -1;
1699     }
1700 }
1701 
1702 /**
1703  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0180
1704  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0180
1705  * @tc.desc      : function test
1706  */
1707 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0180, TestSize.Level3)
1708 {
1709     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1710     int fd = 0;
1711     InitFile(file, TRACKNUM_4, fd);
1712     ASSERT_TRUE(g_initResult);
1713     bool videoIsEnd = false;
1714     int videoFrame = 0;
1715     OH_AVCodecBufferAttr bufferAttr;
1716     const char *trackRefType = nullptr;
1717     const char *trackdescription = nullptr;
1718     int32_t *trackIdsDepth = nullptr;
1719     size_t bufferSize;
1720     while (!videoIsEnd) {
1721         trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1722         ASSERT_NE(trackFormat, nullptr);
1723         ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1724         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, TRACKNUM_1, avBuffer));
1725         ASSERT_NE(avBuffer, nullptr);
1726         ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
1727         if (g_trackType == MEDIA_TYPE_AUXILIARY) {
1728             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1729             ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_DEPTH.c_str()));
1730             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1731             ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_DEPTH_TRACK_KEY.c_str()));
1732             ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
1733                 trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
1734             ASSERT_EQ(TRACKNUM_3, bufferSize);
1735             ASSERT_EQ(TRACKNUM_0, trackIdsDepth[TRACKNUM_0]);
1736             ASSERT_EQ(TRACKNUM_2, trackIdsDepth[TRACKNUM_1]);
1737             ASSERT_EQ(TRACKNUM_3, trackIdsDepth[TRACKNUM_2]);
1738             SetVideoValue(bufferAttr, videoIsEnd, videoFrame);
1739         }
1740         OH_AVFormat_Destroy(trackFormat);
1741         trackFormat = nullptr;
1742     }
1743     ASSERT_EQ(videoFrame, TRACKFRAME_431);
1744     if (fd >= 0) {
1745         close(fd);
1746         fd = -1;
1747     }
1748 }
1749 
1750 /**
1751  * @tc.number    : DEMUXER_FUNCTION_AUDIO_TRACK_0190
1752  * @tc.name      : DEMUXER_FUNCTION_AUDIO_TRACK_0190
1753  * @tc.desc      : function test
1754  */
1755 HWTEST_F(DemuxerFunc2NdkTest, DEMUXER_FUNCTION_AUDIO_TRACK_0190, TestSize.Level3)
1756 {
1757     const char *file = "/data/test/media/Muxer_Auxiliary_02.mp4";
1758     int fd = 0;
1759     InitFile(file, TRACKNUM_4, fd);
1760     ASSERT_TRUE(g_initResult);
1761     bool videoIsEnd = false;
1762     int videoFrame = 0;
1763     OH_AVCodecBufferAttr bufferAttr;
1764     const char *trackRefType = nullptr;
1765     const char *trackdescription = nullptr;
1766     int32_t *trackIdsDepth = nullptr;
1767     size_t bufferSize;
1768     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SeekToTime(demuxer, AUDIOTRACKSEEK / THOUSAND, SEEK_MODE_NEXT_SYNC));
1769     while (!videoIsEnd) {
1770         trackFormat = OH_AVSource_GetTrackFormat(source, TRACKNUM_1);
1771         ASSERT_NE(trackFormat, nullptr);
1772         ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &g_trackType));
1773         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSampleBuffer(demuxer, TRACKNUM_1, avBuffer));
1774         ASSERT_NE(avBuffer, nullptr);
1775         ASSERT_EQ(AV_ERR_OK, OH_AVBuffer_GetBufferAttr(avBuffer, &bufferAttr));
1776         if (g_trackType == MEDIA_TYPE_AUXILIARY) {
1777             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_REFERENCE_TYPE, &trackRefType));
1778             ASSERT_EQ(0, strcmp(trackRefType, TRACK_REF_TYPE_DEPTH.c_str()));
1779             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_TRACK_DESCRIPTION, &trackdescription));
1780             ASSERT_EQ(0, strcmp(trackdescription, AUXILIARY_DEPTH_TRACK_KEY.c_str()));
1781             ASSERT_TRUE(OH_AVFormat_GetIntBuffer(
1782                 trackFormat, OH_MD_KEY_REFERENCE_TRACK_IDS, &trackIdsDepth, &bufferSize));
1783             ASSERT_EQ(TRACKNUM_3, bufferSize);
1784             ASSERT_EQ(TRACKNUM_0, trackIdsDepth[TRACKNUM_0]);
1785             ASSERT_EQ(TRACKNUM_2, trackIdsDepth[TRACKNUM_1]);
1786             ASSERT_EQ(TRACKNUM_3, trackIdsDepth[TRACKNUM_2]);
1787             SetVideoValue(bufferAttr, videoIsEnd, videoFrame);
1788         }
1789         OH_AVFormat_Destroy(trackFormat);
1790         trackFormat = nullptr;
1791     }
1792     if (fd >= 0) {
1793         close(fd);
1794         fd = -1;
1795     }
1796 }
1797 
1798