1 /*
2 * Copyright (C) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <string>
17 #include <malloc.h>
18 #include <sys/stat.h>
19 #include <cinttypes>
20 #include <fcntl.h>
21 #include <list>
22 #include <cmath>
23 #include "gtest/gtest.h"
24 #include "avcodec_errors.h"
25 #include "media_description.h"
26 #include "demuxer_unit_test.h"
27
28 #define LOCAL true
29
30 using namespace OHOS;
31 using namespace OHOS::Media;
32 using namespace OHOS::MediaAVCodec;
33 using namespace testing::ext;
34 using namespace std;
35
36 namespace {
37 const string TEST_FILE_PATH = "/data/test/media/";
38 // video
39 string g_mp4Path = TEST_FILE_PATH + string("test_265_B_Gop25_4sec.mp4");
40 string g_mp4TimeMetaPath = TEST_FILE_PATH + string("timed_metadata_track.mp4");
41 string g_movPath = TEST_FILE_PATH + string("h264_mp3.mov");
42 string g_flvPath = TEST_FILE_PATH + string("h264.flv");
43 string g_aviPath = TEST_FILE_PATH + string("h264_aac.avi");
44 string g_m4vPath = TEST_FILE_PATH + string("h264_fmp4.m4v");
45 string g_mkvPath = TEST_FILE_PATH + string("h264_mp3_4sec.mkv");
46 string g_tsPath = TEST_FILE_PATH + string("hevc_aac_1920x1080_g30_30fps.ts");
47 string g_mpgPath = TEST_FILE_PATH + string("mpeg_mpeg2_mp3.mpeg");
48 // audio
49 string g_m4aPath = TEST_FILE_PATH + string("audio/h264_fmp4.m4a");
50 string g_apePath = TEST_FILE_PATH + string("ape_test.ape");
51 string g_wavPath = TEST_FILE_PATH + string("wav_audio_test_202406290859.wav");
52 string g_oggPath = TEST_FILE_PATH + string("audio/ogg_48000_1.ogg");
53 string g_aacPath = TEST_FILE_PATH + string("audio/aac_44100_1.aac");
54 string g_amrPath = TEST_FILE_PATH + string("audio/amr_nb_8000_1.amr");
55 string g_flacPath = TEST_FILE_PATH + string("audio/flac_48000_1_cover.flac");
56 // subtitle
57 string g_vttPath = TEST_FILE_PATH + string("webvtt_test.vtt");
58
59 // cache check
60 const double CACHE_LIMIT_RANGE_MAX = 1.1; // +10%
61 const double CACHE_LIMIT_RANGE_MIN = 0.9; // -10%
62 std::vector<std::vector<int32_t>> g_singleTrackCheckSteps = {
63 {0, 1, 0, 0, true}, // read track 0 1 time, check track 0
64 {0, 10, 0, 0, true}, // read track 0 10 times, check track 0
65 {1, 20, 0, 0, false}, // read track 0 20 times, check track 0
66 {1, -1, 0, 0, false}, // read to end
67 };
68 } // namespace
69
TrackIsValid(uint32_t trackId,std::vector<uint32_t> selectedTracks)70 bool TrackIsValid(uint32_t trackId, std::vector<uint32_t> selectedTracks)
71 {
72 return std::any_of(selectedTracks.begin(), selectedTracks.end(), [trackId](uint32_t id) { return id == trackId; });
73 }
74
CheckCache(uint32_t readTrackId,uint32_t times,uint32_t checkTrackId,uint32_t expect,bool exist)75 bool DemuxerUnitTest::CheckCache(
76 uint32_t readTrackId, uint32_t times, uint32_t checkTrackId, uint32_t expect, bool exist)
77 {
78 printf("read %d %d times, check %d, expect %d, exist %d\n", readTrackId, times, checkTrackId, expect, exist);
79 if (demuxer_ == nullptr) {
80 printf("demuxer is nullptr\n");
81 return false;
82 }
83 int step = 0;
84 int32_t ret = AV_ERR_OK;
85 while (TrackIsValid(readTrackId, selectedTrackIds_) && (times == -1 || step < times)) {
86 ret = demuxer_->ReadSample(readTrackId, sharedMem_, &info_, flag_);
87 if (ret != AV_ERR_OK) {
88 printf("read failed\n");
89 return false;
90 }
91 if (flag_ & AVCodecBufferFlag::AVCODEC_BUFFER_FLAG_EOS) {
92 break;
93 }
94 step++;
95 }
96 uint32_t cacheSize = 0;
97 ret = demuxer_->GetCurrentCacheSize(checkTrackId, cacheSize);
98 if (ret != static_cast<int32_t>(Status::OK)) {
99 printf("No track\n");
100 return !exist;
101 }
102 if (cacheSize != expect) {
103 if (static_cast<double>(cacheSize) < CACHE_LIMIT_RANGE_MIN * static_cast<double>(expect) ||
104 static_cast<double>(cacheSize) > CACHE_LIMIT_RANGE_MAX * static_cast<double>(expect)) {
105 printf("cacheSize error\n");
106 return false;
107 } else {
108 printf("not equal, in range limit\n");
109 }
110 }
111 printf("Check pass\n");
112 return true;
113 }
114 /**********************************demuxer inner func**************************************/
115 namespace {
116 #ifdef DEMUXER_INNER_UNIT_TEST
117
118 /**
119 * @tc.name: Demuxer_GetCurrentCacheSize_1000
120 * @tc.desc: GetCurrentCacheSize when reading
121 * @tc.type: FUNC
122 */
123 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_1000, TestSize.Level1)
124 {
125 InitResource(g_mp4Path, LOCAL);
126 ASSERT_TRUE(initStatus_);
127 ASSERT_TRUE(SetInitValue());
128 uint32_t cacheSize = 0;
129 ret_ = demuxer_->GetCurrentCacheSize(1, cacheSize);
130 ASSERT_EQ(ret_, AVCS_ERR_INVALID_OPERATION);
131 ret_ = demuxer_->SelectTrackByID(0);
132 ASSERT_EQ(ret_, AV_ERR_OK);
133 ret_ = demuxer_->GetCurrentCacheSize(1, cacheSize);
134 ASSERT_EQ(ret_, AVCS_ERR_INVALID_VAL);
135 }
136
137 /**
138 * @tc.name: Demuxer_GetCurrentCacheSize_1001
139 * @tc.desc: GetCurrentCacheSize when reading, mp4
140 * @tc.type: FUNC
141 */
142 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_1001, TestSize.Level1)
143 {
144 InitResource(g_mp4Path, LOCAL);
145 ASSERT_TRUE(initStatus_);
146 ASSERT_TRUE(SetInitValue());
147 for (auto idx : selectedTrackIds_) {
148 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
149 }
150 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
151 ASSERT_NE(sharedMem_, nullptr);
152 std::vector<std::vector<int32_t>> cacheCheckSteps = {
153 {1, 1, 0, 156165}, // read track 1 1 time, check track 0
154 {1, 10, 0, 186845}, // read track 1 10 times, check track 0
155 {0, 10, 1, 1534}, // read track 0 10 times, check track 1
156 {0, -1, 0, 0}, // read to end
157 {1, -1, 1, 0}, // read to end
158 };
159 for (auto step : cacheCheckSteps) {
160 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3]));
161 }
162 }
163
164 /**
165 * @tc.name: Demuxer_GetCurrentCacheSize_1002
166 * @tc.desc: GetCurrentCacheSize when reading, mp4+timedmeta
167 * @tc.type: FUNC
168 */
169 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_1002, TestSize.Level1)
170 {
171 InitResource(g_mp4TimeMetaPath, LOCAL);
172 ASSERT_TRUE(initStatus_);
173 ASSERT_TRUE(SetInitValue());
174 for (auto idx : selectedTrackIds_) {
175 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
176 }
177 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
178 ASSERT_NE(sharedMem_, nullptr);
179 std::vector<std::vector<int32_t>> cacheCheckSteps = {
180 {1, 1, 0, 138037}, // read track 1 1 time, check track 0
181 {1, 10, 0, 138037}, // read track 1 10 times, check track 0
182 {0, 10, 1, 0}, // read track 0 10 times, check track 1
183 {0, -1, 0, 0}, // read to end
184 {1, -1, 1, 0}, // read to end
185 };
186 for (auto step : cacheCheckSteps) {
187 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3]));
188 }
189 }
190
191 /**
192 * @tc.name: Demuxer_GetCurrentCacheSize_1003
193 * @tc.desc: GetCurrentCacheSize when reading, mov
194 * @tc.type: FUNC
195 */
196 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_1003, TestSize.Level1)
197 {
198 InitResource(g_movPath, LOCAL);
199 ASSERT_TRUE(initStatus_);
200 ASSERT_TRUE(SetInitValue());
201 for (auto idx : selectedTrackIds_) {
202 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
203 }
204 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
205 ASSERT_NE(sharedMem_, nullptr);
206 std::vector<std::vector<int32_t>> cacheCheckSteps = {
207 {1, 1, 0, 45886}, // read track 1 1 time, check track 0
208 {1, 10, 0, 59158}, // read track 1 10 times, check track 0
209 {0, 10, 1, 0}, // read track 0 10 times, check track 1
210 {0, -1, 0, 0}, // read to end
211 {1, -1, 1, 0}, // read to end
212 };
213 for (auto step : cacheCheckSteps) {
214 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3]));
215 }
216 }
217
218 /**
219 * @tc.name: Demuxer_GetCurrentCacheSize_1004
220 * @tc.desc: GetCurrentCacheSize when reading, flv
221 * @tc.type: FUNC
222 */
223 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_1004, TestSize.Level1)
224 {
225 InitResource(g_flvPath, LOCAL);
226 ASSERT_TRUE(initStatus_);
227 ASSERT_TRUE(SetInitValue());
228 for (auto idx : selectedTrackIds_) {
229 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
230 }
231 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
232 ASSERT_NE(sharedMem_, nullptr);
233 std::vector<std::vector<int32_t>> cacheCheckSteps = {
234 {1, 1, 0, 339258}, // read track 1 1 time, check track 0
235 {1, 10, 0, 539571}, // read track 1 10 times, check track 0
236 {0, 10, 1, 2688}, // read track 0 10 times, check track 1
237 {0, -1, 0, 0}, // read to end
238 {1, -1, 1, 0}, // read to end
239 };
240 for (auto step : cacheCheckSteps) {
241 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3]));
242 }
243 }
244
245 /**
246 * @tc.name: Demuxer_GetCurrentCacheSize_1005
247 * @tc.desc: GetCurrentCacheSize when reading, avi
248 * @tc.type: FUNC
249 */
250 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_1005, TestSize.Level1)
251 {
252 InitResource(g_aviPath, LOCAL);
253 ASSERT_TRUE(initStatus_);
254 ASSERT_TRUE(SetInitValue());
255 for (auto idx : selectedTrackIds_) {
256 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
257 }
258 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
259 ASSERT_NE(sharedMem_, nullptr);
260 std::vector<std::vector<int32_t>> cacheCheckSteps = {
261 {1, 1, 0, 46073}, // read track 1 1 time, check track 0
262 {1, 10, 0, 48066}, // read track 1 10 times, check track 0
263 {0, 10, 1, 7906}, // read track 0 10 times, check track 1
264 {0, -1, 0, 0}, // read to end
265 {1, -1, 1, 0}, // read to end
266 };
267 for (auto step : cacheCheckSteps) {
268 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3]));
269 }
270 }
271
272 /**
273 * @tc.name: Demuxer_GetCurrentCacheSize_1006
274 * @tc.desc: GetCurrentCacheSize when reading, m4v, single track
275 * @tc.type: FUNC
276 */
277 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_1006, TestSize.Level1)
278 {
279 InitResource(g_m4vPath, LOCAL);
280 ASSERT_TRUE(initStatus_);
281 ASSERT_TRUE(SetInitValue());
282 for (auto idx : selectedTrackIds_) {
283 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
284 }
285 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
286 ASSERT_NE(sharedMem_, nullptr);
287 std::vector<std::vector<int32_t>> cacheCheckSteps = {
288 {0, 1, 1, 0, false},
289 {0, 10, 1, 0, false},
290 {0, -1, 0, 0, true}, // read to end
291 };
292 for (auto step : cacheCheckSteps) {
293 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3], step[4]));
294 }
295 }
296
297 /**
298 * @tc.name: Demuxer_GetCurrentCacheSize_1007
299 * @tc.desc: GetCurrentCacheSize when reading, mkv
300 * @tc.type: FUNC
301 */
302 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_1007, TestSize.Level1)
303 {
304 InitResource(g_mkvPath, LOCAL);
305 ASSERT_TRUE(initStatus_);
306 ASSERT_TRUE(SetInitValue());
307 for (auto idx : selectedTrackIds_) {
308 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
309 }
310 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
311 ASSERT_NE(sharedMem_, nullptr);
312 std::vector<std::vector<int32_t>> cacheCheckSteps = {
313 {1, 1, 0, 20464}, // read track 1 1 time, check track 0
314 {1, 10, 0, 171744}, // read track 1 10 times, check track 0
315 {0, 10, 1, 0}, // read track 0 10 times, check track 1
316 {0, -1, 0, 0}, // read to end
317 {1, -1, 1, 0}, // read to end
318 };
319 for (auto step : cacheCheckSteps) {
320 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3]));
321 }
322 }
323
324 /**
325 * @tc.name: Demuxer_GetCurrentCacheSize_1008
326 * @tc.desc: GetCurrentCacheSize when reading, ts
327 * @tc.type: FUNC
328 */
329 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_1008, TestSize.Level1)
330 {
331 InitResource(g_tsPath, LOCAL);
332 ASSERT_TRUE(initStatus_);
333 ASSERT_TRUE(SetInitValue());
334 for (auto idx : selectedTrackIds_) {
335 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
336 }
337 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
338 ASSERT_NE(sharedMem_, nullptr);
339 std::vector<std::vector<int32_t>> cacheCheckSteps = {
340 {1, 1, 0, 57407}, // read track 1 1 time, check track 0
341 {1, 10, 0, 57407}, // read track 1 10 times, check track 0
342 {0, 10, 1, 804}, // read track 0 10 times, check track 1
343 {0, -1, 0, 0}, // read to end
344 {1, -1, 1, 0}, // read to end
345 };
346 for (auto step : cacheCheckSteps) {
347 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3]));
348 }
349 }
350
351 /**
352 * @tc.name: Demuxer_GetCurrentCacheSize_1009
353 * @tc.desc: GetCurrentCacheSize when reading, mpg
354 * @tc.type: FUNC
355 */
356 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_1009, TestSize.Level1)
357 {
358 InitResource(g_mpgPath, LOCAL);
359 ASSERT_TRUE(initStatus_);
360 ASSERT_TRUE(SetInitValue());
361 for (auto idx : selectedTrackIds_) {
362 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
363 }
364 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
365 ASSERT_NE(sharedMem_, nullptr);
366 std::vector<std::vector<int32_t>> cacheCheckSteps = {
367 {1, 1, 0, 0}, // read track 1 1 time, check track 0
368 {1, 10, 0, 225849}, // read track 1 10 times, check track 0
369 {0, 10, 1, 0}, // read track 0 10 times, check track 1
370 {0, -1, 0, 0}, // read to end
371 {1, -1, 1, 0}, // read to end
372 };
373 for (auto step : cacheCheckSteps) {
374 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3]));
375 }
376 }
377
378 /**
379 * @tc.name: Demuxer_GetCurrentCacheSize_2001
380 * @tc.desc: GetCurrentCacheSize when reading, m4a
381 * @tc.type: FUNC
382 */
383 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_2001, TestSize.Level1)
384 {
385 InitResource(g_m4aPath, LOCAL);
386 ASSERT_TRUE(initStatus_);
387 ASSERT_TRUE(SetInitValue());
388 for (auto idx : selectedTrackIds_) {
389 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
390 }
391 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
392 ASSERT_NE(sharedMem_, nullptr);
393 for (auto step : g_singleTrackCheckSteps) {
394 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3], step[4]));
395 }
396 }
397
398 /**
399 * @tc.name: Demuxer_GetCurrentCacheSize_2002
400 * @tc.desc: GetCurrentCacheSize when reading, ape
401 * @tc.type: FUNC
402 */
403 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_2002, TestSize.Level1)
404 {
405 InitResource(g_apePath, LOCAL);
406 ASSERT_TRUE(initStatus_);
407 ASSERT_TRUE(SetInitValue());
408 for (auto idx : selectedTrackIds_) {
409 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
410 }
411 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
412 ASSERT_NE(sharedMem_, nullptr);
413 for (auto step : g_singleTrackCheckSteps) {
414 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3], step[4]));
415 }
416 }
417
418 /**
419 * @tc.name: Demuxer_GetCurrentCacheSize_2003
420 * @tc.desc: GetCurrentCacheSize when reading, wav
421 * @tc.type: FUNC
422 */
423 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_2003, TestSize.Level1)
424 {
425 InitResource(g_wavPath, LOCAL);
426 ASSERT_TRUE(initStatus_);
427 ASSERT_TRUE(SetInitValue());
428 for (auto idx : selectedTrackIds_) {
429 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
430 }
431 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
432 ASSERT_NE(sharedMem_, nullptr);
433 for (auto step : g_singleTrackCheckSteps) {
434 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3], step[4]));
435 }
436 }
437
438 /**
439 * @tc.name: Demuxer_GetCurrentCacheSize_2004
440 * @tc.desc: GetCurrentCacheSize when reading, ogg
441 * @tc.type: FUNC
442 */
443 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_2004, TestSize.Level1)
444 {
445 InitResource(g_oggPath, LOCAL);
446 ASSERT_TRUE(initStatus_);
447 ASSERT_TRUE(SetInitValue());
448 for (auto idx : selectedTrackIds_) {
449 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
450 }
451 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
452 ASSERT_NE(sharedMem_, nullptr);
453 for (auto step : g_singleTrackCheckSteps) {
454 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3], step[4]));
455 }
456 }
457
458 /**
459 * @tc.name: Demuxer_GetCurrentCacheSize_2005
460 * @tc.desc: GetCurrentCacheSize when reading, aac
461 * @tc.type: FUNC
462 */
463 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_2005, TestSize.Level1)
464 {
465 InitResource(g_aacPath, LOCAL);
466 ASSERT_TRUE(initStatus_);
467 ASSERT_TRUE(SetInitValue());
468 for (auto idx : selectedTrackIds_) {
469 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
470 }
471 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
472 ASSERT_NE(sharedMem_, nullptr);
473 for (auto step : g_singleTrackCheckSteps) {
474 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3], step[4]));
475 }
476 }
477
478 /**
479 * @tc.name: Demuxer_GetCurrentCacheSize_2006
480 * @tc.desc: GetCurrentCacheSize when reading, amr
481 * @tc.type: FUNC
482 */
483 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_2006, TestSize.Level1)
484 {
485 InitResource(g_amrPath, LOCAL);
486 ASSERT_TRUE(initStatus_);
487 ASSERT_TRUE(SetInitValue());
488 for (auto idx : selectedTrackIds_) {
489 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
490 }
491 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
492 ASSERT_NE(sharedMem_, nullptr);
493 for (auto step : g_singleTrackCheckSteps) {
494 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3], step[4]));
495 }
496 }
497
498 /**
499 * @tc.name: Demuxer_GetCurrentCacheSize_2007
500 * @tc.desc: GetCurrentCacheSize when reading, flac
501 * @tc.type: FUNC
502 */
503 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_2007, TestSize.Level1)
504 {
505 InitResource(g_flacPath, LOCAL);
506 ASSERT_TRUE(initStatus_);
507 ASSERT_TRUE(SetInitValue());
508 for (auto idx : selectedTrackIds_) {
509 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
510 }
511 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
512 ASSERT_NE(sharedMem_, nullptr);
513 for (auto step : g_singleTrackCheckSteps) {
514 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3], step[4]));
515 }
516 }
517
518 /**
519 * @tc.name: Demuxer_GetCurrentCacheSize_3001
520 * @tc.desc: GetCurrentCacheSize when reading, vtt
521 * @tc.type: FUNC
522 */
523 HWTEST_F(DemuxerUnitTest, Demuxer_GetCurrentCacheSize_3001, TestSize.Level1)
524 {
525 InitResource(g_vttPath, LOCAL);
526 ASSERT_TRUE(initStatus_);
527 ASSERT_TRUE(SetInitValue());
528 for (auto idx : selectedTrackIds_) {
529 ASSERT_EQ(demuxer_->SelectTrackByID(idx), AV_ERR_OK);
530 }
531 sharedMem_ = AVMemoryMockFactory::CreateAVMemoryMock(bufferSize_);
532 ASSERT_NE(sharedMem_, nullptr);
533 for (auto step : g_singleTrackCheckSteps) {
534 ASSERT_TRUE(CheckCache(step[0], step[1], step[2], step[3], step[4]));
535 }
536 }
537 #endif
538 } // namespace
539