@@ -5033,6 +5033,8 @@ VOID TEST(KernelMP4Test, CoverMP4CodecSingleFrame)
5033
5033
));
5034
5034
}
5035
5035
5036
+ enc.acodec = SrsAudioCodecIdAAC;
5037
+
5036
5038
HELPER_EXPECT_SUCCESS (enc.flush ());
5037
5039
// mock_print_mp4(string(f.data(), f.filesize()));
5038
5040
}
@@ -5147,6 +5149,8 @@ VOID TEST(KernelMP4Test, CoverMP4MultipleVideos)
5147
5149
));
5148
5150
}
5149
5151
5152
+ enc.acodec = SrsAudioCodecIdAAC;
5153
+
5150
5154
// Flush encoder.
5151
5155
HELPER_EXPECT_SUCCESS (enc.flush ());
5152
5156
// mock_print_mp4(string(f.data(), f.filesize()));
@@ -5245,6 +5249,8 @@ VOID TEST(KernelMP4Test, CoverMP4MultipleCTTs)
5245
5249
));
5246
5250
}
5247
5251
5252
+ enc.acodec = SrsAudioCodecIdAAC;
5253
+
5248
5254
// Flush encoder.
5249
5255
HELPER_EXPECT_SUCCESS (enc.flush ());
5250
5256
// mock_print_mp4(string(f.data(), f.filesize()));
@@ -5357,6 +5363,8 @@ VOID TEST(KernelMP4Test, CoverMP4MultipleAVs)
5357
5363
));
5358
5364
}
5359
5365
5366
+ enc.acodec = SrsAudioCodecIdAAC;
5367
+
5360
5368
// Flush encoder.
5361
5369
HELPER_EXPECT_SUCCESS (enc.flush ());
5362
5370
// mock_print_mp4(string(f.data(), f.filesize()));
@@ -5397,6 +5405,120 @@ VOID TEST(KernelMP4Test, CoverMP4MultipleAVs)
5397
5405
}
5398
5406
}
5399
5407
5408
+ VOID TEST (KernelMP4Test, CoverMP4MultipleAVsWithMp3)
5409
+ {
5410
+ srs_error_t err;
5411
+
5412
+ MockSrsFileWriter f;
5413
+
5414
+ // Encode frames.
5415
+ // V-A V-V
5416
+ if (true ) {
5417
+ SrsMp4Encoder enc; SrsFormat fmt;
5418
+ HELPER_EXPECT_SUCCESS (enc.initialize (&f));
5419
+ HELPER_EXPECT_SUCCESS (fmt.initialize ());
5420
+
5421
+ // Sequence header, V-A
5422
+ if (true ) {
5423
+ uint8_t raw[] = {
5424
+ 0x17 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x64 , 0x00 , 0x20 , 0xff , 0xe1 , 0x00 , 0x19 , 0x67 , 0x64 , 0x00 , 0x20 , 0xac , 0xd9 , 0x40 , 0xc0 , 0x29 , 0xb0 , 0x11 , 0x00 , 0x00 , 0x03 , 0x00 , 0x01 , 0x00 , 0x00 , 0x03 , 0x00 , 0x32 , 0x0f , 0x18 , 0x31 , 0x96 , 0x01 , 0x00 , 0x05 , 0x68 , 0xeb , 0xec , 0xb2 , 0x2c
5425
+ };
5426
+ HELPER_EXPECT_SUCCESS (fmt.on_video (0 , (char *)raw, sizeof (raw)));
5427
+ HELPER_EXPECT_SUCCESS (enc.write_sample (
5428
+ &fmt, SrsMp4HandlerTypeVIDE, fmt.video ->frame_type , fmt.video ->avc_packet_type , 0 , 0 , (uint8_t *)fmt.raw , fmt.nb_raw
5429
+ ));
5430
+ EXPECT_EQ (768 , (int )enc.width ); EXPECT_EQ (320 , (int )enc.height );
5431
+ }
5432
+
5433
+ if (true ) {
5434
+ uint8_t raw[] = {
5435
+ 0xaf , 0x00 , 0x12 , 0x10
5436
+ };
5437
+ HELPER_EXPECT_SUCCESS (fmt.on_audio (0 , (char *)raw, sizeof (raw)));
5438
+ HELPER_EXPECT_SUCCESS (enc.write_sample (
5439
+ &fmt, SrsMp4HandlerTypeSOUN, 0x00 , fmt.audio ->aac_packet_type , 0 , 0 , (uint8_t *)fmt.raw , fmt.nb_raw
5440
+ ));
5441
+ }
5442
+
5443
+ // Frame group #0, V-A-A-V
5444
+ if (true ) {
5445
+ uint8_t raw[] = {
5446
+ 0x17 , 0x01 , 0x00 , 0x00 , 0x50 , 0x00 , 0x00 , 0x00 , 0x7b , 0x41 , 0x9a , 0x21 , 0x6c , 0x42 , 0x1f , 0x00 , 0x00 , 0xf1 , 0x68 , 0x1a , 0x35 , 0x84 , 0xb3 , 0xee , 0xe0 , 0x61 , 0xba , 0x4e , 0xa8 , 0x52 , 0x48 , 0x50 , 0x59 , 0x75 , 0x42 , 0xd9 , 0x96 , 0x4a , 0x51 , 0x38 , 0x2c , 0x63 , 0x5e , 0x41 , 0xc9 , 0x70 , 0x60 , 0x9d , 0x13 , 0x53 , 0xc2 , 0xa8 , 0xf5 , 0x45 , 0x86 , 0xc5 , 0x3e , 0x28 , 0x1a , 0x69 , 0x5f , 0x71 , 0x1e , 0x51 , 0x74 , 0x0e , 0x31 , 0x47 , 0x3c , 0xd3 , 0xd2 , 0x10 , 0x25 , 0x45 , 0xc5 , 0xb7 , 0x31 , 0xec , 0x7f , 0xd8 , 0x02 , 0xae , 0xa4 , 0x77 , 0x6d , 0xcb , 0xc6 , 0x1e , 0x2f , 0xa2 , 0xd1 , 0x12 , 0x08 , 0x34 , 0x52 , 0xea , 0xe8 , 0x0b , 0x4f , 0x81 , 0x21 , 0x4f , 0x71 , 0x3f , 0xf2 , 0xad , 0x02 , 0x58 , 0xdf , 0x9e , 0x31 , 0x86 , 0x9b , 0x1b , 0x41 , 0xbf , 0x2a , 0x09 , 0x00 , 0x43 , 0x5c , 0xa1 , 0x7e , 0x76 , 0x59 , 0xef , 0xa6 , 0xfc , 0x82 , 0xb2 , 0x72 , 0x5a
5447
+ };
5448
+ HELPER_EXPECT_SUCCESS (fmt.on_video (0 , (char *)raw, sizeof (raw)));
5449
+ HELPER_EXPECT_SUCCESS (enc.write_sample (
5450
+ &fmt, SrsMp4HandlerTypeVIDE, fmt.video ->frame_type , fmt.video ->avc_packet_type , 0 , 0 , (uint8_t *)fmt.raw , fmt.nb_raw
5451
+ ));
5452
+ }
5453
+
5454
+ if (true ) {
5455
+ uint8_t raw[] = {
5456
+ 0xaf , 0x01 , 0x21 , 0x11 , 0x45 , 0x00 , 0x14 , 0x50 , 0x01 , 0x46 , 0xf3 , 0xf1 , 0x0a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5e
5457
+ };
5458
+ HELPER_EXPECT_SUCCESS (fmt.on_audio (0 , (char *)raw, sizeof (raw)));
5459
+ HELPER_EXPECT_SUCCESS (enc.write_sample (
5460
+ &fmt, SrsMp4HandlerTypeSOUN, 0x00 , fmt.audio ->aac_packet_type , 0 , 0 , (uint8_t *)fmt.raw , fmt.nb_raw
5461
+ ));
5462
+ }
5463
+
5464
+ if (true ) {
5465
+ uint8_t raw[] = {
5466
+ 0xaf , 0x01 , 0x21 , 0x11 , 0x45 , 0x00 , 0x14 , 0x50 , 0x01 , 0x46 , 0xf3 , 0xf1 , 0x0a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5a , 0x5e
5467
+ };
5468
+ HELPER_EXPECT_SUCCESS (fmt.on_audio (0 , (char *)raw, sizeof (raw)));
5469
+ HELPER_EXPECT_SUCCESS (enc.write_sample (
5470
+ &fmt, SrsMp4HandlerTypeSOUN, 0x00 , fmt.audio ->aac_packet_type , 20 , 20 , (uint8_t *)fmt.raw , fmt.nb_raw
5471
+ ));
5472
+ }
5473
+
5474
+ if (true ) {
5475
+ uint8_t raw[] = {
5476
+ 0x27 , 0x01 , 0x00 , 0x00 , 0x50 , 0x00 , 0x00 , 0x00 , 0x7b , 0x41 , 0x9a , 0x21 , 0x6c , 0x42 , 0x1f , 0x00 , 0x00 , 0xf1 , 0x68 , 0x1a , 0x35 , 0x84 , 0xb3 , 0xee , 0xe0 , 0x61 , 0xba , 0x4e , 0xa8 , 0x52 , 0x48 , 0x50 , 0x59 , 0x75 , 0x42 , 0xd9 , 0x96 , 0x4a , 0x51 , 0x38 , 0x2c , 0x63 , 0x5e , 0x41 , 0xc9 , 0x70 , 0x60 , 0x9d , 0x13 , 0x53 , 0xc2 , 0xa8 , 0xf5 , 0x45 , 0x86 , 0xc5 , 0x3e , 0x28 , 0x1a , 0x69 , 0x5f , 0x71 , 0x1e , 0x51 , 0x74 , 0x0e , 0x31 , 0x47 , 0x3c , 0xd3 , 0xd2 , 0x10 , 0x25 , 0x45 , 0xc5 , 0xb7 , 0x31 , 0xec , 0x7f , 0xd8 , 0x02 , 0xae , 0xa4 , 0x77 , 0x6d , 0xcb , 0xc6 , 0x1e , 0x2f , 0xa2 , 0xd1 , 0x12 , 0x08 , 0x34 , 0x52 , 0xea , 0xe8 , 0x0b , 0x4f , 0x81 , 0x21 , 0x4f , 0x71 , 0x3f , 0xf2 , 0xad , 0x02 , 0x58 , 0xdf , 0x9e , 0x31 , 0x86 , 0x9b , 0x1b , 0x41 , 0xbf , 0x2a , 0x09 , 0x00 , 0x43 , 0x5c , 0xa1 , 0x7e , 0x76 , 0x59 , 0xef , 0xa6 , 0xfc , 0x82 , 0xb2 , 0x72 , 0x5a
5477
+ };
5478
+ HELPER_EXPECT_SUCCESS (fmt.on_video (0 , (char *)raw, sizeof (raw)));
5479
+ HELPER_EXPECT_SUCCESS (enc.write_sample (
5480
+ &fmt, SrsMp4HandlerTypeVIDE, fmt.video ->frame_type , fmt.video ->avc_packet_type , 40 , 40 , (uint8_t *)fmt.raw , fmt.nb_raw
5481
+ ));
5482
+ }
5483
+
5484
+ enc.acodec = SrsAudioCodecIdMP3;
5485
+
5486
+ // Flush encoder.
5487
+ HELPER_EXPECT_SUCCESS (enc.flush ());
5488
+ // mock_print_mp4(string(f.data(), f.filesize()));
5489
+ }
5490
+
5491
+ // Decode frames.
5492
+ if (true ) {
5493
+ MockSrsFileReader fr ((const char *)f.data (), f.filesize ());
5494
+ SrsMp4Decoder dec; HELPER_EXPECT_SUCCESS (dec.initialize (&fr));
5495
+
5496
+ SrsMp4HandlerType ht; uint16_t ft, ct; uint32_t dts, pts, nb_sample; uint8_t * sample = NULL ;
5497
+
5498
+ // Sequence header.
5499
+ HELPER_EXPECT_SUCCESS (dec.read_sample (&ht, &ft, &ct, &dts, &pts, &sample, &nb_sample));
5500
+ EXPECT_EQ (0 , (int )dts); EXPECT_EQ (41 , (int )nb_sample); EXPECT_EQ (SrsMp4HandlerTypeVIDE, ht); EXPECT_EQ (SrsVideoAvcFrameTraitSequenceHeader, ct);
5501
+ srs_freepa (sample);
5502
+
5503
+ // Frames order by dts asc.
5504
+ HELPER_EXPECT_SUCCESS (dec.read_sample (&ht, &ft, &ct, &dts, &pts, &sample, &nb_sample));
5505
+ EXPECT_EQ (0 , (int )dts); EXPECT_EQ (127 , (int )nb_sample); EXPECT_EQ (SrsMp4HandlerTypeVIDE, ht); EXPECT_NE (SrsAudioMp3FrameTrait, ct);
5506
+ srs_freepa (sample);
5507
+
5508
+ HELPER_EXPECT_SUCCESS (dec.read_sample (&ht, &ft, &ct, &dts, &pts, &sample, &nb_sample));
5509
+ EXPECT_EQ (0 , (int )dts); EXPECT_EQ (87 , (int )nb_sample); EXPECT_EQ (SrsMp4HandlerTypeSOUN, ht); EXPECT_NE (SrsVideoAvcFrameTraitSequenceHeader, ct);
5510
+ srs_freepa (sample);
5511
+
5512
+ HELPER_EXPECT_SUCCESS (dec.read_sample (&ht, &ft, &ct, &dts, &pts, &sample, &nb_sample));
5513
+ EXPECT_EQ (20 , (int )dts); EXPECT_EQ (87 , (int )nb_sample); EXPECT_EQ (SrsMp4HandlerTypeSOUN, ht); EXPECT_NE (SrsVideoAvcFrameTraitSequenceHeader, ct);
5514
+ srs_freepa (sample);
5515
+
5516
+ HELPER_EXPECT_SUCCESS (dec.read_sample (&ht, &ft, &ct, &dts, &pts, &sample, &nb_sample));
5517
+ EXPECT_EQ (40 , (int )dts); EXPECT_EQ (40 , (int )pts); EXPECT_EQ (127 , (int )nb_sample); EXPECT_EQ (SrsMp4HandlerTypeVIDE, ht); EXPECT_NE (SrsAudioMp3FrameTrait, ct);
5518
+ srs_freepa (sample);
5519
+ }
5520
+ }
5521
+
5400
5522
VOID TEST (KernelMP4Test, CoverMP4CodecErrorNoFrames)
5401
5523
{
5402
5524
srs_error_t err;
0 commit comments