1f6603c60Sopenharmony_ci/*
2f6603c60Sopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd.
3f6603c60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4f6603c60Sopenharmony_ci * you may not use this file except in compliance with the License.
5f6603c60Sopenharmony_ci * You may obtain a copy of the License at
6f6603c60Sopenharmony_ci *
7f6603c60Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
8f6603c60Sopenharmony_ci *
9f6603c60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10f6603c60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11f6603c60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12f6603c60Sopenharmony_ci * See the License for the specific language governing permissions and
13f6603c60Sopenharmony_ci * limitations under the License.
14f6603c60Sopenharmony_ci */
15f6603c60Sopenharmony_ci
16f6603c60Sopenharmony_ci#include "gtest/gtest.h"
17f6603c60Sopenharmony_ci
18f6603c60Sopenharmony_ci#include "native_avcodec_base.h"
19f6603c60Sopenharmony_ci#include "native_avdemuxer.h"
20f6603c60Sopenharmony_ci#include "native_avformat.h"
21f6603c60Sopenharmony_ci#include "native_avsource.h"
22f6603c60Sopenharmony_ci#include "native_avbuffer.h"
23f6603c60Sopenharmony_ci
24f6603c60Sopenharmony_ci#include <iostream>
25f6603c60Sopenharmony_ci#include <cstdio>
26f6603c60Sopenharmony_ci#include <string>
27f6603c60Sopenharmony_ci#include <fcntl.h>
28f6603c60Sopenharmony_ci
29f6603c60Sopenharmony_cinamespace OHOS {
30f6603c60Sopenharmony_cinamespace Media {
31f6603c60Sopenharmony_ciclass DemuxerApiNdkTest : public testing::Test {
32f6603c60Sopenharmony_cipublic:
33f6603c60Sopenharmony_ci    // SetUpTestCase: Called before all test cases
34f6603c60Sopenharmony_ci    static void SetUpTestCase(void);
35f6603c60Sopenharmony_ci    // TearDownTestCase: Called after all test case
36f6603c60Sopenharmony_ci    static void TearDownTestCase(void);
37f6603c60Sopenharmony_ci    // SetUp: Called before each test cases
38f6603c60Sopenharmony_ci    void SetUp(void);
39f6603c60Sopenharmony_ci    // TearDown: Called after each test cases
40f6603c60Sopenharmony_ci    void TearDown(void);
41f6603c60Sopenharmony_ci
42f6603c60Sopenharmony_cipublic:
43f6603c60Sopenharmony_ci    int fd1;
44f6603c60Sopenharmony_ci    int64_t size;
45f6603c60Sopenharmony_ci};
46f6603c60Sopenharmony_cistatic int32_t g_width = 3840;
47f6603c60Sopenharmony_cistatic int32_t g_height = 2160;
48f6603c60Sopenharmony_cistatic OH_AVMemory *memory = nullptr;
49f6603c60Sopenharmony_cistatic OH_AVBuffer *buffer = nullptr;
50f6603c60Sopenharmony_cistatic OH_AVSource *source = nullptr;
51f6603c60Sopenharmony_cistatic OH_AVDemuxer *demuxer = nullptr;
52f6603c60Sopenharmony_ciconst char *g_file1 = "/data/test/media/01_video_audio.mp4";
53f6603c60Sopenharmony_ciconst char *g_file2 = "/data/test/media/avcc_10sec.mp4";
54f6603c60Sopenharmony_ci
55f6603c60Sopenharmony_civoid DemuxerApiNdkTest::SetUpTestCase() {}
56f6603c60Sopenharmony_civoid DemuxerApiNdkTest::TearDownTestCase() {}
57f6603c60Sopenharmony_ci
58f6603c60Sopenharmony_civoid DemuxerApiNdkTest::SetUp()
59f6603c60Sopenharmony_ci{
60f6603c60Sopenharmony_ci    memory = OH_AVMemory_Create(g_width * g_height);
61f6603c60Sopenharmony_ci    buffer = OH_AVBuffer_Create(g_width * g_height);
62f6603c60Sopenharmony_ci    fd1 = open(g_file1, O_RDONLY);
63f6603c60Sopenharmony_ci
64f6603c60Sopenharmony_ci    struct stat fileStatus {};
65f6603c60Sopenharmony_ci    if (stat(g_file1, &fileStatus) == 0) {
66f6603c60Sopenharmony_ci        size = static_cast<int64_t>(fileStatus.st_size);
67f6603c60Sopenharmony_ci    }
68f6603c60Sopenharmony_ci
69f6603c60Sopenharmony_ci    std::cout << fd1 << "----------" << g_file1 << "=====" << size << std::endl;
70f6603c60Sopenharmony_ci}
71f6603c60Sopenharmony_ci
72f6603c60Sopenharmony_civoid DemuxerApiNdkTest::TearDown()
73f6603c60Sopenharmony_ci{
74f6603c60Sopenharmony_ci    close(fd1);
75f6603c60Sopenharmony_ci    fd1 = 0;
76f6603c60Sopenharmony_ci    if (memory != nullptr) {
77f6603c60Sopenharmony_ci        OH_AVMemory_Destroy(memory);
78f6603c60Sopenharmony_ci        memory = nullptr;
79f6603c60Sopenharmony_ci    }
80f6603c60Sopenharmony_ci    if (buffer != nullptr) {
81f6603c60Sopenharmony_ci        OH_AVBuffer_Destroy(buffer);
82f6603c60Sopenharmony_ci        buffer = nullptr;
83f6603c60Sopenharmony_ci    }
84f6603c60Sopenharmony_ci    if (source != nullptr) {
85f6603c60Sopenharmony_ci        OH_AVSource_Destroy(source);
86f6603c60Sopenharmony_ci        source = nullptr;
87f6603c60Sopenharmony_ci    }
88f6603c60Sopenharmony_ci    if (demuxer != nullptr) {
89f6603c60Sopenharmony_ci        OH_AVDemuxer_Destroy(demuxer);
90f6603c60Sopenharmony_ci        demuxer = nullptr;
91f6603c60Sopenharmony_ci    }
92f6603c60Sopenharmony_ci}
93f6603c60Sopenharmony_ci} // namespace Media
94f6603c60Sopenharmony_ci} // namespace OHOS
95f6603c60Sopenharmony_ci
96f6603c60Sopenharmony_cinamespace {
97f6603c60Sopenharmony_ciusing namespace std;
98f6603c60Sopenharmony_ciusing namespace OHOS;
99f6603c60Sopenharmony_ciusing namespace OHOS::Media;
100f6603c60Sopenharmony_ciusing namespace testing::ext;
101f6603c60Sopenharmony_ci
102f6603c60Sopenharmony_ci/**
103f6603c60Sopenharmony_ci * @tc.number    : OH_AVSource_CreateWithDataSource_0100
104f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_CreateWithDataSource para error
105f6603c60Sopenharmony_ci * @tc.desc      : api test
106f6603c60Sopenharmony_ci */
107f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, OH_AVSource_CreateWithDataSource_0100, TestSize.Level2)
108f6603c60Sopenharmony_ci{
109f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithDataSource(nullptr);
110f6603c60Sopenharmony_ci    ASSERT_EQ(nullptr, source);
111f6603c60Sopenharmony_ci}
112f6603c60Sopenharmony_ci
113f6603c60Sopenharmony_ci/**
114f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_0100
115f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_CreateWithURI para error
116f6603c60Sopenharmony_ci * @tc.desc      : api test
117f6603c60Sopenharmony_ci */
118f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_0100, TestSize.Level2)
119f6603c60Sopenharmony_ci{
120f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithURI(nullptr);
121f6603c60Sopenharmony_ci    ASSERT_EQ(nullptr, source);
122f6603c60Sopenharmony_ci}
123f6603c60Sopenharmony_ci
124f6603c60Sopenharmony_ci/**
125f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_0200
126f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_CreateWithFD para error
127f6603c60Sopenharmony_ci * @tc.desc      : api test
128f6603c60Sopenharmony_ci */
129f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_0200, TestSize.Level2)
130f6603c60Sopenharmony_ci{
131f6603c60Sopenharmony_ci    // fd must bigger than 2
132f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(2, 0, 0);
133f6603c60Sopenharmony_ci    ASSERT_EQ(nullptr, source);
134f6603c60Sopenharmony_ci}
135f6603c60Sopenharmony_ci
136f6603c60Sopenharmony_ci/**
137f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_0700
138f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_CreateWithFD para error
139f6603c60Sopenharmony_ci * @tc.desc      : api test
140f6603c60Sopenharmony_ci */
141f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_0700, TestSize.Level2)
142f6603c60Sopenharmony_ci{
143f6603c60Sopenharmony_ci    // fd must bigger than 2
144f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(3, 0, -1);
145f6603c60Sopenharmony_ci    ASSERT_EQ(nullptr, source);
146f6603c60Sopenharmony_ci}
147f6603c60Sopenharmony_ci
148f6603c60Sopenharmony_ci/**
149f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_0800
150f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_CreateWithFD para error
151f6603c60Sopenharmony_ci * @tc.desc      : api test
152f6603c60Sopenharmony_ci */
153f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_0800, TestSize.Level2)
154f6603c60Sopenharmony_ci{
155f6603c60Sopenharmony_ci    // fd must bigger than 2
156f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(3, -1, 1);
157f6603c60Sopenharmony_ci    ASSERT_EQ(nullptr, source);
158f6603c60Sopenharmony_ci}
159f6603c60Sopenharmony_ci
160f6603c60Sopenharmony_ci/**
161f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_0300
162f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_Destroy para error
163f6603c60Sopenharmony_ci * @tc.desc      : api test
164f6603c60Sopenharmony_ci */
165f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_0300, TestSize.Level2)
166f6603c60Sopenharmony_ci{
167f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVSource_Destroy(nullptr));
168f6603c60Sopenharmony_ci}
169f6603c60Sopenharmony_ci
170f6603c60Sopenharmony_ci/**
171f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_0400
172f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_GetSourceFormat para error
173f6603c60Sopenharmony_ci * @tc.desc      : api test
174f6603c60Sopenharmony_ci */
175f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_0400, TestSize.Level2)
176f6603c60Sopenharmony_ci{
177f6603c60Sopenharmony_ci    OH_AVFormat *format = OH_AVSource_GetSourceFormat(nullptr);
178f6603c60Sopenharmony_ci    ASSERT_EQ(nullptr, format);
179f6603c60Sopenharmony_ci}
180f6603c60Sopenharmony_ci
181f6603c60Sopenharmony_ci/**
182f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_0500
183f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_GetTrackFormat para error
184f6603c60Sopenharmony_ci * @tc.desc      : api test
185f6603c60Sopenharmony_ci */
186f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_0500, TestSize.Level2)
187f6603c60Sopenharmony_ci{
188f6603c60Sopenharmony_ci    OH_AVFormat *format = OH_AVSource_GetTrackFormat(nullptr, 0);
189f6603c60Sopenharmony_ci    ASSERT_EQ(nullptr, format);
190f6603c60Sopenharmony_ci}
191f6603c60Sopenharmony_ci
192f6603c60Sopenharmony_ci/**
193f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_0600
194f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_GetSourceFormat para error
195f6603c60Sopenharmony_ci * @tc.desc      : api test
196f6603c60Sopenharmony_ci */
197f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_0600, TestSize.Level2)
198f6603c60Sopenharmony_ci{
199f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
200f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
201f6603c60Sopenharmony_ci    OH_AVFormat *format = OH_AVSource_GetTrackFormat(source, -1);
202f6603c60Sopenharmony_ci    ASSERT_EQ(nullptr, format);
203f6603c60Sopenharmony_ci}
204f6603c60Sopenharmony_ci
205f6603c60Sopenharmony_ci/**
206f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_2300
207f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_CreateWithFD para error
208f6603c60Sopenharmony_ci * @tc.desc      : api test
209f6603c60Sopenharmony_ci */
210f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_2300, TestSize.Level2)
211f6603c60Sopenharmony_ci{
212f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, 0);
213f6603c60Sopenharmony_ci    ASSERT_EQ(nullptr, source);
214f6603c60Sopenharmony_ci}
215f6603c60Sopenharmony_ci
216f6603c60Sopenharmony_ci/**
217f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_0900
218f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_CreateWithSource para error
219f6603c60Sopenharmony_ci * @tc.desc      : api test
220f6603c60Sopenharmony_ci */
221f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_0900, TestSize.Level2)
222f6603c60Sopenharmony_ci{
223f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(nullptr);
224f6603c60Sopenharmony_ci    ASSERT_EQ(nullptr, demuxer);
225f6603c60Sopenharmony_ci}
226f6603c60Sopenharmony_ci
227f6603c60Sopenharmony_ci/**
228f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_1000
229f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_Destroy para error
230f6603c60Sopenharmony_ci * @tc.desc      : api test
231f6603c60Sopenharmony_ci */
232f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_1000, TestSize.Level2)
233f6603c60Sopenharmony_ci{
234f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_Destroy(nullptr));
235f6603c60Sopenharmony_ci}
236f6603c60Sopenharmony_ci
237f6603c60Sopenharmony_ci/**
238f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_1100
239f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_SelectTrackByID para error
240f6603c60Sopenharmony_ci * @tc.desc      : api test
241f6603c60Sopenharmony_ci */
242f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_1100, TestSize.Level2)
243f6603c60Sopenharmony_ci{
244f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_SelectTrackByID(nullptr, 0));
245f6603c60Sopenharmony_ci}
246f6603c60Sopenharmony_ci
247f6603c60Sopenharmony_ci/**
248f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_1200
249f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_SelectTrackByID para error
250f6603c60Sopenharmony_ci * @tc.desc      : api test
251f6603c60Sopenharmony_ci */
252f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_1200, TestSize.Level2)
253f6603c60Sopenharmony_ci{
254f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
255f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
256f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
257f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_SelectTrackByID(demuxer, -1));
258f6603c60Sopenharmony_ci}
259f6603c60Sopenharmony_ci
260f6603c60Sopenharmony_ci/**
261f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_1300
262f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_UnselectTrackByID para error
263f6603c60Sopenharmony_ci * @tc.desc      : api test
264f6603c60Sopenharmony_ci */
265f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_1300, TestSize.Level2)
266f6603c60Sopenharmony_ci{
267f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_UnselectTrackByID(nullptr, 0));
268f6603c60Sopenharmony_ci}
269f6603c60Sopenharmony_ci
270f6603c60Sopenharmony_ci/**
271f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_1400
272f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_UnselectTrackByID para error
273f6603c60Sopenharmony_ci * @tc.desc      : api test
274f6603c60Sopenharmony_ci */
275f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_1400, TestSize.Level2)
276f6603c60Sopenharmony_ci{
277f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
278f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
279f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
280f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, demuxer);
281f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_UnselectTrackByID(demuxer, -1)); // unselect ok
282f6603c60Sopenharmony_ci}
283f6603c60Sopenharmony_ci
284f6603c60Sopenharmony_ci/**
285f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_1500
286f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSample para error
287f6603c60Sopenharmony_ci * @tc.desc      : api test
288f6603c60Sopenharmony_ci */
289f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_1500, TestSize.Level2)
290f6603c60Sopenharmony_ci{
291f6603c60Sopenharmony_ci    uint32_t trackIndex = 0;
292f6603c60Sopenharmony_ci    OH_AVCodecBufferAttr bufferAttr;
293f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_ReadSample(nullptr, trackIndex, memory, &bufferAttr));
294f6603c60Sopenharmony_ci}
295f6603c60Sopenharmony_ci
296f6603c60Sopenharmony_ci/**
297f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_1600
298f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSample para error
299f6603c60Sopenharmony_ci * @tc.desc      : api test
300f6603c60Sopenharmony_ci */
301f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_1600, TestSize.Level2)
302f6603c60Sopenharmony_ci{
303f6603c60Sopenharmony_ci    uint32_t trackIndex = -1;
304f6603c60Sopenharmony_ci    OH_AVCodecBufferAttr bufferAttr;
305f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
306f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
307f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
308f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, demuxer);
309f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, OH_AVDemuxer_ReadSample(demuxer, trackIndex, memory, &bufferAttr));
310f6603c60Sopenharmony_ci}
311f6603c60Sopenharmony_ci
312f6603c60Sopenharmony_ci/**
313f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_1700
314f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSample para error
315f6603c60Sopenharmony_ci * @tc.desc      : api test
316f6603c60Sopenharmony_ci */
317f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_1700, TestSize.Level2)
318f6603c60Sopenharmony_ci{
319f6603c60Sopenharmony_ci    uint32_t trackIndex = 0;
320f6603c60Sopenharmony_ci    OH_AVMemory *memory1 = OH_AVMemory_Create(2);
321f6603c60Sopenharmony_ci    OH_AVCodecBufferAttr bufferAttr;
322f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
323f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
324f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
325f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, demuxer);
326f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, 0));
327f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_NO_MEMORY, OH_AVDemuxer_ReadSample(demuxer, trackIndex, memory1, &bufferAttr));
328f6603c60Sopenharmony_ci
329f6603c60Sopenharmony_ci    OH_AVMemory_Destroy(memory1);
330f6603c60Sopenharmony_ci    memory1 = nullptr;
331f6603c60Sopenharmony_ci}
332f6603c60Sopenharmony_ci
333f6603c60Sopenharmony_ci/**
334f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_8600
335f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSample para error
336f6603c60Sopenharmony_ci * @tc.desc      : api test
337f6603c60Sopenharmony_ci */
338f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_2400, TestSize.Level2)
339f6603c60Sopenharmony_ci{
340f6603c60Sopenharmony_ci    uint32_t trackIndex = 0;
341f6603c60Sopenharmony_ci    OH_AVMemory *memory1 = OH_AVMemory_Create(2);
342f6603c60Sopenharmony_ci    OH_AVCodecBufferAttr bufferAttr;
343f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
344f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
345f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
346f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, demuxer);
347f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, OH_AVDemuxer_ReadSample(demuxer, trackIndex, memory1, &bufferAttr));
348f6603c60Sopenharmony_ci
349f6603c60Sopenharmony_ci    OH_AVMemory_Destroy(memory1);
350f6603c60Sopenharmony_ci    memory1 = nullptr;
351f6603c60Sopenharmony_ci}
352f6603c60Sopenharmony_ci
353f6603c60Sopenharmony_ci/**
354f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_1700
355f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSample para error
356f6603c60Sopenharmony_ci * @tc.desc      : api test
357f6603c60Sopenharmony_ci */
358f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_2500, TestSize.Level2)
359f6603c60Sopenharmony_ci{
360f6603c60Sopenharmony_ci    uint32_t trackIndex = 0;
361f6603c60Sopenharmony_ci    OH_AVCodecBufferAttr bufferAttr;
362f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
363f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
364f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
365f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, demuxer);
366f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_ReadSample(demuxer, trackIndex, nullptr, &bufferAttr));
367f6603c60Sopenharmony_ci}
368f6603c60Sopenharmony_ci
369f6603c60Sopenharmony_ci/**
370f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_2600
371f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSampleBuffer para error, input null demuxer
372f6603c60Sopenharmony_ci * @tc.desc      : api test
373f6603c60Sopenharmony_ci */
374f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_2600, TestSize.Level2)
375f6603c60Sopenharmony_ci{
376f6603c60Sopenharmony_ci    uint32_t trackIndex = 0;
377f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_ReadSampleBuffer(nullptr, trackIndex, buffer));
378f6603c60Sopenharmony_ci}
379f6603c60Sopenharmony_ci
380f6603c60Sopenharmony_ci/**
381f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_2700
382f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSampleBuffer para error, input illegal trackIndex
383f6603c60Sopenharmony_ci * @tc.desc      : api test
384f6603c60Sopenharmony_ci */
385f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_2700, TestSize.Level2)
386f6603c60Sopenharmony_ci{
387f6603c60Sopenharmony_ci    uint32_t trackIndex = -1;
388f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
389f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
390f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
391f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, demuxer);
392f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, OH_AVDemuxer_ReadSampleBuffer(demuxer, trackIndex, buffer));
393f6603c60Sopenharmony_ci}
394f6603c60Sopenharmony_ci
395f6603c60Sopenharmony_ci/**
396f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_2800
397f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSampleBuffer para error, input buffer is not enough
398f6603c60Sopenharmony_ci * @tc.desc      : api test
399f6603c60Sopenharmony_ci */
400f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_2800, TestSize.Level2)
401f6603c60Sopenharmony_ci{
402f6603c60Sopenharmony_ci    uint32_t trackIndex = 0;
403f6603c60Sopenharmony_ci    OH_AVBuffer *buffer1 = OH_AVBuffer_Create(2);
404f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
405f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
406f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
407f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, demuxer);
408f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_SelectTrackByID(demuxer, 0));
409f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_NO_MEMORY, OH_AVDemuxer_ReadSampleBuffer(demuxer, trackIndex, buffer1));
410f6603c60Sopenharmony_ci
411f6603c60Sopenharmony_ci    OH_AVBuffer_Destroy(buffer1);
412f6603c60Sopenharmony_ci    buffer1 = nullptr;
413f6603c60Sopenharmony_ci}
414f6603c60Sopenharmony_ci
415f6603c60Sopenharmony_ci/**
416f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_2900
417f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSampleBuffer para error, read before select
418f6603c60Sopenharmony_ci * @tc.desc      : api test
419f6603c60Sopenharmony_ci */
420f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_2900, TestSize.Level2)
421f6603c60Sopenharmony_ci{
422f6603c60Sopenharmony_ci    uint32_t trackIndex = 0;
423f6603c60Sopenharmony_ci    OH_AVBuffer *buffer1 = OH_AVBuffer_Create(2);
424f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
425f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
426f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
427f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, demuxer);
428f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, OH_AVDemuxer_ReadSampleBuffer(demuxer, trackIndex, buffer1));
429f6603c60Sopenharmony_ci
430f6603c60Sopenharmony_ci    OH_AVBuffer_Destroy(buffer1);
431f6603c60Sopenharmony_ci    buffer1 = nullptr;
432f6603c60Sopenharmony_ci}
433f6603c60Sopenharmony_ci
434f6603c60Sopenharmony_ci/**
435f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_3000
436f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSampleBuffer para error, input null buffer
437f6603c60Sopenharmony_ci * @tc.desc      : api test
438f6603c60Sopenharmony_ci */
439f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_3000, TestSize.Level2)
440f6603c60Sopenharmony_ci{
441f6603c60Sopenharmony_ci    uint32_t trackIndex = 0;
442f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
443f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
444f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
445f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, demuxer);
446f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_ReadSampleBuffer(demuxer, trackIndex, nullptr));
447f6603c60Sopenharmony_ci}
448f6603c60Sopenharmony_ci
449f6603c60Sopenharmony_ci/**
450f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_1800
451f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSample para error
452f6603c60Sopenharmony_ci * @tc.desc      : api test
453f6603c60Sopenharmony_ci */
454f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_1800, TestSize.Level2)
455f6603c60Sopenharmony_ci{
456f6603c60Sopenharmony_ci    uint32_t trackIndex = 0;
457f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
458f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, source);
459f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
460f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, demuxer);
461f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_ReadSample(demuxer, trackIndex, memory, nullptr));
462f6603c60Sopenharmony_ci}
463f6603c60Sopenharmony_ci
464f6603c60Sopenharmony_ci/**
465f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_1900
466f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_SeekToTime para error
467f6603c60Sopenharmony_ci * @tc.desc      : api test
468f6603c60Sopenharmony_ci */
469f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_1900, TestSize.Level2)
470f6603c60Sopenharmony_ci{
471f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_SeekToTime(nullptr, 1, SEEK_MODE_NEXT_SYNC));
472f6603c60Sopenharmony_ci}
473f6603c60Sopenharmony_ci
474f6603c60Sopenharmony_ci/**
475f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_2100
476f6603c60Sopenharmony_ci * @tc.name      : OH_AVMemory_Create para error
477f6603c60Sopenharmony_ci * @tc.desc      : api test
478f6603c60Sopenharmony_ci */
479f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_2100, TestSize.Level2)
480f6603c60Sopenharmony_ci{
481f6603c60Sopenharmony_ci    memory = OH_AVMemory_Create(-1);
482f6603c60Sopenharmony_ci    ASSERT_EQ(nullptr, memory);
483f6603c60Sopenharmony_ci}
484f6603c60Sopenharmony_ci
485f6603c60Sopenharmony_ci/**
486f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_2200
487f6603c60Sopenharmony_ci * @tc.name      : OH_AVMemory_Destroy para error
488f6603c60Sopenharmony_ci * @tc.desc      : api test
489f6603c60Sopenharmony_ci */
490f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_ILLEGAL_PARA_2200, TestSize.Level2)
491f6603c60Sopenharmony_ci{
492f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVMemory_Destroy(nullptr));
493f6603c60Sopenharmony_ci}
494f6603c60Sopenharmony_ci
495f6603c60Sopenharmony_ci/**
496f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_API_0200
497f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_CreateWithFD Repeat Call
498f6603c60Sopenharmony_ci * @tc.desc      : api test
499f6603c60Sopenharmony_ci */
500f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_0200, TestSize.Level2)
501f6603c60Sopenharmony_ci{
502f6603c60Sopenharmony_ci    OH_AVSource *source1 = OH_AVSource_CreateWithFD(fd1, 0, size);
503f6603c60Sopenharmony_ci    ASSERT_NE(source1, nullptr);
504f6603c60Sopenharmony_ci    int fd2 = open(g_file2, O_RDONLY);
505f6603c60Sopenharmony_ci    int64_t size2 = 0;
506f6603c60Sopenharmony_ci
507f6603c60Sopenharmony_ci    struct stat fileStatus {};
508f6603c60Sopenharmony_ci    if (stat(g_file2, &fileStatus) == 0) {
509f6603c60Sopenharmony_ci        size2 = static_cast<int64_t>(fileStatus.st_size);
510f6603c60Sopenharmony_ci    }
511f6603c60Sopenharmony_ci
512f6603c60Sopenharmony_ci    OH_AVSource *source2 = OH_AVSource_CreateWithFD(fd2, 0, size2);
513f6603c60Sopenharmony_ci    cout << size2 << "------------------" << endl;
514f6603c60Sopenharmony_ci    ASSERT_NE(source2, nullptr);
515f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OK, OH_AVSource_Destroy(source1));
516f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OK, OH_AVSource_Destroy(source2));
517f6603c60Sopenharmony_ci    source1 = nullptr;
518f6603c60Sopenharmony_ci    source2 = nullptr;
519f6603c60Sopenharmony_ci    close(fd2);
520f6603c60Sopenharmony_ci}
521f6603c60Sopenharmony_ci
522f6603c60Sopenharmony_ci/**
523f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_API_0300
524f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_Destroy Repeat Call
525f6603c60Sopenharmony_ci * @tc.desc      : api test
526f6603c60Sopenharmony_ci */
527f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_0300, TestSize.Level2)
528f6603c60Sopenharmony_ci{
529f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
530f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OK, OH_AVSource_Destroy(source));
531f6603c60Sopenharmony_ci    source = nullptr;
532f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVSource_Destroy(source));
533f6603c60Sopenharmony_ci}
534f6603c60Sopenharmony_ci
535f6603c60Sopenharmony_ci/**
536f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_API_0500
537f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_GetSourceFormat Repeat Call
538f6603c60Sopenharmony_ci * @tc.desc      : api test
539f6603c60Sopenharmony_ci */
540f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_0500, TestSize.Level2)
541f6603c60Sopenharmony_ci{
542f6603c60Sopenharmony_ci    OH_AVFormat *format;
543f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
544f6603c60Sopenharmony_ci    ASSERT_NE(source, nullptr);
545f6603c60Sopenharmony_ci    format = OH_AVSource_GetSourceFormat(source);
546f6603c60Sopenharmony_ci    ASSERT_NE(format, nullptr);
547f6603c60Sopenharmony_ci    format = OH_AVSource_GetSourceFormat(source);
548f6603c60Sopenharmony_ci    ASSERT_NE(format, nullptr);
549f6603c60Sopenharmony_ci}
550f6603c60Sopenharmony_ci
551f6603c60Sopenharmony_ci/**
552f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_API_0700
553f6603c60Sopenharmony_ci * @tc.name      : OH_AVSource_GetTrackFormat Repeat Call
554f6603c60Sopenharmony_ci * @tc.desc      : api test
555f6603c60Sopenharmony_ci */
556f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_0700, TestSize.Level2)
557f6603c60Sopenharmony_ci{
558f6603c60Sopenharmony_ci    OH_AVFormat *format;
559f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
560f6603c60Sopenharmony_ci    ASSERT_NE(source, nullptr);
561f6603c60Sopenharmony_ci
562f6603c60Sopenharmony_ci    format = OH_AVSource_GetTrackFormat(source, 0);
563f6603c60Sopenharmony_ci    ASSERT_NE(format, nullptr);
564f6603c60Sopenharmony_ci    format = OH_AVSource_GetTrackFormat(source, 0);
565f6603c60Sopenharmony_ci    ASSERT_NE(format, nullptr);
566f6603c60Sopenharmony_ci}
567f6603c60Sopenharmony_ci
568f6603c60Sopenharmony_ci/**
569f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_API_1000
570f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_Destroy Repeat Call
571f6603c60Sopenharmony_ci * @tc.desc      : api test
572f6603c60Sopenharmony_ci */
573f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_1000, TestSize.Level2)
574f6603c60Sopenharmony_ci{
575f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
576f6603c60Sopenharmony_ci    ASSERT_NE(source, nullptr);
577f6603c60Sopenharmony_ci
578f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
579f6603c60Sopenharmony_ci    ASSERT_NE(demuxer, nullptr);
580f6603c60Sopenharmony_ci
581f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OK, OH_AVDemuxer_Destroy(demuxer));
582f6603c60Sopenharmony_ci    demuxer = nullptr;
583f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVDemuxer_Destroy(demuxer));
584f6603c60Sopenharmony_ci}
585f6603c60Sopenharmony_ci
586f6603c60Sopenharmony_ci/**
587f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_API_1100
588f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_SelectTrackByID Repeat Call
589f6603c60Sopenharmony_ci * @tc.desc      : api test
590f6603c60Sopenharmony_ci */
591f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_1100, TestSize.Level2)
592f6603c60Sopenharmony_ci{
593f6603c60Sopenharmony_ci    OH_AVErrCode ret = AV_ERR_OK;
594f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
595f6603c60Sopenharmony_ci    ASSERT_NE(source, nullptr);
596f6603c60Sopenharmony_ci
597f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
598f6603c60Sopenharmony_ci    ASSERT_NE(demuxer, nullptr);
599f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_SelectTrackByID(demuxer, 0);
600f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
601f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_SelectTrackByID(demuxer, 0);
602f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
603f6603c60Sopenharmony_ci}
604f6603c60Sopenharmony_ci
605f6603c60Sopenharmony_ci/**
606f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_API_1200
607f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_UnselectTrackByID Repeat Call
608f6603c60Sopenharmony_ci * @tc.desc      : api test
609f6603c60Sopenharmony_ci */
610f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_1200, TestSize.Level2)
611f6603c60Sopenharmony_ci{
612f6603c60Sopenharmony_ci    OH_AVErrCode ret = AV_ERR_OK;
613f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
614f6603c60Sopenharmony_ci    ASSERT_NE(source, nullptr);
615f6603c60Sopenharmony_ci
616f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
617f6603c60Sopenharmony_ci    ASSERT_NE(demuxer, nullptr);
618f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_SelectTrackByID(demuxer, 0);
619f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
620f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_UnselectTrackByID(demuxer, 0);
621f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
622f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_UnselectTrackByID(demuxer, 0);
623f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
624f6603c60Sopenharmony_ci}
625f6603c60Sopenharmony_ci
626f6603c60Sopenharmony_ci/**
627f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_API_1300
628f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSample Repeat Call
629f6603c60Sopenharmony_ci * @tc.desc      : api test
630f6603c60Sopenharmony_ci */
631f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_1300, TestSize.Level2)
632f6603c60Sopenharmony_ci{
633f6603c60Sopenharmony_ci    OH_AVErrCode ret = AV_ERR_OK;
634f6603c60Sopenharmony_ci    OH_AVCodecBufferAttr attr;
635f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
636f6603c60Sopenharmony_ci    ASSERT_NE(source, nullptr);
637f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
638f6603c60Sopenharmony_ci    ASSERT_NE(demuxer, nullptr);
639f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_SelectTrackByID(demuxer, 0);
640f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
641f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_ReadSample(demuxer, 0, memory, &attr);
642f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
643f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_ReadSample(demuxer, 0, memory, &attr);
644f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
645f6603c60Sopenharmony_ci}
646f6603c60Sopenharmony_ci
647f6603c60Sopenharmony_ci/**
648f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_API_1400
649f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_SeekToTime Repeat Call
650f6603c60Sopenharmony_ci * @tc.desc      : api test
651f6603c60Sopenharmony_ci */
652f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_1400, TestSize.Level2)
653f6603c60Sopenharmony_ci{
654f6603c60Sopenharmony_ci    OH_AVErrCode ret = AV_ERR_OK;
655f6603c60Sopenharmony_ci    uint32_t ms = 1000;
656f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
657f6603c60Sopenharmony_ci    ASSERT_NE(source, nullptr);
658f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
659f6603c60Sopenharmony_ci    ASSERT_NE(demuxer, nullptr);
660f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_SelectTrackByID(demuxer, 0);
661f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
662f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_SeekToTime(demuxer, ms, SEEK_MODE_NEXT_SYNC);
663f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
664f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_SeekToTime(demuxer, ms, SEEK_MODE_NEXT_SYNC);
665f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
666f6603c60Sopenharmony_ci}
667f6603c60Sopenharmony_ci
668f6603c60Sopenharmony_ci/**
669f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_API_1500
670f6603c60Sopenharmony_ci * @tc.name      : OH_AVMemory_Create Repeat Call
671f6603c60Sopenharmony_ci * @tc.desc      : api test
672f6603c60Sopenharmony_ci */
673f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_2300, TestSize.Level2)
674f6603c60Sopenharmony_ci{
675f6603c60Sopenharmony_ci    memory = OH_AVMemory_Create(1024);
676f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, memory);
677f6603c60Sopenharmony_ci    memory = OH_AVMemory_Create(2);
678f6603c60Sopenharmony_ci    ASSERT_NE(nullptr, memory);
679f6603c60Sopenharmony_ci}
680f6603c60Sopenharmony_ci
681f6603c60Sopenharmony_ci/**
682f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_ILLEGAL_PARA_2200
683f6603c60Sopenharmony_ci * @tc.name      : OH_AVMemory_Destroy para error
684f6603c60Sopenharmony_ci * @tc.desc      : api test
685f6603c60Sopenharmony_ci */
686f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_2400, TestSize.Level2)
687f6603c60Sopenharmony_ci{
688f6603c60Sopenharmony_ci    memory = OH_AVMemory_Create(2);
689f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_OK, OH_AVMemory_Destroy(memory));
690f6603c60Sopenharmony_ci    memory = nullptr;
691f6603c60Sopenharmony_ci    ASSERT_EQ(AV_ERR_INVALID_VAL, OH_AVMemory_Destroy(memory));
692f6603c60Sopenharmony_ci}
693f6603c60Sopenharmony_ci
694f6603c60Sopenharmony_ci/**
695f6603c60Sopenharmony_ci * @tc.number    : DEMUXER_API_2500
696f6603c60Sopenharmony_ci * @tc.name      : OH_AVDemuxer_ReadSampleBuffer Repeat Call
697f6603c60Sopenharmony_ci * @tc.desc      : api test
698f6603c60Sopenharmony_ci */
699f6603c60Sopenharmony_ciHWTEST_F(DemuxerApiNdkTest, DEMUXER_API_2500, TestSize.Level2)
700f6603c60Sopenharmony_ci{
701f6603c60Sopenharmony_ci    OH_AVErrCode ret = AV_ERR_OK;
702f6603c60Sopenharmony_ci    source = OH_AVSource_CreateWithFD(fd1, 0, size);
703f6603c60Sopenharmony_ci    ASSERT_NE(source, nullptr);
704f6603c60Sopenharmony_ci    demuxer = OH_AVDemuxer_CreateWithSource(source);
705f6603c60Sopenharmony_ci    ASSERT_NE(demuxer, nullptr);
706f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_SelectTrackByID(demuxer, 0);
707f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
708f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_ReadSampleBuffer(demuxer, 0, buffer);
709f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
710f6603c60Sopenharmony_ci    ret = OH_AVDemuxer_ReadSampleBuffer(demuxer, 0, buffer);
711f6603c60Sopenharmony_ci    ASSERT_EQ(ret, AV_ERR_OK);
712f6603c60Sopenharmony_ci}
713f6603c60Sopenharmony_ci}
714