• 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 
24 #include <iostream>
25 #include <cstdio>
26 #include <string>
27 #include <fcntl.h>
28 #include <cmath>
29 #include <thread>
30 namespace OHOS {
31 namespace Media {
32 class DemuxerMovFuncNdkTest : public testing::Test {
33 public:
34     // SetUpTestCase: Called before all test cases
35     static void SetUpTestCase(void);
36     // TearDownTestCase: Called after all test case
37     static void TearDownTestCase(void);
38     // SetUp: Called before each test cases
39     void SetUp(void);
40     // TearDown: Called after each test cases
41     void TearDown(void);
42 };
43 
44 static OH_AVMemory *memory = nullptr;
45 static OH_AVSource *source = nullptr;
46 static OH_AVErrCode ret = AV_ERR_OK;
47 static OH_AVDemuxer *demuxer = nullptr;
48 static OH_AVFormat *sourceFormat = nullptr;
49 static OH_AVFormat *trackFormat = nullptr;
50 static OH_AVBuffer *avBuffer = nullptr;
51 static OH_AVFormat *format = nullptr;
52 static uint8_t g_track0 = 0;
53 static uint8_t g_track1 = 1;
54 static uint8_t g_track2 = 2;
55 static uint8_t g_track3 = 3;
56 static int32_t g_trackCount;
57 static int32_t g_width = 3840;
58 static int32_t g_height = 2160;
59 const std::string HEVC_LIB_PATH = std::string(AV_CODEC_PATH) + "/libav_codec_hevc_parser.z.so";
SetUpTestCase()60 void DemuxerMovFuncNdkTest::SetUpTestCase() {}
TearDownTestCase()61 void DemuxerMovFuncNdkTest::TearDownTestCase() {}
SetUp()62 void DemuxerMovFuncNdkTest::SetUp()
63 {
64     memory = OH_AVMemory_Create(g_width * g_height);
65     g_trackCount = 0;
66 }
TearDown()67 void DemuxerMovFuncNdkTest::TearDown()
68 {
69     if (trackFormat != nullptr) {
70         OH_AVFormat_Destroy(trackFormat);
71         trackFormat = nullptr;
72     }
73 
74     if (sourceFormat != nullptr) {
75         OH_AVFormat_Destroy(sourceFormat);
76         sourceFormat = nullptr;
77     }
78     if (format != nullptr) {
79         OH_AVFormat_Destroy(format);
80         format = nullptr;
81     }
82 
83     if (memory != nullptr) {
84         OH_AVMemory_Destroy(memory);
85         memory = nullptr;
86     }
87     if (source != nullptr) {
88         OH_AVSource_Destroy(source);
89         source = nullptr;
90     }
91     if (demuxer != nullptr) {
92         OH_AVDemuxer_Destroy(demuxer);
93         demuxer = nullptr;
94     }
95     if (avBuffer != nullptr) {
96         OH_AVBuffer_Destroy(avBuffer);
97         avBuffer = nullptr;
98     }
99 }
100 } // namespace Media
101 } // namespace OHOS
102 
103 using namespace std;
104 using namespace OHOS;
105 using namespace OHOS::Media;
106 using namespace testing::ext;
107 
GetFileSize(const char * fileName)108 static int64_t GetFileSize(const char *fileName)
109 {
110     int64_t fileSize = 0;
111     if (fileName != nullptr) {
112         struct stat fileStatus {};
113         if (stat(fileName, &fileStatus) == 0) {
114             fileSize = static_cast<int64_t>(fileStatus.st_size);
115         }
116     }
117     return fileSize;
118 }
119 
OpenFile(const char * fileName,int fd,OH_AVSource ** src,OH_AVDemuxer ** Demuxer)120 static void OpenFile(const char *fileName, int fd, OH_AVSource **src, OH_AVDemuxer **Demuxer)
121 {
122     int64_t size = GetFileSize(fileName);
123     cout << fileName << "----------------------" << fd << "---------" << size << endl;
124     *src = OH_AVSource_CreateWithFD(fd, 0, size);
125     ASSERT_NE(*src, nullptr);
126 
127     *Demuxer = OH_AVDemuxer_CreateWithSource(*src);
128     ASSERT_NE(*Demuxer, nullptr);
129 }
130 
OpenSourceFormat(const char * fileName,int fd,OH_AVSource ** src,OH_AVFormat ** srcFormat)131 static void OpenSourceFormat(const char *fileName, int fd, OH_AVSource **src, OH_AVFormat **srcFormat)
132 {
133     int64_t size = GetFileSize(fileName);
134     cout << fileName << "----------------------" << fd << "---------" << size << endl;
135     *src = OH_AVSource_CreateWithFD(fd, 0, size);
136     ASSERT_NE(*src, nullptr);
137 
138     *srcFormat = OH_AVSource_GetSourceFormat(*src);
139     ASSERT_NE(*srcFormat, nullptr);
140 }
141 
CheckTrackCount(OH_AVFormat ** srcFormat,OH_AVSource * src,int32_t * trackCount,int trackNum)142 static void CheckTrackCount(OH_AVFormat **srcFormat, OH_AVSource *src, int32_t *trackCount, int trackNum)
143 {
144     *srcFormat = OH_AVSource_GetSourceFormat(src);
145     ASSERT_TRUE(OH_AVFormat_GetIntValue(*srcFormat, OH_MD_KEY_TRACK_COUNT, trackCount));
146     ASSERT_EQ(trackNum, *trackCount);
147 }
148 
CheckTrackSelect()149 static void CheckTrackSelect()
150 {
151     for (int32_t index = 0; index < g_trackCount; index++) {
152         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, index));
153     }
154 }
155 
SetAudioValue(OH_AVCodecBufferAttr attr,bool & audioIsEnd,int & audioFrame,int & aKeyCount)156 static void SetAudioValue(OH_AVCodecBufferAttr attr, bool &audioIsEnd, int &audioFrame, int &aKeyCount)
157 {
158     if (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_EOS) {
159         audioIsEnd = true;
160         cout << audioFrame << "    audio is end !!!!!!!!!!!!!!!" << endl;
161     } else {
162         audioFrame++;
163         if (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_SYNC_FRAME) {
164             aKeyCount++;
165         }
166     }
167 }
168 
SetVideoValue(OH_AVCodecBufferAttr attr,bool & videoIsEnd,int & videoFrame,int & vKeyCount)169 static void SetVideoValue(OH_AVCodecBufferAttr attr, bool &videoIsEnd, int &videoFrame, int &vKeyCount)
170 {
171     if (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_EOS) {
172         videoIsEnd = true;
173         cout << videoFrame << "   video is end !!!!!!!!!!!!!!!" << endl;
174     } else {
175         videoFrame++;
176         cout << "video track !!!!!" << endl;
177         if (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_SYNC_FRAME) {
178             vKeyCount++;
179         }
180     }
181 }
182 
CheckFrames(int videoFrameNum,int videoKey,int audioFrameNum,int audioKey)183 static void CheckFrames(int videoFrameNum, int videoKey, int audioFrameNum, int audioKey)
184 {
185     int trackType = 0;
186     OH_AVCodecBufferAttr attr;
187     bool audioIsEnd = false;
188     bool videoIsEnd = false;
189     int audioFrame = 0;
190     int videoFrame = 0;
191     int vKeyCount = 0;
192     int aKeyCount = 0;
193 
194     while (!audioIsEnd || !videoIsEnd) {
195         for (int32_t index = 0; index < g_trackCount; index++) {
196             trackFormat = OH_AVSource_GetTrackFormat(source, index);
197             ASSERT_NE(trackFormat, nullptr);
198             ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &trackType));
199             OH_AVFormat_Destroy(trackFormat);
200             trackFormat = nullptr;
201             if ((audioIsEnd && (trackType == MEDIA_TYPE_AUD)) || (videoIsEnd && (trackType == MEDIA_TYPE_VID))) {
202                 continue;
203             }
204             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSample(demuxer, index, memory, &attr));
205 
206             if (trackType == MEDIA_TYPE_AUD) {
207                 SetAudioValue(attr, audioIsEnd, audioFrame, aKeyCount);
208             } else if (trackType == MEDIA_TYPE_VID) {
209                 SetVideoValue(attr, videoIsEnd, videoFrame, vKeyCount);
210             }
211         }
212     }
213     ASSERT_EQ(audioFrame, audioFrameNum);
214     ASSERT_EQ(aKeyCount, audioKey);
215     ASSERT_EQ(videoFrame, videoFrameNum);
216     ASSERT_EQ(vKeyCount, videoKey);
217 }
218 
InitTrkPara(int index,int * trackType)219 static void InitTrkPara(int index, int *trackType)
220 {
221     trackFormat = OH_AVSource_GetTrackFormat(source, index);
222     ASSERT_NE(trackFormat, nullptr);
223     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, trackType));
224     OH_AVFormat_Destroy(trackFormat);
225     trackFormat = nullptr;
226 }
227 
FramesMultiTrks(int vFrameNum,int videoKey,int aFrameNum,int audioKey)228 static void FramesMultiTrks(int vFrameNum, int videoKey, int aFrameNum, int audioKey)
229 {
230     OH_AVCodecBufferAttr attr;
231     int aKeyCount = 0;
232     int vKeyCount = 0;
233     int audioFrame = 0;
234     int videoFrame = 0;
235     int trackType = 0;
236     bool trackEndFlag[4] = {0, 0, 0, 0};
237     bool allEnd = false;
238     while (!allEnd) {
239         for (int32_t index = 0; index < g_trackCount; index++) {
240             InitTrkPara(index, &trackType);
241             if ((trackEndFlag[index] && (trackType == MEDIA_TYPE_AUD)) ||
242                 (trackEndFlag[index] && (trackType == MEDIA_TYPE_VID))) {
243                 continue;
244             }
245             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSample(demuxer, index, memory, &attr));
246 
247             if (trackType == MEDIA_TYPE_AUD &&
248                 (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_EOS)) {
249                 trackEndFlag[index] = true;
250             } else if (trackType == MEDIA_TYPE_AUD &&
251                 (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_SYNC_FRAME)) {
252                 aKeyCount++;
253                 audioFrame++;
254             } else if (trackType == MEDIA_TYPE_AUD) {
255                 audioFrame++;
256             }
257 
258             if (trackType == MEDIA_TYPE_VID &&
259                 (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_EOS)) {
260                 trackEndFlag[index] = true;
261             } else if (trackType == MEDIA_TYPE_VID &&
262                 (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_SYNC_FRAME)) {
263                 vKeyCount++;
264                 videoFrame++;
265             } else if (trackType == MEDIA_TYPE_VID) {
266                 videoFrame++;
267             }
268         }
269         allEnd = trackEndFlag[g_track0] && trackEndFlag[g_track1] &&
270                      trackEndFlag[g_track2] && trackEndFlag[g_track3];
271     }
272 
273     ASSERT_EQ(audioFrame, aFrameNum);
274     ASSERT_EQ(videoFrame, vFrameNum);
275     ASSERT_EQ(aKeyCount, audioKey);
276     ASSERT_EQ(vKeyCount, videoKey);
277 }
278 
CheckMOVVideoKey()279 static void CheckMOVVideoKey()
280 {
281     int64_t bitrate = 0;
282     const char* mimeType = nullptr;
283     double frameRate;
284     int32_t currentWidth = 0;
285     int32_t currentHeight = 0;
286     ASSERT_TRUE(OH_AVFormat_GetLongValue(trackFormat, OH_MD_KEY_BITRATE, &bitrate));
287     int bitrateResult = 750752;
288     ASSERT_EQ(bitrateResult, bitrate);
289     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, &mimeType));
290     int expectNum = 0;
291     ASSERT_EQ(expectNum, strcmp(mimeType, OH_AVCODEC_MIMETYPE_VIDEO_AVC));
292     ASSERT_TRUE(OH_AVFormat_GetDoubleValue(trackFormat, OH_MD_KEY_FRAME_RATE, &frameRate));
293     int frameRateResult = 30.000000;
294     ASSERT_EQ(frameRateResult, frameRate);
295     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_HEIGHT, &currentHeight));
296     int currentHeightResult = 1080;
297     ASSERT_EQ(currentHeightResult, currentHeight);
298     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_WIDTH, &currentWidth));
299     int currentWidthResult = 1920;
300     ASSERT_EQ(currentWidthResult, currentWidth);
301 }
302 
CheckMOVAudioKey()303 static void CheckMOVAudioKey()
304 {
305     int32_t audioCount = 0;
306     int64_t bitrate = 0;
307     const char* mimeType = nullptr;
308     int32_t sampleRate = 0;
309     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, &audioCount));
310     int audioCountResult = 1;
311     ASSERT_EQ(audioCountResult, audioCount);
312     ASSERT_TRUE(OH_AVFormat_GetLongValue(trackFormat, OH_MD_KEY_BITRATE, &bitrate));
313     int bitrateResult = 70005;
314     ASSERT_EQ(bitrateResult, bitrate);
315     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, &mimeType));
316     int expectNum = 0;
317     ASSERT_EQ(expectNum, strcmp(mimeType, OH_AVCODEC_MIMETYPE_AUDIO_AAC));
318     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, &sampleRate));
319     int sampleRateResult = 48000;
320     ASSERT_EQ(sampleRateResult, sampleRate);
321 }
322 
CheckMPGVideoKey()323 static void CheckMPGVideoKey()
324 {
325     int64_t bitrate = 0;
326     const char* mimeType = nullptr;
327     double frameRate;
328     int32_t currentWidth = 0;
329     int32_t currentHeight = 0;
330     ASSERT_FALSE(OH_AVFormat_GetLongValue(trackFormat, OH_MD_KEY_BITRATE, &bitrate));
331     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, &mimeType));
332     int expectNum = 0;
333     ASSERT_EQ(expectNum, strcmp(mimeType, OH_AVCODEC_MIMETYPE_VIDEO_AVC));
334     ASSERT_TRUE(OH_AVFormat_GetDoubleValue(trackFormat, OH_MD_KEY_FRAME_RATE, &frameRate));
335     int frameRateResult = 30.000000;
336     ASSERT_EQ(frameRateResult, frameRate);
337     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_HEIGHT, &currentHeight));
338     int currentHeightResult = 1080;
339     ASSERT_EQ(currentHeightResult, currentHeight);
340     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_WIDTH, &currentWidth));
341     int currentWidthResult = 1920;
342     ASSERT_EQ(currentWidthResult, currentWidth);
343 }
344 
CheckMPGAudioKey()345 static void CheckMPGAudioKey()
346 {
347     int32_t audioCount = 0;
348     int64_t bitrate = 0;
349     const char* mimeType = nullptr;
350     int32_t sampleRate = 0;
351     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, &audioCount));
352     int audioCountResult = 1;
353     ASSERT_EQ(audioCountResult, audioCount);
354     ASSERT_TRUE(OH_AVFormat_GetLongValue(trackFormat, OH_MD_KEY_BITRATE, &bitrate));
355     int bitrateResult = 384000;
356     ASSERT_EQ(bitrateResult, bitrate);
357     ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, &mimeType));
358     int expectNum = 0;
359     ASSERT_EQ(expectNum, strcmp(mimeType, OH_AVCODEC_MIMETYPE_AUDIO_MPEG));
360     ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, &sampleRate));
361     int sampleRateResult = 44100;
362     ASSERT_EQ(sampleRateResult, sampleRate);
363 }
364 
365 /**
366  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_0100
367  * @tc.name      : demux H264_base@5_1920_1080_30_AAC_48K_1.mov
368  * @tc.desc      : function test
369  */
370 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_0100, TestSize.Level0)
371 {
372     const char *file = "/data/test/media/H264_base@5_1920_1080_30_AAC_48K_1.mov";
373     int fd = open(file, O_RDONLY);
374     OpenFile(file, fd, &source, &demuxer);
375     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
376     CheckTrackSelect();
377     CheckFrames(60, 6, 95, 95);
378     close(fd);
379 }
380 
381 /**
382  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_0200
383  * @tc.name      : demux H264_main@4_1280_720_60_MP2_44.1K_2.mov
384  * @tc.desc      : function test
385  */
386 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_0200, TestSize.Level0)
387 {
388     const char *file = "/data/test/media/H264_main@4_1280_720_60_MP2_44.1K_2.mov";
389     int fd = open(file, O_RDONLY);
390     OpenFile(file, fd, &source, &demuxer);
391     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
392     CheckTrackSelect();
393     CheckFrames(119, 12, 77, 77);
394     close(fd);
395 }
396 
397 /**
398  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_0300
399  * @tc.name      : demux H264_high@5.1_3840_2160_30_MP3_48K_1.mov
400  * @tc.desc      : function test
401  */
402 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_0300, TestSize.Level0)
403 {
404     const char *file = "/data/test/media/H264_high@5.1_3840_2160_30_MP3_48K_1.mov";
405     int fd = open(file, O_RDONLY);
406     OpenFile(file, fd, &source, &demuxer);
407     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
408     CheckTrackSelect();
409     CheckFrames(60, 6, 85, 85);
410     close(fd);
411 }
412 
413 /**
414  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_0400
415  * @tc.name      : demux H264_h444@5.1_1920_1080_60_vorbis_32K_2.mov
416  * @tc.desc      : function test
417  */
418 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_0400, TestSize.Level2)
419 {
420     const char *file = "/data/test/media/H264_h444@5.1_1920_1080_60_vorbis_32K_2.mov";
421     int fd = open(file, O_RDONLY);
422     OpenFile(file, fd, &source, &demuxer);
423     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
424     CheckTrackSelect();
425     CheckFrames(119, 12, 72, 72);
426     close(fd);
427 }
428 
429 /**
430  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_0500
431  * @tc.name      : demux H264_main@3_720_480_30_PCM_48K_24_1.mov
432  * @tc.desc      : function test
433  */
434 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_0500, TestSize.Level0)
435 {
436     const char *file = "/data/test/media/H264_main@3_720_480_30_PCM_48K_24_1.mov";
437     int fd = open(file, O_RDONLY);
438     OpenFile(file, fd, &source, &demuxer);
439     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
440     CheckTrackSelect();
441     CheckFrames(60, 6, 144, 144);
442     close(fd);
443 }
444 
445 /**
446  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_0600
447  * @tc.name      : demux H265_main@4_1920_1080_30_AAC_44.1K_2.mov
448  * @tc.desc      : function test
449  */
450 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_0600, TestSize.Level0)
451 {
452     if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) {
453         return;
454     }
455     const char *file = "/data/test/media/H265_main@4_1920_1080_30_AAC_44.1K_2.mov";
456     int fd = open(file, O_RDONLY);
457     OpenFile(file, fd, &source, &demuxer);
458     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
459     CheckTrackSelect();
460     CheckFrames(60, 6, 88, 88);
461     close(fd);
462 }
463 
464 /**
465  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_0700
466  * @tc.name      : demux H265_main10@4.1_1280_720_60_MP2_48K_1.mov
467  * @tc.desc      : function test
468  */
469 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_0700, TestSize.Level2)
470 {
471     if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) {
472         return;
473     }
474     const char *file = "/data/test/media/H265_main10@4.1_1280_720_60_MP2_48K_1.mov";
475     int fd = open(file, O_RDONLY);
476     OpenFile(file, fd, &source, &demuxer);
477     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
478     CheckTrackSelect();
479     CheckFrames(119, 12, 84, 84);
480     close(fd);
481 }
482 
483 /**
484  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_0800
485  * @tc.name      : demux H265_main10@5_1920_1080_60_MP3_44.1K_2.mov
486  * @tc.desc      : function test
487  */
488 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_0800, TestSize.Level2)
489 {
490     if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) {
491         return;
492     }
493     const char *file = "/data/test/media/H265_main10@5_1920_1080_60_MP3_44.1K_2.mov";
494     int fd = open(file, O_RDONLY);
495     OpenFile(file, fd, &source, &demuxer);
496     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
497     CheckTrackSelect();
498     CheckFrames(119, 12, 78, 78);
499     close(fd);
500 }
501 
502 /**
503  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_0900
504  * @tc.name      : demux H265_main@5_3840_2160_30_vorbis_48K_1.mov
505  * @tc.desc      : function test
506  */
507 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_0900, TestSize.Level0)
508 {
509     if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) {
510         return;
511     }
512     const char *file = "/data/test/media/H265_main@5_3840_2160_30_vorbis_48K_1.mov";
513     int fd = open(file, O_RDONLY);
514     OpenFile(file, fd, &source, &demuxer);
515     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
516     CheckTrackSelect();
517     CheckFrames(60, 6, 96, 96);
518     close(fd);
519 }
520 
521 /**
522  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_1000
523  * @tc.name      : demux H265_main10@5.1_3840_2160_60_PCM(mulaw)_48K_16_2.mov
524  * @tc.desc      : function test
525  */
526 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_1000, TestSize.Level2)
527 {
528     if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) {
529         return;
530     }
531     const char *file = "/data/test/media/H265_main10@5.1_3840_2160_60_PCM(mulaw)_48K_16_2.mov";
532     int fd = open(file, O_RDONLY);
533     OpenFile(file, fd, &source, &demuxer);
534     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
535     CheckTrackSelect();
536     CheckFrames(119, 12, 171, 171);
537     close(fd);
538 }
539 
540 /**
541  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_1100
542  * @tc.name      : demux MPEG4_SP@5_720_480_30_AAC_32K_1.mov
543  * @tc.desc      : function test
544  */
545 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_1100, TestSize.Level0)
546 {
547     const char *file = "/data/test/media/MPEG4_SP@5_720_480_30_AAC_32K_1.mov";
548     int fd = open(file, O_RDONLY);
549     OpenFile(file, fd, &source, &demuxer);
550     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
551     CheckTrackSelect();
552     CheckFrames(60, 6, 64, 64);
553     close(fd);
554 }
555 
556 /**
557  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_1200
558  * @tc.name      : demux MPEG4_SP@6_1280_720_30_MP2_32K_2.mov
559  * @tc.desc      : function test
560  */
561 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_1200, TestSize.Level0)
562 {
563     const char *file = "/data/test/media/MPEG4_SP@6_1280_720_30_MP2_32K_2.mov";
564     int fd = open(file, O_RDONLY);
565     OpenFile(file, fd, &source, &demuxer);
566     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
567     CheckTrackSelect();
568     CheckFrames(60, 6, 56, 56);
569     close(fd);
570 }
571 
572 /**
573  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_1300
574  * @tc.name      : demux MPEG4_ASP@3_352_288_30_MP3_32K_1.mov
575  * @tc.desc      : function test
576  */
577 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_1300, TestSize.Level2)
578 {
579     const char *file = "/data/test/media/MPEG4_ASP@3_352_288_30_MP3_32K_1.mov";
580     int fd = open(file, O_RDONLY);
581     OpenFile(file, fd, &source, &demuxer);
582     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
583     CheckTrackSelect();
584     CheckFrames(60, 6, 57, 57);
585     close(fd);
586 }
587 
588 /**
589  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_1400
590  * @tc.name      : demux MPEG4_ASP@4_720_576_30_Vorbis_44.1K_2.mov
591  * @tc.desc      : function test
592  */
593 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_1400, TestSize.Level2)
594 {
595     const char *file = "/data/test/media/MPEG4_ASP@4_720_576_30_Vorbis_44.1K_2.mov";
596     int fd = open(file, O_RDONLY);
597     OpenFile(file, fd, &source, &demuxer);
598     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
599     CheckTrackSelect();
600     CheckFrames(60, 6, 91, 91);
601     close(fd);
602 }
603 
604 /**
605  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_1500
606  * @tc.name      : demux MPEG4_Core@2_1920_1080_30_PCM(mulaw)_44.1K_16_1.mov
607  * @tc.desc      : function test
608  */
609 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_1500, TestSize.Level0)
610 {
611     const char *file = "/data/test/media/MPEG4_Core@2_1920_1080_30_PCM(mulaw)_44.1K_16_1.mov";
612     int fd = open(file, O_RDONLY);
613     OpenFile(file, fd, &source, &demuxer);
614     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
615     CheckTrackSelect();
616     CheckFrames(45, 5, 65, 65);
617     close(fd);
618 }
619 
620 /**
621  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_1600
622  * @tc.name      : create source with invalid fd
623  * @tc.desc      : function test
624  */
625 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_1600, TestSize.Level2)
626 {
627     const char *file = "/data/test/media/invalid.mov";
628     int fd = open(file, O_RDONLY);
629     int64_t size = GetFileSize(file);
630     cout << file << "----------------------" << fd << "---------" << size << endl;
631     source = OH_AVSource_CreateWithFD(fd, 0, size);
632     ASSERT_EQ(source, nullptr);
633     close(fd);
634 }
635 
636 /**
637  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_1700
638  * @tc.name      : create source with invalid uri
639  * @tc.desc      : function test
640  */
641 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_1700, TestSize.Level2)
642 {
643     const char *uri = "http://invalidPath/invalid.mov";
644     source = OH_AVSource_CreateWithURI(const_cast<char *>(uri));
645     ASSERT_EQ(nullptr, source);
646 }
647 
648 /**
649  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_1900
650  * @tc.name      : demuxer mov  ,check source format,OH_MD_KEY_TITLE
651  * @tc.desc      : function test
652  */
653 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_1900, TestSize.Level2)
654 {
655     const char *file = "/data/test/media/meta_test.mov";
656     int fd = open(file, O_RDONLY);
657     OpenSourceFormat(file, fd, &source, &sourceFormat);
658     const char *stringVal;
659     ASSERT_TRUE(OH_AVFormat_GetStringValue(sourceFormat, OH_MD_KEY_TITLE, &stringVal));
660     ASSERT_EQ(0, strcmp(stringVal, "title"));
661     close(fd);
662 }
663 
664 /**
665  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_2000
666  * @tc.name      : demuxer mov  ,check source format,OH_MD_KEY_ALBUM
667  * @tc.desc      : function test
668  */
669 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_2000, TestSize.Level2)
670 {
671     const char *file = "/data/test/media/meta_test.mov";
672     int fd = open(file, O_RDONLY);
673     OpenSourceFormat(file, fd, &source, &sourceFormat);
674     const char *stringVal;
675     ASSERT_TRUE(OH_AVFormat_GetStringValue(sourceFormat, OH_MD_KEY_ALBUM, &stringVal));
676     ASSERT_EQ(0, strcmp(stringVal, "album"));
677     close(fd);
678 }
679 
680 /**
681  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_2100
682  * @tc.name      : demuxer mov  ,check source format,OH_MD_KEY_ALBUM_ARTIST
683  * @tc.desc      : function test
684  */
685 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_2100, TestSize.Level2)
686 {
687     const char *file = "/data/test/media/meta_test.mov";
688     int fd = open(file, O_RDONLY);
689     OpenSourceFormat(file, fd, &source, &sourceFormat);
690     const char *stringVal;
691     ASSERT_FALSE(OH_AVFormat_GetStringValue(sourceFormat, OH_MD_KEY_ALBUM_ARTIST, &stringVal));
692     close(fd);
693 }
694 
695 /**
696  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_2200
697  * @tc.name      : demuxer mov  ,check track format,OH_MD_KEY_DATE
698  * @tc.desc      : function test
699  */
700 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_2200, TestSize.Level2)
701 {
702     const char *file = "/data/test/media/meta_test.mov";
703     int fd = open(file, O_RDONLY);
704     OpenSourceFormat(file, fd, &source, &sourceFormat);
705     const char *stringVal;
706     ASSERT_TRUE(OH_AVFormat_GetStringValue(sourceFormat, OH_MD_KEY_DATE, &stringVal));
707     ASSERT_EQ(0, strcmp(stringVal, "date"));
708     close(fd);
709 }
710 
711 /**
712  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_2300
713  * @tc.name      : demuxer mov  ,check track format,OH_MD_KEY_COMMENT
714  * @tc.desc      : function test
715  */
716 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_2300, TestSize.Level2)
717 {
718     const char *file = "/data/test/media/meta_test.mov";
719     int fd = open(file, O_RDONLY);
720     OpenSourceFormat(file, fd, &source, &sourceFormat);
721     const char *stringVal;
722     ASSERT_TRUE(OH_AVFormat_GetStringValue(sourceFormat, OH_MD_KEY_COMMENT, &stringVal));
723     ASSERT_EQ(0, strcmp(stringVal, "comment"));
724     close(fd);
725 }
726 
727 /**
728  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_2400
729  * @tc.name      : demuxer mov  ,check track format,OH_MD_KEY_GENRE
730  * @tc.desc      : function test
731  */
732 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_2400, TestSize.Level2)
733 {
734     const char *file = "/data/test/media/meta_test.mov";
735     int fd = open(file, O_RDONLY);
736     OpenSourceFormat(file, fd, &source, &sourceFormat);
737     const char *stringVal;
738     ASSERT_TRUE(OH_AVFormat_GetStringValue(sourceFormat, OH_MD_KEY_GENRE, &stringVal));
739     ASSERT_EQ(0, strcmp(stringVal, "genre"));
740     close(fd);
741 }
742 
743 /**
744  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_2500
745  * @tc.name      : demuxer mov  ,check track format,OH_MD_KEY_COPYRIGHT
746  * @tc.desc      : function test
747  */
748 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_2500, TestSize.Level2)
749 {
750     const char *file = "/data/test/media/meta_test.mov";
751     int fd = open(file, O_RDONLY);
752     OpenSourceFormat(file, fd, &source, &sourceFormat);
753     const char *stringVal;
754     ASSERT_TRUE(OH_AVFormat_GetStringValue(sourceFormat, OH_MD_KEY_COPYRIGHT, &stringVal));
755     ASSERT_EQ(0, strcmp(stringVal, "copyright"));
756     close(fd);
757 }
758 
759 /**
760  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_2600
761  * @tc.name      : demuxer mov  ,check track format,OH_MD_KEY_LANGUAGE
762  * @tc.desc      : function test
763  */
764 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_2600, TestSize.Level2)
765 {
766     const char *file = "/data/test/media/meta_test.mov";
767     int fd = open(file, O_RDONLY);
768     OpenSourceFormat(file, fd, &source, &sourceFormat);
769     const char *stringVal;
770     ASSERT_FALSE(OH_AVFormat_GetStringValue(sourceFormat, OH_MD_KEY_LANGUAGE, &stringVal));
771     close(fd);
772 }
773 
774 /**
775  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_2700
776  * @tc.name      : demuxer mov  ,check track format,OH_MD_KEY_DESCRIPTION
777  * @tc.desc      : function test
778  */
779 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_2700, TestSize.Level2)
780 {
781     const char *file = "/data/test/media/meta_test.mov";
782     int fd = open(file, O_RDONLY);
783     OpenSourceFormat(file, fd, &source, &sourceFormat);
784     const char *stringVal;
785     ASSERT_FALSE(OH_AVFormat_GetStringValue(sourceFormat, OH_MD_KEY_DESCRIPTION, &stringVal));
786     close(fd);
787 }
788 
789 /**
790  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_2800
791  * @tc.name      : demuxer mov  ,check track format,OH_MD_KEY_LYRICS
792  * @tc.desc      : function test
793  */
794 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_2800, TestSize.Level2)
795 {
796     const char *file = "/data/test/media/meta_test.mov";
797     int fd = open(file, O_RDONLY);
798     OpenSourceFormat(file, fd, &source, &sourceFormat);
799     const char *stringVal;
800     ASSERT_FALSE(OH_AVFormat_GetStringValue(sourceFormat, OH_MD_KEY_LYRICS, &stringVal));
801     close(fd);
802 }
803 
804 /**
805  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_2900
806  * @tc.name      : demuxer mov  ,check source format,OH_MD_KEY_ARTIST
807  * @tc.desc      : function test
808  */
809 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_2900, TestSize.Level2)
810 {
811     const char *file = "/data/test/media/meta_test.mov";
812     int fd = open(file, O_RDONLY);
813     OpenSourceFormat(file, fd, &source, &sourceFormat);
814     const char *stringVal;
815     ASSERT_TRUE(OH_AVFormat_GetStringValue(sourceFormat, OH_MD_KEY_ARTIST, &stringVal));
816     ASSERT_EQ(0, strcmp(stringVal, "artist"));
817     close(fd);
818 }
819 
820 /**
821  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_3000
822  * @tc.name      : demuxer mov file, check key
823  * @tc.desc      : function test
824  */
825 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_3000, TestSize.Level2)
826 {
827     int trackType = 0;
828     int64_t duration = 0;
829     int64_t startTime;
830     const char *file = "/data/test/media/H264_base@5_1920_1080_30_AAC_48K_1.mov";
831     int fd = open(file, O_RDONLY);
832     OpenSourceFormat(file, fd, &source, &sourceFormat);
833     trackFormat = OH_AVSource_GetTrackFormat(source, 0);
834     ASSERT_NE(trackFormat, nullptr);
835     ASSERT_TRUE(OH_AVFormat_GetLongValue(sourceFormat, OH_MD_KEY_DURATION, &duration));
836     ASSERT_EQ(2000000, duration);
837     ASSERT_TRUE(OH_AVFormat_GetLongValue(sourceFormat, OH_MD_KEY_START_TIME, &startTime));
838     ASSERT_EQ(0, startTime);
839     ASSERT_TRUE(OH_AVFormat_GetIntValue(sourceFormat, OH_MD_KEY_TRACK_COUNT, &g_trackCount));
840     ASSERT_EQ(2, g_trackCount);
841     demuxer = OH_AVDemuxer_CreateWithSource(source);
842     ASSERT_NE(demuxer, nullptr);
843 
844     const char* mimeType = nullptr;
845     for (int32_t index = 0; index < g_trackCount; index++) {
846         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, index));
847     }
848 
849     OH_AVCodecBufferAttr attr;
850     int vKeyCount = 0;
851     int aKeyCount = 0;
852     bool audioIsEnd = false;
853     bool videoIsEnd = false;
854     int audioFrame = 0;
855     int videoFrame = 0;
856 
857     for (int32_t index = 0; index < g_trackCount; index++) {
858             trackFormat = OH_AVSource_GetTrackFormat(source, index);
859             ASSERT_NE(trackFormat, nullptr);
860             ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &trackType));
861             if ((audioIsEnd && (trackType == MEDIA_TYPE_AUD) && index == MEDIA_TYPE_AUD) ||
862              (videoIsEnd && (trackType == MEDIA_TYPE_VID) && index == MEDIA_TYPE_VID)) {
863                 continue;
864             }
865             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSample(demuxer, index, memory, &attr));
866             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, &mimeType));
867             if (trackType == MEDIA_TYPE_AUD) {
868                 SetAudioValue(attr, audioIsEnd, audioFrame, aKeyCount);
869                 CheckMOVAudioKey();
870             } else if (trackType == MEDIA_TYPE_VID) {
871                 SetVideoValue(attr, videoIsEnd, videoFrame, vKeyCount);
872                 CheckMOVVideoKey();
873             }
874             OH_AVFormat_Destroy(trackFormat);
875             trackFormat = nullptr;
876         }
877 
878     close(fd);
879 }
880 
881 /**
882  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_3100
883  * @tc.name      : demux multi track mov file
884  * @tc.desc      : function test
885  */
886 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_3100, TestSize.Level2)
887 {
888     const char *file = "/data/test/media/multi_trk.mov";
889     int fd = open(file, O_RDONLY);
890     OpenFile(file, fd, &source, &demuxer);
891     CheckTrackCount(&sourceFormat, source, &g_trackCount, 4);
892     CheckTrackSelect();
893     FramesMultiTrks(120, 12, 145, 145);
894     close(fd);
895 }
896 
897 /**
898  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_3200
899  * @tc.name      : create source with error mov file
900  * @tc.desc      : function test
901  */
902 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_3200, TestSize.Level3)
903 {
904     const char *file = "/data/test/media/error.mov";
905     int fd = open(file, O_RDONLY);
906     int64_t size = GetFileSize(file);
907     cout << file << "----------------------" << fd << "---------" << size << endl;
908     source = OH_AVSource_CreateWithFD(fd, 0, size);
909     ASSERT_NE(source, nullptr);
910 
911     demuxer = OH_AVDemuxer_CreateWithSource(source);
912     ASSERT_NE(demuxer, nullptr);
913     OH_AVCodecBufferAttr attr;
914     ASSERT_NE(AV_ERR_OK, OH_AVDemuxer_ReadSample(demuxer, 0, memory, &attr));
915 
916     close(fd);
917 }
918 
919 /**
920  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_3300
921  * @tc.name      : demux mov , zero track
922  * @tc.desc      : function test
923  */
924 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_3300, TestSize.Level3)
925 {
926     const char *file = "/data/test/media/zero_track.mov";
927     int fd = open(file, O_RDONLY);
928     OpenFile(file, fd, &source, &demuxer);
929     CheckTrackCount(&sourceFormat, source, &g_trackCount, 0);
930 
931     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_SelectTrackByID(demuxer, 0));
932     close(fd);
933 }
934 
935 /**
936  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_3400
937  * @tc.name      : seek to a invalid time, closest mode
938  * @tc.desc      : function test
939  */
940 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_3400, TestSize.Level3)
941 {
942     const char *file = "/data/test/media/H264_base@5_1920_1080_30_AAC_48K_1.mov";
943     srand(time(nullptr));
944     int fd = open(file, O_RDONLY);
945     int64_t size = GetFileSize(file);
946     cout << file << "----------------------" << fd << "---------" << size << endl;
947     source = OH_AVSource_CreateWithFD(fd, 0, size);
948     ASSERT_NE(source, nullptr);
949 
950     demuxer = OH_AVDemuxer_CreateWithSource(source);
951     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, 0));
952 
953     ASSERT_NE(demuxer, nullptr);
954     int64_t invalidPts = 12000 * 16666;
955     ret = OH_AVDemuxer_SeekToTime(demuxer, invalidPts, SEEK_MODE_CLOSEST_SYNC);
956     ASSERT_NE(ret, AV_ERR_OK);
957     close(fd);
958 }
959 
960 /**
961  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_3500
962  * @tc.name      : remove track before add track
963  * @tc.desc      : function test
964  */
965 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_3500, TestSize.Level3)
966 {
967     const char *file = "/data/test/media/H264_base@5_1920_1080_30_AAC_48K_1.mov";
968     srand(time(nullptr));
969     int fd = open(file, O_RDONLY);
970     int64_t size = GetFileSize(file);
971     cout << file << "----------------------" << fd << "---------" << size << endl;
972     source = OH_AVSource_CreateWithFD(fd, 0, size);
973     ASSERT_NE(source, nullptr);
974 
975     demuxer = OH_AVDemuxer_CreateWithSource(source);
976     ASSERT_NE(demuxer, nullptr);
977     ret = OH_AVDemuxer_UnselectTrackByID(demuxer, 0);
978     ASSERT_EQ(ret, AV_ERR_OK);
979     ret = OH_AVDemuxer_SelectTrackByID(demuxer, 0);
980     ASSERT_EQ(ret, AV_ERR_OK);
981     close(fd);
982 }
983 
984 /**
985  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_3600
986  * @tc.name      : remove all tracks before demux finish
987  * @tc.desc      : function test
988  */
989 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_3600, TestSize.Level3)
990 {
991     OH_AVCodecBufferAttr attr;
992     const char *file = "/data/test/media/H264_base@5_1920_1080_30_AAC_48K_1.mov";
993     bool isEnd = false;
994     int count = 0;
995     int fd = open(file, O_RDONLY);
996     int64_t size = GetFileSize(file);
997     cout << file << "----------------------" << fd << "---------" << size << endl;
998     source = OH_AVSource_CreateWithFD(fd, 0, size);
999     ASSERT_NE(source, nullptr);
1000 
1001     demuxer = OH_AVDemuxer_CreateWithSource(source);
1002     ASSERT_NE(demuxer, nullptr);
1003 
1004     sourceFormat = OH_AVSource_GetSourceFormat(source);
1005     ASSERT_TRUE(OH_AVFormat_GetIntValue(sourceFormat, OH_MD_KEY_TRACK_COUNT, &g_trackCount));
1006     ASSERT_EQ(2, g_trackCount);
1007     for (int32_t index = 0; index < g_trackCount; index++) {
1008         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, index));
1009     }
1010     srand(time(nullptr));
1011     int pos = rand() % 60;
1012     cout << " pos= " << pos << endl;
1013     while (!isEnd) {
1014         for (int32_t index = 0; index < g_trackCount; index++) {
1015             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSample(demuxer, index, memory, &attr));
1016             if (count == pos) {
1017                 cout << count << " count == pos!!!!!!!!!" << endl;
1018                 ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_UnselectTrackByID(demuxer, 0));
1019                 ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_UnselectTrackByID(demuxer, 1));
1020                 ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, OH_AVDemuxer_ReadSample(demuxer, index, memory, &attr));
1021                 isEnd = true;
1022                 break;
1023             }
1024 
1025             if (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_EOS) {
1026                 isEnd = true;
1027                 cout << "is end !!!!!!!!!!!!!!!" << endl;
1028             }
1029             if (index == MEDIA_TYPE_AUD) {
1030                 count++;
1031             }
1032         }
1033     }
1034     close(fd);
1035 }
1036 
1037 /**
1038  * @tc.number    : MOV_DEMUXER_FUNCTION_TEST_3700
1039  * @tc.name      : start demux bufore add track
1040  * @tc.desc      : function test
1041  */
1042 HWTEST_F(DemuxerMovFuncNdkTest, MOV_DEMUXER_FUNCTION_TEST_3700, TestSize.Level3)
1043 {
1044     uint32_t trackIndex = 0;
1045     OH_AVCodecBufferAttr attr;
1046     const char *file = "/data/test/media/H264_base@5_1920_1080_30_AAC_48K_1.mov";
1047     srand(time(nullptr));
1048     int fd = open(file, O_RDONLY);
1049     int64_t size = GetFileSize(file);
1050     cout << file << "----------------------" << fd << "---------" << size << endl;
1051     source = OH_AVSource_CreateWithFD(fd, 0, size);
1052     ASSERT_NE(source, nullptr);
1053 
1054     demuxer = OH_AVDemuxer_CreateWithSource(source);
1055     ASSERT_NE(demuxer, nullptr);
1056     ret = OH_AVDemuxer_ReadSample(demuxer, trackIndex, memory, &attr);
1057     ASSERT_EQ(ret, AV_ERR_OPERATE_NOT_PERMIT);
1058     close(fd);
1059 }
1060 
1061 /**
1062  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_0100
1063  * @tc.name      : demux H264_base@5_1920_1080_30_MP2_44.1K_1.mpg
1064  * @tc.desc      : function test
1065  */
1066 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_0100, TestSize.Level0)
1067 {
1068     const char *file = "/data/test/media/H264_base@5_1920_1080_30_MP2_44.1K_1.mpg";
1069     int fd = open(file, O_RDONLY);
1070     OpenFile(file, fd, &source, &demuxer);
1071     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
1072     CheckTrackSelect();
1073     CheckFrames(60, 6, 77, 77);
1074     close(fd);
1075 }
1076 
1077 /**
1078  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_0200
1079  * @tc.name      : demux H264_h444p@5.1_1920_1080_60_MP2_48K_2.mpg
1080  * @tc.desc      : function test
1081  */
1082 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_0200, TestSize.Level2)
1083 {
1084     const char *file = "/data/test/media/H264_h444p@5.1_1920_1080_60_MP2_48K_2.mpg";
1085     int fd = open(file, O_RDONLY);
1086     OpenFile(file, fd, &source, &demuxer);
1087     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
1088     CheckTrackSelect();
1089     CheckFrames(119, 12, 84, 84);
1090     close(fd);
1091 }
1092 
1093 /**
1094  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_0300
1095  * @tc.name      : demux H264_high@5.1_3840_2160_30_MP3_44.1K_1.mpg
1096  * @tc.desc      : function test
1097  */
1098 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_0300, TestSize.Level2)
1099 {
1100     const char *file = "/data/test/media/H264_high@5.1_3840_2160_30_MP3_44.1K_1.mpg";
1101     int fd = open(file, O_RDONLY);
1102     OpenFile(file, fd, &source, &demuxer);
1103     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
1104     CheckTrackSelect();
1105     CheckFrames(60, 6, 78, 78);
1106     close(fd);
1107 }
1108 
1109 /**
1110  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_0400
1111  * @tc.name      : demux H264_main@4.2_1280_720_60_MP3_32K_2.mpg
1112  * @tc.desc      : function test
1113  */
1114 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_0400, TestSize.Level0)
1115 {
1116     const char *file = "/data/test/media/H264_main@4.2_1280_720_60_MP3_32K_2.mpg";
1117     int fd = open(file, O_RDONLY);
1118     OpenFile(file, fd, &source, &demuxer);
1119     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
1120     CheckTrackSelect();
1121     CheckFrames(119, 12, 57, 57);
1122     close(fd);
1123 }
1124 
1125 /**
1126  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_0500
1127  * @tc.name      : demux MPEG2_422p_1280_720_60_MP3_32K_1.mpg
1128  * @tc.desc      : function test
1129  */
1130 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_0500, TestSize.Level2)
1131 {
1132     const char *file = "/data/test/media/MPEG2_422p_1280_720_60_MP3_32K_1.mpg";
1133     int fd = open(file, O_RDONLY);
1134     OpenFile(file, fd, &source, &demuxer);
1135     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
1136     CheckTrackSelect();
1137     CheckFrames(119, 12, 57, 57);
1138     close(fd);
1139 }
1140 
1141 /**
1142  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_0600
1143  * @tc.name      : demux MPEG2_high_720_480_30_MP2_32K_2.mpg
1144  * @tc.desc      : function test
1145  */
1146 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_0600, TestSize.Level0)
1147 {
1148     const char *file = "/data/test/media/MPEG2_high_720_480_30_MP2_32K_2.mpg";
1149     int fd = open(file, O_RDONLY);
1150     OpenFile(file, fd, &source, &demuxer);
1151     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
1152     CheckTrackSelect();
1153     CheckFrames(60, 6, 56, 56);
1154     close(fd);
1155 }
1156 
1157 /**
1158  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_0700
1159  * @tc.name      : demux MPEG2_main_352_288_30_MP2_44.1K_1.mpg
1160  * @tc.desc      : function test
1161  */
1162 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_0700, TestSize.Level0)
1163 {
1164     const char *file = "/data/test/media/MPEG2_main_352_288_30_MP2_44.1K_1.mpg";
1165     int fd = open(file, O_RDONLY);
1166     OpenFile(file, fd, &source, &demuxer);
1167     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
1168     CheckTrackSelect();
1169     CheckFrames(60, 6, 77, 77);
1170     close(fd);
1171 }
1172 
1173 /**
1174  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_0800
1175  * @tc.name      : demux MPEG2_main_1920_1080_30_MP3_48K_2.mpg
1176  * @tc.desc      : function test
1177  */
1178 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_0800, TestSize.Level0)
1179 {
1180     const char *file = "/data/test/media/MPEG2_main_1920_1080_30_MP3_48K_2.mpg";
1181     int fd = open(file, O_RDONLY);
1182     OpenFile(file, fd, &source, &demuxer);
1183     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
1184     CheckTrackSelect();
1185     CheckFrames(60, 6, 85, 85);
1186     close(fd);
1187 }
1188 
1189 /**
1190  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_0900
1191  * @tc.name      : demux MPEG2_simple_320_240_24_MP3_48K_2.mpg
1192  * @tc.desc      : function test
1193  */
1194 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_0900, TestSize.Level0)
1195 {
1196     const char *file = "/data/test/media/MPEG2_simple_320_240_24_MP3_48K_2.mpg";
1197     int fd = open(file, O_RDONLY);
1198     OpenFile(file, fd, &source, &demuxer);
1199     CheckTrackCount(&sourceFormat, source, &g_trackCount, 2);
1200     CheckTrackSelect();
1201     CheckFrames(48, 5, 85, 85);
1202     close(fd);
1203 }
1204 
1205 /**
1206  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_1100
1207  * @tc.name      : demuxer mpg file, check key
1208  * @tc.desc      : function test
1209  */
1210 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_1100, TestSize.Level2)
1211 {
1212     int trackType = 0;
1213     int64_t duration = 0;
1214     int64_t startTime;
1215     const char *file = "/data/test/media/H264_base@5_1920_1080_30_MP2_44.1K_1.mpg";
1216     int fd = open(file, O_RDONLY);
1217     OpenSourceFormat(file, fd, &source, &sourceFormat);
1218     trackFormat = OH_AVSource_GetTrackFormat(source, 0);
1219     ASSERT_NE(trackFormat, nullptr);
1220     ASSERT_TRUE(OH_AVFormat_GetLongValue(sourceFormat, OH_MD_KEY_DURATION, &duration));
1221     ASSERT_EQ(2011433, duration);
1222     ASSERT_TRUE(OH_AVFormat_GetLongValue(sourceFormat, OH_MD_KEY_START_TIME, &startTime));
1223     ASSERT_EQ(500000, startTime);
1224     ASSERT_TRUE(OH_AVFormat_GetIntValue(sourceFormat, OH_MD_KEY_TRACK_COUNT, &g_trackCount));
1225     ASSERT_EQ(2, g_trackCount);
1226     demuxer = OH_AVDemuxer_CreateWithSource(source);
1227     ASSERT_NE(demuxer, nullptr);
1228     const char* mimeType = nullptr;
1229     for (int32_t index = 0; index < g_trackCount; index++) {
1230         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, index));
1231     }
1232     OH_AVCodecBufferAttr attr;
1233     int vKeyCount = 0;
1234     int aKeyCount = 0;
1235     bool audioIsEnd = false;
1236     bool videoIsEnd = false;
1237     int audioFrame = 0;
1238     int videoFrame = 0;
1239 
1240     for (int32_t index = 0; index < g_trackCount; index++) {
1241             trackFormat = OH_AVSource_GetTrackFormat(source, index);
1242             ASSERT_NE(trackFormat, nullptr);
1243             ASSERT_TRUE(OH_AVFormat_GetIntValue(trackFormat, OH_MD_KEY_TRACK_TYPE, &trackType));
1244             if ((audioIsEnd && (trackType == MEDIA_TYPE_AUD) && index == MEDIA_TYPE_AUD) ||
1245              (videoIsEnd && (trackType == MEDIA_TYPE_VID) && index == MEDIA_TYPE_VID)) {
1246                 continue;
1247             }
1248             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSample(demuxer, index, memory, &attr));
1249             ASSERT_TRUE(OH_AVFormat_GetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, &mimeType));
1250             if (trackType == MEDIA_TYPE_AUD) {
1251                 SetAudioValue(attr, audioIsEnd, audioFrame, aKeyCount);
1252                 CheckMPGAudioKey();
1253             } else if (trackType == MEDIA_TYPE_VID) {
1254                 SetVideoValue(attr, videoIsEnd, videoFrame, vKeyCount);
1255                 CheckMPGVideoKey();
1256             }
1257             OH_AVFormat_Destroy(trackFormat);
1258             trackFormat = nullptr;
1259         }
1260     close(fd);
1261 }
1262 
1263 /**
1264  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_1200
1265  * @tc.name      : demux multi track mpg file
1266  * @tc.desc      : function test
1267  */
1268 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_1200, TestSize.Level2)
1269 {
1270     const char *file = "/data/test/media/multi_trk.mpg";
1271     int fd = open(file, O_RDONLY);
1272     OpenFile(file, fd, &source, &demuxer);
1273     CheckTrackCount(&sourceFormat, source, &g_trackCount, 4);
1274     CheckTrackSelect();
1275     FramesMultiTrks(167, 17, 142, 142);
1276     close(fd);
1277 }
1278 
1279 /**
1280  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_1300
1281  * @tc.name      : create source with error mpg file
1282  * @tc.desc      : function test
1283  */
1284 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_1300, TestSize.Level3)
1285 {
1286     const char *file = "/data/test/media/error.mpg";
1287     int fd = open(file, O_RDONLY);
1288     int64_t size = GetFileSize(file);
1289     cout << file << "----------------------" << fd << "---------" << size << endl;
1290     source = OH_AVSource_CreateWithFD(fd, 0, size);
1291     ASSERT_NE(source, nullptr);
1292     demuxer = OH_AVDemuxer_CreateWithSource(source);
1293     ASSERT_NE(demuxer, nullptr);
1294     OH_AVCodecBufferAttr attr;
1295     ASSERT_NE(AV_ERR_OK, OH_AVDemuxer_ReadSample(demuxer, 0, memory, &attr));
1296     close(fd);
1297 }
1298 
1299 /**
1300  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_1400
1301  * @tc.name      : demux mpg , zero track
1302  * @tc.desc      : function test
1303  */
1304 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_1400, TestSize.Level3)
1305 {
1306     const char *file = "/data/test/media/zero_track.mpg";
1307     int fd = open(file, O_RDONLY);
1308     OpenFile(file, fd, &source, &demuxer);
1309     CheckTrackCount(&sourceFormat, source, &g_trackCount, 0);
1310 
1311     ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_SelectTrackByID(demuxer, 0));
1312     close(fd);
1313 }
1314 
1315 /**
1316  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_1500
1317  * @tc.name      : seek to a invalid time, closest mode
1318  * @tc.desc      : function test
1319  */
1320 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_1500, TestSize.Level3)
1321 {
1322     const char *file = "/data/test/media/H264_base@5_1920_1080_30_MP2_44.1K_1.mpg";
1323     srand(time(nullptr));
1324     int fd = open(file, O_RDONLY);
1325     int64_t size = GetFileSize(file);
1326     cout << file << "----------------------" << fd << "---------" << size << endl;
1327     source = OH_AVSource_CreateWithFD(fd, 0, size);
1328     ASSERT_NE(source, nullptr);
1329 
1330     demuxer = OH_AVDemuxer_CreateWithSource(source);
1331     ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, 0));
1332 
1333     ASSERT_NE(demuxer, nullptr);
1334     int64_t invalidPts = 12000 * 16666;
1335     ret = OH_AVDemuxer_SeekToTime(demuxer, invalidPts, SEEK_MODE_CLOSEST_SYNC);
1336     ASSERT_NE(ret, AV_ERR_OK);
1337     close(fd);
1338 }
1339 
1340 /**
1341  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_1600
1342  * @tc.name      : remove track before add track
1343  * @tc.desc      : function test
1344  */
1345 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_1600, TestSize.Level3)
1346 {
1347     const char *file = "/data/test/media/H264_base@5_1920_1080_30_MP2_44.1K_1.mpg";
1348     srand(time(nullptr));
1349     int fd = open(file, O_RDONLY);
1350     int64_t size = GetFileSize(file);
1351     cout << file << "----------------------" << fd << "---------" << size << endl;
1352     source = OH_AVSource_CreateWithFD(fd, 0, size);
1353     ASSERT_NE(source, nullptr);
1354 
1355     demuxer = OH_AVDemuxer_CreateWithSource(source);
1356     ASSERT_NE(demuxer, nullptr);
1357     ret = OH_AVDemuxer_UnselectTrackByID(demuxer, 0);
1358     ASSERT_EQ(ret, AV_ERR_OK);
1359     ret = OH_AVDemuxer_SelectTrackByID(demuxer, 0);
1360     ASSERT_EQ(ret, AV_ERR_OK);
1361     close(fd);
1362 }
1363 
1364 /**
1365  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_1700
1366  * @tc.name      : remove all tracks before demux finish
1367  * @tc.desc      : function test
1368  */
1369 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_1700, TestSize.Level3)
1370 {
1371     OH_AVCodecBufferAttr attr;
1372     const char *file = "/data/test/media/H264_base@5_1920_1080_30_MP2_44.1K_1.mpg";
1373     bool isEnd = false;
1374     int count = 0;
1375     int fd = open(file, O_RDONLY);
1376     int64_t size = GetFileSize(file);
1377     cout << file << "----------------------" << fd << "---------" << size << endl;
1378     source = OH_AVSource_CreateWithFD(fd, 0, size);
1379     ASSERT_NE(source, nullptr);
1380 
1381     demuxer = OH_AVDemuxer_CreateWithSource(source);
1382     ASSERT_NE(demuxer, nullptr);
1383 
1384     sourceFormat = OH_AVSource_GetSourceFormat(source);
1385     ASSERT_TRUE(OH_AVFormat_GetIntValue(sourceFormat, OH_MD_KEY_TRACK_COUNT, &g_trackCount));
1386     ASSERT_EQ(2, g_trackCount);
1387     for (int32_t index = 0; index < g_trackCount; index++) {
1388         ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, index));
1389     }
1390     srand(time(nullptr));
1391     int pos = rand() % 60;
1392     cout << " pos= " << pos << endl;
1393     while (!isEnd) {
1394         for (int32_t index = 0; index < g_trackCount; index++) {
1395             ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_ReadSample(demuxer, index, memory, &attr));
1396             if (count == pos) {
1397                 cout << count << " count == pos!!!!!!!!!" << endl;
1398                 ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_UnselectTrackByID(demuxer, 0));
1399                 ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_UnselectTrackByID(demuxer, 1));
1400                 ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, OH_AVDemuxer_ReadSample(demuxer, index, memory, &attr));
1401                 isEnd = true;
1402                 break;
1403             }
1404 
1405             if (attr.flags & OH_AVCodecBufferFlags::AVCODEC_BUFFER_FLAGS_EOS) {
1406                 isEnd = true;
1407                 cout << "is end !!!!!!!!!!!!!!!" << endl;
1408             }
1409             if (index == MEDIA_TYPE_AUD) {
1410                 count++;
1411             }
1412         }
1413     }
1414     close(fd);
1415 }
1416 
1417 /**
1418  * @tc.number    : MPG_DEMUXER_FUNCTION_TEST_1800
1419  * @tc.name      : start demux bufore add track
1420  * @tc.desc      : function test
1421  */
1422 HWTEST_F(DemuxerMovFuncNdkTest, MPG_DEMUXER_FUNCTION_TEST_1800, TestSize.Level3)
1423 {
1424     uint32_t trackIndex = 0;
1425     OH_AVCodecBufferAttr attr;
1426     const char *file = "/data/test/media/H264_base@5_1920_1080_30_MP2_44.1K_1.mpg";
1427     srand(time(nullptr));
1428     int fd = open(file, O_RDONLY);
1429     int64_t size = GetFileSize(file);
1430     cout << file << "----------------------" << fd << "---------" << size << endl;
1431     source = OH_AVSource_CreateWithFD(fd, 0, size);
1432     ASSERT_NE(source, nullptr);
1433 
1434     demuxer = OH_AVDemuxer_CreateWithSource(source);
1435     ASSERT_NE(demuxer, nullptr);
1436     ret = OH_AVDemuxer_ReadSample(demuxer, trackIndex, memory, &attr);
1437     ASSERT_EQ(ret, AV_ERR_OPERATE_NOT_PERMIT);
1438     close(fd);
1439 }