1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1636, muxing sh, use sound_rate if aac sr not set.

This commit is contained in:
winlin 2020-03-13 17:36:22 +08:00
parent 7036f839d2
commit a7c8980a60
2 changed files with 48 additions and 7 deletions

View file

@ -405,6 +405,7 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
codec.aac_object = SrsAacObjectTypeAacMain;
codec.channel_configuration = 1;
codec.sound_rate = SrsAudioSampleRate22050;
codec.sampling_frequency_index = 7;
HELPER_ASSERT_SUCCESS(h.mux_sequence_header(&codec, sh));
EXPECT_EQ(2, sh.length());
EXPECT_EQ(0x0b, (uint8_t)sh.at(0));
@ -417,6 +418,7 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
codec.aac_object = SrsAacObjectTypeAacMain;
codec.channel_configuration = 1;
codec.sound_rate = SrsAudioSampleRate11025;
codec.sampling_frequency_index = 0xa;
HELPER_ASSERT_SUCCESS(h.mux_sequence_header(&codec, sh));
EXPECT_EQ(2, sh.length());
EXPECT_EQ(0x0d, (uint8_t)sh.at(0));
@ -426,7 +428,8 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
// Fail for invalid sampling rate.
if (true) {
SrsRawAacStream h; string sh; SrsRawAacStreamCodec codec;
codec.sampling_frequency_index = 0xf;
codec.aac_object = SrsAacObjectTypeAacMain;
codec.sampling_frequency_index = SrsAacSampleRateUnset;
codec.sound_rate = SrsAudioSampleRateReserved;
HELPER_EXPECT_FAILED(h.mux_sequence_header(&codec, sh));
}
@ -457,6 +460,33 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
codec.aac_object = SrsAacObjectTypeAacMain;
codec.channel_configuration = 1;
codec.sound_rate = SrsAudioSampleRate44100;
codec.sampling_frequency_index = 4;
HELPER_ASSERT_SUCCESS(h.mux_sequence_header(&codec, sh));
EXPECT_EQ(2, sh.length());
EXPECT_EQ(0x0a, (uint8_t)sh.at(0));
EXPECT_EQ(0x08, (uint8_t)sh.at(1));
}
// We ignored the sound_rate.
if (true) {
SrsRawAacStream h; string sh; SrsRawAacStreamCodec codec;
codec.aac_object = SrsAacObjectTypeAacMain;
codec.channel_configuration = 1;
codec.sound_rate = SrsAudioSampleRate22050;
codec.sampling_frequency_index = 4;
HELPER_ASSERT_SUCCESS(h.mux_sequence_header(&codec, sh));
EXPECT_EQ(2, sh.length());
EXPECT_EQ(0x0a, (uint8_t)sh.at(0));
EXPECT_EQ(0x08, (uint8_t)sh.at(1));
}
// Use sound_rate if sampling_frequency_index not set.
if (true) {
SrsRawAacStream h; string sh; SrsRawAacStreamCodec codec;
codec.aac_object = SrsAacObjectTypeAacMain;
codec.channel_configuration = 1;
codec.sound_rate = SrsAudioSampleRate44100;
codec.sampling_frequency_index = SrsAacSampleRateUnset;
HELPER_ASSERT_SUCCESS(h.mux_sequence_header(&codec, sh));
EXPECT_EQ(2, sh.length());
EXPECT_EQ(0x0a, (uint8_t)sh.at(0));