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