1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include <string>
17#include "gtest/gtest.h"
18#include "AVMuxerDemo.h"
19
20using namespace std;
21using namespace testing::ext;
22using namespace OHOS;
23using namespace OHOS::MediaAVCodec;
24
25
26namespace {
27    class NativeAVMuxerInterfaceDependCheckTest : public testing::Test {
28    public:
29        static void SetUpTestCase();
30        static void TearDownTestCase();
31        void SetUp() override;
32        void TearDown() override;
33    };
34
35    void NativeAVMuxerInterfaceDependCheckTest::SetUpTestCase() {}
36    void NativeAVMuxerInterfaceDependCheckTest::TearDownTestCase() {}
37    void NativeAVMuxerInterfaceDependCheckTest::SetUp() {}
38    void NativeAVMuxerInterfaceDependCheckTest::TearDown() {}
39
40    constexpr int64_t BITRATE = 32000;
41    constexpr int32_t CODEC_CONFIG = 100;
42    constexpr int32_t CHANNEL_COUNT = 1;
43    constexpr int32_t SAMPLE_RATE = 48000;
44    constexpr int32_t PROFILE = 0;
45    constexpr int32_t INFO_SIZE = 100;
46
47    OH_AVMuxer* Create(AVMuxerDemo* muxerDemo)
48    {
49        OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4;
50        OH_AVMuxer* handle = nullptr;
51        int32_t fd = muxerDemo->GetFdByMode(format);
52        handle = muxerDemo->NativeCreate(fd, format);
53
54        return handle;
55    }
56
57    OH_AVErrCode SetRotation(AVMuxerDemo* muxerDemo, OH_AVMuxer* handle)
58    {
59        int32_t rotation = 0;
60
61        OH_AVErrCode ret = muxerDemo->NativeSetRotation(handle, rotation);
62
63        return ret;
64    }
65
66    OH_AVErrCode AddTrack(AVMuxerDemo* muxerDemo, int32_t* trackId, OH_AVMuxer* handle)
67    {
68        uint8_t a[100];
69
70        OH_AVFormat* trackFormat = OH_AVFormat_Create();
71        OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC);
72        OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, BITRATE);
73        OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG);
74        OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT);
75        OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE);
76        OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE);
77
78        OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, trackId, trackFormat);
79        OH_AVFormat_Destroy(trackFormat);
80        return ret;
81    }
82
83    OH_AVErrCode Start(AVMuxerDemo* muxerDemo, OH_AVMuxer* handle)
84    {
85        OH_AVErrCode ret = muxerDemo->NativeStart(handle);
86
87        return ret;
88    }
89
90    OH_AVErrCode WriteSampleBuffer(AVMuxerDemo* muxerDemo, OH_AVMuxer* handle, uint32_t trackIndex)
91    {
92        OH_AVMemory* avMemBuffer = OH_AVMemory_Create(100);
93
94        OH_AVCodecBufferAttr info;
95        info.size = INFO_SIZE;
96        info.pts = 0;
97        info.offset = 0;
98        info.flags = 0;
99
100        OH_AVErrCode ret = muxerDemo->NativeWriteSampleBuffer(handle, trackIndex, avMemBuffer, info);
101        OH_AVMemory_Destroy(avMemBuffer);
102        return ret;
103    }
104
105    OH_AVErrCode Stop(AVMuxerDemo* muxerDemo, OH_AVMuxer* handle)
106    {
107        OH_AVErrCode ret = muxerDemo->NativeStop(handle);
108
109        return ret;
110    }
111
112    OH_AVErrCode Destroy(AVMuxerDemo* muxerDemo, OH_AVMuxer* handle)
113    {
114        OH_AVErrCode ret = muxerDemo->NativeDestroy(handle);
115
116        return ret;
117    }
118}
119
120
121/**
122 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_001
123 * @tc.name      : Create -> SetRotation
124 * @tc.desc      : interface depend check
125 */
126HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_001, TestSize.Level2)
127{
128    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
129    OH_AVMuxer* handle = Create(muxerDemo);
130    ASSERT_NE(nullptr, handle);
131
132    OH_AVErrCode ret;
133
134    ret = SetRotation(muxerDemo, handle);
135    ASSERT_EQ(AV_ERR_OK, ret);
136
137    Destroy(muxerDemo, handle);
138    delete muxerDemo;
139}
140
141
142/**
143 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_002
144 * @tc.name      : Create -> SetRotation -> SetRotation
145 * @tc.desc      : interface depend check
146 */
147HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_002, TestSize.Level2)
148{
149    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
150    OH_AVMuxer* handle = Create(muxerDemo);
151    ASSERT_NE(nullptr, handle);
152
153    OH_AVErrCode ret;
154
155    ret = SetRotation(muxerDemo, handle);
156    ASSERT_EQ(AV_ERR_OK, ret);
157
158    ret = SetRotation(muxerDemo, handle);
159    ASSERT_EQ(AV_ERR_OK, ret);
160
161    Destroy(muxerDemo, handle);
162    delete muxerDemo;
163}
164
165
166/**
167 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_003
168 * @tc.name      : Create -> AddTrack -> SetRotation
169 * @tc.desc      : interface depend check
170 */
171HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_003, TestSize.Level2)
172{
173    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
174    OH_AVMuxer* handle = Create(muxerDemo);
175    ASSERT_NE(nullptr, handle);
176
177    OH_AVErrCode ret;
178
179    int32_t trackId;
180    ret = AddTrack(muxerDemo, &trackId, handle);
181    ASSERT_EQ(0, trackId);
182
183    ret = SetRotation(muxerDemo, handle);
184    ASSERT_EQ(AV_ERR_OK, ret);
185
186    Destroy(muxerDemo, handle);
187    delete muxerDemo;
188}
189
190
191/**
192 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_004
193 * @tc.name      : Create -> AddTrack -> Start -> SetRotation
194 * @tc.desc      : interface depend check
195 */
196HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_004, TestSize.Level2)
197{
198    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
199    OH_AVMuxer* handle = Create(muxerDemo);
200    ASSERT_NE(nullptr, handle);
201
202    OH_AVErrCode ret;
203
204    int32_t trackId;
205    ret = AddTrack(muxerDemo, &trackId, handle);
206    ASSERT_EQ(0, trackId);
207
208    ret = Start(muxerDemo, handle);
209    ASSERT_EQ(AV_ERR_OK, ret);
210
211    ret = SetRotation(muxerDemo, handle);
212    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
213
214    Destroy(muxerDemo, handle);
215    delete muxerDemo;
216}
217
218
219/**
220 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_005
221 * @tc.name      : Create -> AddTrack -> Start -> Stop -> SetRotation
222 * @tc.desc      : interface depend check
223 */
224HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_005, TestSize.Level2)
225{
226    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
227    OH_AVMuxer* handle = Create(muxerDemo);
228    ASSERT_NE(nullptr, handle);
229
230    OH_AVErrCode ret;
231
232    int32_t trackId;
233    ret = AddTrack(muxerDemo, &trackId, handle);
234    ASSERT_EQ(0, trackId);
235
236    ret = Start(muxerDemo, handle);
237    ASSERT_EQ(AV_ERR_OK, ret);
238
239    ret = Stop(muxerDemo, handle);
240    ASSERT_EQ(AV_ERR_OK, ret);
241
242    ret = SetRotation(muxerDemo, handle);
243    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
244
245    Destroy(muxerDemo, handle);
246    delete muxerDemo;
247}
248
249
250/**
251 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_006
252 * @tc.name      : Create -> AddTrack
253 * @tc.desc      : interface depend check
254 */
255HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_006, TestSize.Level2)
256{
257    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
258    OH_AVMuxer* handle = Create(muxerDemo);
259    ASSERT_NE(nullptr, handle);
260
261    int32_t trackId;
262    OH_AVErrCode ret = AddTrack(muxerDemo, &trackId, handle);
263    ASSERT_EQ(0, trackId);
264    ASSERT_EQ(AV_ERR_OK, ret);
265
266    Destroy(muxerDemo, handle);
267    delete muxerDemo;
268}
269
270
271/**
272 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_007
273 * @tc.name      : Create -> AddTrack -> AddTrack
274 * @tc.desc      : interface depend check
275 */
276HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_007, TestSize.Level2)
277{
278    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
279    OH_AVMuxer* handle = Create(muxerDemo);
280    ASSERT_NE(nullptr, handle);
281
282    int32_t trackId;
283    OH_AVErrCode ret = AddTrack(muxerDemo, &trackId, handle);
284    ASSERT_EQ(AV_ERR_OK, ret);
285    ASSERT_EQ(0, trackId);
286
287    ret = AddTrack(muxerDemo, &trackId, handle);
288    ASSERT_EQ(AV_ERR_OK, ret);
289    ASSERT_EQ(1, trackId);
290
291    Destroy(muxerDemo, handle);
292    delete muxerDemo;
293}
294
295
296/**
297 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_008
298 * @tc.name      : Create -> SetRotation -> AddTrack
299 * @tc.desc      : interface depend check
300 */
301HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_008, TestSize.Level2)
302{
303    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
304    OH_AVMuxer* handle = Create(muxerDemo);
305    ASSERT_NE(nullptr, handle);
306
307    OH_AVErrCode ret;
308
309    ret = SetRotation(muxerDemo, handle);
310    ASSERT_EQ(AV_ERR_OK, ret);
311
312    int32_t trackId;
313    ret = AddTrack(muxerDemo, &trackId, handle);
314    ASSERT_EQ(0, trackId);
315
316    Destroy(muxerDemo, handle);
317    delete muxerDemo;
318}
319
320
321/**
322 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_009
323 * @tc.name      : Create -> AddTrack -> Start -> AddTrack
324 * @tc.desc      : interface depend check
325 */
326HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_009, TestSize.Level2)
327{
328    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
329    OH_AVMuxer* handle = Create(muxerDemo);
330    ASSERT_NE(nullptr, handle);
331
332    OH_AVErrCode ret;
333
334    int32_t trackId;
335    ret = AddTrack(muxerDemo, &trackId, handle);
336    ASSERT_EQ(0, trackId);
337
338    ret = Start(muxerDemo, handle);
339    ASSERT_EQ(AV_ERR_OK, ret);
340
341    ret = AddTrack(muxerDemo, &trackId, handle);
342    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
343
344    Destroy(muxerDemo, handle);
345    delete muxerDemo;
346}
347
348
349/**
350 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_010
351 * @tc.name      : Create -> AddTrack -> Start -> Stop -> AddTrack
352 * @tc.desc      : interface depend check
353 */
354HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_010, TestSize.Level2)
355{
356    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
357    OH_AVMuxer* handle = Create(muxerDemo);
358    ASSERT_NE(nullptr, handle);
359
360    OH_AVErrCode ret;
361
362    int32_t trackId;
363    ret = AddTrack(muxerDemo, &trackId, handle);
364    ASSERT_EQ(0, trackId);
365
366    ret = Start(muxerDemo, handle);
367    ASSERT_EQ(AV_ERR_OK, ret);
368
369    ret = Stop(muxerDemo, handle);
370    ASSERT_EQ(AV_ERR_OK, ret);
371
372    ret = AddTrack(muxerDemo, &trackId, handle);
373    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
374
375    Destroy(muxerDemo, handle);
376    delete muxerDemo;
377}
378
379
380/**
381 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_011
382 * @tc.name      : Create -> Start
383 * @tc.desc      : interface depend check
384 */
385HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_011, TestSize.Level2)
386{
387    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
388    OH_AVMuxer* handle = Create(muxerDemo);
389    ASSERT_NE(nullptr, handle);
390
391    OH_AVErrCode ret;
392
393    ret = Start(muxerDemo, handle);
394    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
395
396    Destroy(muxerDemo, handle);
397    delete muxerDemo;
398}
399
400
401/**
402 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_012
403 * @tc.name      : Create -> AddTrack -> Start
404 * @tc.desc      : interface depend check
405 */
406HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_012, TestSize.Level2)
407{
408    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
409    OH_AVMuxer* handle = Create(muxerDemo);
410    ASSERT_NE(nullptr, handle);
411
412    OH_AVErrCode ret;
413
414    int32_t trackId;
415    ret = AddTrack(muxerDemo, &trackId, handle);
416    ASSERT_EQ(0, trackId);
417
418    ret = Start(muxerDemo, handle);
419    ASSERT_EQ(AV_ERR_OK, ret);
420
421    Destroy(muxerDemo, handle);
422    delete muxerDemo;
423}
424
425
426/**
427 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_013
428 * @tc.name      : Create -> SetRotation -> AddTrack -> Start
429 * @tc.desc      : interface depend check
430 */
431HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_013, TestSize.Level2)
432{
433    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
434    OH_AVMuxer* handle = Create(muxerDemo);
435    ASSERT_NE(nullptr, handle);
436
437    OH_AVErrCode ret;
438
439    ret = SetRotation(muxerDemo, handle);
440    ASSERT_EQ(AV_ERR_OK, ret);
441
442    int32_t trackId;
443    ret = AddTrack(muxerDemo, &trackId, handle);
444    ASSERT_EQ(0, trackId);
445
446    ret = Start(muxerDemo, handle);
447    ASSERT_EQ(AV_ERR_OK, ret);
448
449    Destroy(muxerDemo, handle);
450    delete muxerDemo;
451}
452
453
454/**
455 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_014
456 * @tc.name      : Create -> AddTrack -> Start -> Start
457 * @tc.desc      : interface depend check
458 */
459HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_014, TestSize.Level2)
460{
461    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
462    OH_AVMuxer* handle = Create(muxerDemo);
463    ASSERT_NE(nullptr, handle);
464
465    OH_AVErrCode ret;
466
467    int32_t trackId;
468    ret = AddTrack(muxerDemo, &trackId, handle);
469    ASSERT_EQ(0, trackId);
470
471    ret = Start(muxerDemo, handle);
472    ASSERT_EQ(AV_ERR_OK, ret);
473
474    ret = Start(muxerDemo, handle);
475    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
476
477    Destroy(muxerDemo, handle);
478    delete muxerDemo;
479}
480
481
482/**
483 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_015
484 * @tc.name      : Create -> AddTrack -> Start -> Stop -> Start
485 * @tc.desc      : interface depend check
486 */
487HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_015, TestSize.Level2)
488{
489    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
490    OH_AVMuxer* handle = Create(muxerDemo);
491    ASSERT_NE(nullptr, handle);
492
493    OH_AVErrCode ret;
494
495    int32_t trackId;
496    ret = AddTrack(muxerDemo, &trackId, handle);
497    ASSERT_EQ(0, trackId);
498
499    ret = Start(muxerDemo, handle);
500    ASSERT_EQ(AV_ERR_OK, ret);
501
502    ret = Stop(muxerDemo, handle);
503    ASSERT_EQ(AV_ERR_OK, ret);
504
505    ret = Start(muxerDemo, handle);
506    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
507
508    Destroy(muxerDemo, handle);
509    delete muxerDemo;
510}
511
512
513/**
514 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_016
515 * @tc.name      : Create -> WriteSampleBuffer
516 * @tc.desc      : interface depend check
517 */
518HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_016, TestSize.Level2)
519{
520    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
521    OH_AVMuxer* handle = Create(muxerDemo);
522    ASSERT_NE(nullptr, handle);
523
524    OH_AVErrCode ret;
525    int32_t trackId = -1;
526
527    ret = WriteSampleBuffer(muxerDemo, handle, trackId);
528    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
529
530    Destroy(muxerDemo, handle);
531    delete muxerDemo;
532}
533
534
535/**
536 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_017
537 * @tc.name      : Create -> AddTrack -> WriteSampleBuffer
538 * @tc.desc      : interface depend check
539 */
540HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_017, TestSize.Level2)
541{
542    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
543    OH_AVMuxer* handle = Create(muxerDemo);
544    ASSERT_NE(nullptr, handle);
545
546    OH_AVErrCode ret;
547    int32_t trackId = -1;
548
549    ret = AddTrack(muxerDemo, &trackId, handle);
550    ASSERT_EQ(0, trackId);
551
552    ret = WriteSampleBuffer(muxerDemo, handle, trackId);
553    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
554
555    Destroy(muxerDemo, handle);
556    delete muxerDemo;
557}
558
559
560/**
561 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_018
562 * @tc.name      : Create -> SetRotation -> AddTrack -> Start -> WriteSampleBuffer
563 * @tc.desc      : interface depend check
564 */
565HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_018, TestSize.Level2)
566{
567    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
568    OH_AVMuxer* handle = Create(muxerDemo);
569    ASSERT_NE(nullptr, handle);
570
571    OH_AVErrCode ret;
572    int32_t trackId = -1;
573
574    ret = SetRotation(muxerDemo, handle);
575    ASSERT_EQ(AV_ERR_OK, ret);
576
577    ret = AddTrack(muxerDemo, &trackId, handle);
578    ASSERT_EQ(0, trackId);
579
580    ret = Start(muxerDemo, handle);
581    ASSERT_EQ(AV_ERR_OK, ret);
582
583    ret = WriteSampleBuffer(muxerDemo, handle, trackId);
584    ASSERT_EQ(AV_ERR_OK, ret);
585
586    Destroy(muxerDemo, handle);
587    delete muxerDemo;
588}
589
590
591/**
592 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_019
593 * @tc.name      : Create -> AddTrack -> Start -> WriteSampleBuffer
594 * @tc.desc      : interface depend check
595 */
596HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_019, TestSize.Level2)
597{
598    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
599    OH_AVMuxer* handle = Create(muxerDemo);
600    ASSERT_NE(nullptr, handle);
601
602    OH_AVErrCode ret;
603    int32_t trackId = -1;
604
605    ret = AddTrack(muxerDemo, &trackId, handle);
606    ASSERT_EQ(0, trackId);
607
608    ret = Start(muxerDemo, handle);
609    ASSERT_EQ(AV_ERR_OK, ret);
610
611    ret = WriteSampleBuffer(muxerDemo, handle, trackId);
612    ASSERT_EQ(AV_ERR_OK, ret);
613
614    Destroy(muxerDemo, handle);
615    delete muxerDemo;
616}
617
618
619/**
620 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_020
621 * @tc.name      : Create -> AddTrack -> Start -> WriteSampleBuffer -> WriteSampleBuffer
622 * @tc.desc      : interface depend check
623 */
624HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_020, TestSize.Level2)
625{
626    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
627    OH_AVMuxer* handle = Create(muxerDemo);
628    ASSERT_NE(nullptr, handle);
629
630    OH_AVErrCode ret;
631    int32_t trackId = -1;
632
633    ret = AddTrack(muxerDemo, &trackId, handle);
634    ASSERT_EQ(0, trackId);
635
636    ret = Start(muxerDemo, handle);
637    ASSERT_EQ(AV_ERR_OK, ret);
638
639    ret = WriteSampleBuffer(muxerDemo, handle, trackId);
640    ASSERT_EQ(AV_ERR_OK, ret);
641
642    ret = WriteSampleBuffer(muxerDemo, handle, trackId);
643    ASSERT_EQ(AV_ERR_OK, ret);
644
645    Destroy(muxerDemo, handle);
646    delete muxerDemo;
647}
648
649
650/**
651 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_021
652 * @tc.name      : Create -> AddTrack -> Start -> Stop -> WriteSampleBuffer
653 * @tc.desc      : interface depend check
654 */
655HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_021, TestSize.Level2)
656{
657    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
658    OH_AVMuxer* handle = Create(muxerDemo);
659    ASSERT_NE(nullptr, handle);
660
661    OH_AVErrCode ret;
662    int32_t trackId = -1;
663
664    ret = AddTrack(muxerDemo, &trackId, handle);
665    ASSERT_EQ(0, trackId);
666
667    ret = Start(muxerDemo, handle);
668    ASSERT_EQ(AV_ERR_OK, ret);
669
670    ret = Stop(muxerDemo, handle);
671    ASSERT_EQ(AV_ERR_OK, ret);
672
673    ret = WriteSampleBuffer(muxerDemo, handle, trackId);
674    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
675
676    Destroy(muxerDemo, handle);
677    delete muxerDemo;
678}
679
680
681/**
682 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_022
683 * @tc.name      : Create -> Stop
684 * @tc.desc      : interface depend check
685 */
686HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_022, TestSize.Level2)
687{
688    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
689    OH_AVMuxer* handle = Create(muxerDemo);
690    ASSERT_NE(nullptr, handle);
691
692    OH_AVErrCode ret;
693
694    ret = Stop(muxerDemo, handle);
695    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
696
697    Destroy(muxerDemo, handle);
698    delete muxerDemo;
699}
700
701
702/**
703 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_023
704 * @tc.name      : Create -> AddTrack -> Stop
705 * @tc.desc      : interface depend check
706 */
707HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_023, TestSize.Level2)
708{
709    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
710    OH_AVMuxer* handle = Create(muxerDemo);
711    ASSERT_NE(nullptr, handle);
712
713    OH_AVErrCode ret;
714    int32_t trackId = -1;
715
716    ret = AddTrack(muxerDemo, &trackId, handle);
717    ASSERT_EQ(0, trackId);
718
719    ret = Stop(muxerDemo, handle);
720    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
721
722    Destroy(muxerDemo, handle);
723    delete muxerDemo;
724}
725
726
727/**
728 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_024
729 * @tc.name      : Create -> AddTrack -> Start -> Stop
730 * @tc.desc      : interface depend check
731 */
732HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_024, TestSize.Level2)
733{
734    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
735    OH_AVMuxer* handle = Create(muxerDemo);
736    ASSERT_NE(nullptr, handle);
737
738    OH_AVErrCode ret;
739    int32_t trackId = -1;
740
741    ret = AddTrack(muxerDemo, &trackId, handle);
742    ASSERT_EQ(0, trackId);
743
744    ret = Start(muxerDemo, handle);
745    ASSERT_EQ(AV_ERR_OK, ret);
746
747    ret = Stop(muxerDemo, handle);
748    ASSERT_EQ(AV_ERR_OK, ret);
749
750    Destroy(muxerDemo, handle);
751    delete muxerDemo;
752}
753
754
755/**
756 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_025
757 * @tc.name      : Create -> SetRotation -> AddTrack -> Start -> Stop
758 * @tc.desc      : interface depend check
759 */
760HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_025, TestSize.Level2)
761{
762    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
763    OH_AVMuxer* handle = Create(muxerDemo);
764    ASSERT_NE(nullptr, handle);
765
766    OH_AVErrCode ret;
767
768    ret = SetRotation(muxerDemo, handle);
769    ASSERT_EQ(AV_ERR_OK, ret);
770
771    int32_t trackId = -1;
772    ret = AddTrack(muxerDemo, &trackId, handle);
773    ASSERT_EQ(0, trackId);
774
775    ret = Start(muxerDemo, handle);
776    ASSERT_EQ(AV_ERR_OK, ret);
777
778    ret = Stop(muxerDemo, handle);
779    ASSERT_EQ(AV_ERR_OK, ret);
780
781    Destroy(muxerDemo, handle);
782    delete muxerDemo;
783}
784
785
786/**
787 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_026
788 * @tc.name      : Create -> AddTrack -> Start -> WriteSampleBuffer -> Stop -> Stop
789 * @tc.desc      : interface depend check
790 */
791HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_026, TestSize.Level2)
792{
793    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
794    OH_AVMuxer* handle = Create(muxerDemo);
795    ASSERT_NE(nullptr, handle);
796
797    OH_AVErrCode ret;
798
799    int32_t trackId = -1;
800    ret = AddTrack(muxerDemo, &trackId, handle);
801    ASSERT_EQ(0, trackId);
802
803    ret = Start(muxerDemo, handle);
804    ASSERT_EQ(AV_ERR_OK, ret);
805
806    ret = WriteSampleBuffer(muxerDemo, handle, trackId);
807    ASSERT_EQ(AV_ERR_OK, ret);
808
809    ret = Stop(muxerDemo, handle);
810    ASSERT_EQ(AV_ERR_OK, ret);
811
812    ret = Stop(muxerDemo, handle);
813    ASSERT_EQ(AV_ERR_OPERATE_NOT_PERMIT, ret);
814
815    Destroy(muxerDemo, handle);
816    delete muxerDemo;
817}
818
819
820/**
821 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_027
822 * @tc.name      : Create -> Destroy
823 * @tc.desc      : interface depend check
824 */
825HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_027, TestSize.Level2)
826{
827    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
828    OH_AVMuxer* handle = Create(muxerDemo);
829    ASSERT_NE(nullptr, handle);
830
831    OH_AVErrCode ret;
832
833    ret = Destroy(muxerDemo, handle);
834    ASSERT_EQ(AV_ERR_OK, ret);
835
836    delete muxerDemo;
837}
838
839
840/**
841 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_028
842 * @tc.name      : Create -> SetRotation -> Destroy
843 * @tc.desc      : interface depend check
844 */
845HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_028, TestSize.Level2)
846{
847    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
848    OH_AVMuxer* handle = Create(muxerDemo);
849    ASSERT_NE(nullptr, handle);
850
851    OH_AVErrCode ret;
852
853    ret = SetRotation(muxerDemo, handle);
854    ASSERT_EQ(AV_ERR_OK, ret);
855
856    ret = Destroy(muxerDemo, handle);
857    ASSERT_EQ(AV_ERR_OK, ret);
858
859    delete muxerDemo;
860}
861
862
863/**
864 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_029
865 * @tc.name      : Create -> AddTrack -> Destroy
866 * @tc.desc      : interface depend check
867 */
868HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_029, TestSize.Level2)
869{
870    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
871    OH_AVMuxer* handle = Create(muxerDemo);
872    ASSERT_NE(nullptr, handle);
873
874    OH_AVErrCode ret;
875    int32_t trackId = -1;
876
877    ret = AddTrack(muxerDemo, &trackId, handle);
878    ASSERT_EQ(0, trackId);
879
880    ret = Destroy(muxerDemo, handle);
881    ASSERT_EQ(AV_ERR_OK, ret);
882
883    delete muxerDemo;
884}
885
886
887/**
888 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_030
889 * @tc.name      : Create -> AddTrack -> Start -> Destroy
890 * @tc.desc      : interface depend check
891 */
892HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_030, TestSize.Level2)
893{
894    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
895    OH_AVMuxer* handle = Create(muxerDemo);
896    ASSERT_NE(nullptr, handle);
897
898    OH_AVErrCode ret;
899    int32_t trackId = -1;
900
901    ret = AddTrack(muxerDemo, &trackId, handle);
902    ASSERT_EQ(0, trackId);
903
904    ret = Start(muxerDemo, handle);
905    ASSERT_EQ(AV_ERR_OK, ret);
906
907    ret = Destroy(muxerDemo, handle);
908    ASSERT_EQ(AV_ERR_OK, ret);
909
910    delete muxerDemo;
911}
912
913
914/**
915 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_031
916 * @tc.name      : Create -> AddTrack -> Start -> WriteSampleBuffer -> Destroy
917 * @tc.desc      : interface depend check
918 */
919HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_031, TestSize.Level2)
920{
921    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
922    OH_AVMuxer* handle = Create(muxerDemo);
923    ASSERT_NE(nullptr, handle);
924
925    OH_AVErrCode ret;
926    int32_t trackId = -1;
927
928    ret = AddTrack(muxerDemo, &trackId, handle);
929    ASSERT_EQ(0, trackId);
930
931    ret = Start(muxerDemo, handle);
932    ASSERT_EQ(AV_ERR_OK, ret);
933
934    ret = WriteSampleBuffer(muxerDemo, handle, trackId);
935    ASSERT_EQ(AV_ERR_OK, ret);
936
937    ret = Destroy(muxerDemo, handle);
938    ASSERT_EQ(AV_ERR_OK, ret);
939
940    delete muxerDemo;
941}
942
943
944/**
945 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_032
946 * @tc.name      : Create -> AddTrack -> Start -> WriteSampleBuffer -> Stop -> Destroy
947 * @tc.desc      : interface depend check
948 */
949HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_032, TestSize.Level2)
950{
951    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
952    OH_AVMuxer* handle = Create(muxerDemo);
953    ASSERT_NE(nullptr, handle);
954
955    OH_AVErrCode ret;
956    int32_t trackId = -1;
957
958    ret = AddTrack(muxerDemo, &trackId, handle);
959    ASSERT_EQ(0, trackId);
960
961    ret = Start(muxerDemo, handle);
962    ASSERT_EQ(AV_ERR_OK, ret);
963
964    ret = WriteSampleBuffer(muxerDemo, handle, trackId);
965    ASSERT_EQ(AV_ERR_OK, ret);
966
967    ret = Stop(muxerDemo, handle);
968    ASSERT_EQ(AV_ERR_OK, ret);
969
970    ret = Destroy(muxerDemo, handle);
971    ASSERT_EQ(AV_ERR_OK, ret);
972
973    delete muxerDemo;
974}
975
976
977/**
978 * @tc.number    : SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_033
979 * @tc.name      : Create -> SetRotation -> AddTrack -> Start -> WriteSampleBuffer -> Stop -> Destroy
980 * @tc.desc      : interface depend check
981 */
982HWTEST_F(NativeAVMuxerInterfaceDependCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_INTERFACE_DEPEND_CHECK_033, TestSize.Level2)
983{
984    AVMuxerDemo* muxerDemo = new AVMuxerDemo();
985    OH_AVMuxer* handle = Create(muxerDemo);
986    ASSERT_NE(nullptr, handle);
987
988    OH_AVErrCode ret;
989
990    ret = SetRotation(muxerDemo, handle);
991    ASSERT_EQ(AV_ERR_OK, ret);
992
993    int32_t trackId = -1;
994    ret = AddTrack(muxerDemo, &trackId, handle);
995    ASSERT_EQ(0, trackId);
996
997    ret = Start(muxerDemo, handle);
998    ASSERT_EQ(AV_ERR_OK, ret);
999
1000    ret = WriteSampleBuffer(muxerDemo, handle, trackId);
1001    ASSERT_EQ(AV_ERR_OK, ret);
1002
1003    ret = Stop(muxerDemo, handle);
1004    ASSERT_EQ(AV_ERR_OK, ret);
1005
1006    ret = Destroy(muxerDemo, handle);
1007    ASSERT_EQ(AV_ERR_OK, ret);
1008
1009    delete muxerDemo;
1010}