mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge branch v4.0.269 into 5.0release
1. MP3: Fix bug for TS or HLS with mp3 codec. v4.0.269 (#296) (#3333)
This commit is contained in:
commit
05d7400cd5
9 changed files with 108 additions and 21 deletions
|
@ -3469,11 +3469,23 @@ VOID TEST(KernelCodecTest, AVFrame)
|
|||
EXPECT_TRUE(20 == f.samples[1].size);
|
||||
EXPECT_TRUE(2 == f.nb_samples);
|
||||
}
|
||||
|
||||
|
||||
if (true) {
|
||||
SrsAudioFrame f;
|
||||
EXPECT_TRUE(0 == f.nb_samples);
|
||||
|
||||
HELPER_EXPECT_SUCCESS(f.add_sample((char*)1, 0));
|
||||
EXPECT_TRUE(0 == f.nb_samples);
|
||||
|
||||
HELPER_EXPECT_SUCCESS(f.add_sample(NULL, 1));
|
||||
EXPECT_TRUE(0 == f.nb_samples);
|
||||
}
|
||||
|
||||
if (true) {
|
||||
SrsAudioFrame f;
|
||||
for (int i = 0; i < SrsMaxNbSamples; i++) {
|
||||
HELPER_EXPECT_SUCCESS(f.add_sample((char*)(int64_t)i, i*10));
|
||||
HELPER_EXPECT_SUCCESS(f.add_sample((char*)(int64_t)(i + 1), i*10 + 1));
|
||||
}
|
||||
|
||||
srs_error_t err = f.add_sample((char*)1, 1);
|
||||
|
@ -3580,18 +3592,39 @@ VOID TEST(KernelCodecTest, AudioFormat)
|
|||
HELPER_EXPECT_SUCCESS(f.on_audio(0, (char*)"\x00", 0));
|
||||
HELPER_EXPECT_SUCCESS(f.on_audio(0, (char*)"\x00", 1));
|
||||
}
|
||||
|
||||
|
||||
// For MP3
|
||||
if (true) {
|
||||
SrsFormat f;
|
||||
HELPER_EXPECT_SUCCESS(f.initialize());
|
||||
HELPER_EXPECT_SUCCESS(f.on_audio(0, (char*)"\x20", 1));
|
||||
EXPECT_TRUE(0 == f.nb_raw);
|
||||
EXPECT_TRUE(0 == f.audio->nb_samples);
|
||||
|
||||
HELPER_EXPECT_SUCCESS(f.on_audio(0, (char*)"\x20\x00", 2));
|
||||
EXPECT_TRUE(1 == f.nb_raw);
|
||||
EXPECT_TRUE(0 == f.audio->nb_samples);
|
||||
EXPECT_TRUE(1 == f.audio->nb_samples);
|
||||
|
||||
HELPER_EXPECT_SUCCESS(f.on_audio(0, (char*)"\x20\x00\x00", 3));
|
||||
EXPECT_TRUE(2 == f.nb_raw);
|
||||
EXPECT_TRUE(1 == f.audio->nb_samples);
|
||||
}
|
||||
|
||||
// For AAC
|
||||
if (true) {
|
||||
SrsFormat f;
|
||||
HELPER_EXPECT_SUCCESS(f.initialize());
|
||||
HELPER_EXPECT_FAILED(f.on_audio(0, (char*)"\xa0", 1));
|
||||
|
||||
HELPER_EXPECT_SUCCESS(f.on_audio(0, (char*)"\xaf\x00\x12\x10", 4));
|
||||
HELPER_EXPECT_SUCCESS(f.on_audio(0, (char*)"\xa0\x01", 2));
|
||||
EXPECT_TRUE(0 == f.nb_raw);
|
||||
EXPECT_TRUE(0 == f.audio->nb_samples);
|
||||
|
||||
HELPER_EXPECT_SUCCESS(f.on_audio(0, (char*)"\xa0\x01\x00", 3));
|
||||
EXPECT_TRUE(1 == f.nb_raw);
|
||||
EXPECT_TRUE(1 == f.audio->nb_samples);
|
||||
}
|
||||
|
||||
if (true) {
|
||||
SrsFormat f;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue