diff --git a/README.md b/README.md index 21a10b52f..761e87dac 100755 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ For previous versions, please read: ## V4 changes +* v4.0, 2020-03-13, For [#1636][bug #1636], fix bug for mux AAC to ADTS, never overwrite by RTMP sampling rate. 4.0.13 * v4.0, 2020-03-07, For [#1612][bug #1612], fix crash bug for RTSP. 4.0.12 * v4.0, 2020-03-07, For [#1631][bug #1631], support sei_filter for SRT. 4.0.11 * v4.0, 2020-03-01, For [#1621][bug #1621], support mix_correct for aggregate aac for SRT. 4.0.10 diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 98f2899e1..dbb90abd4 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION4_HPP #define SRS_CORE_VERSION4_HPP -#define SRS_VERSION4_REVISION 12 +#define SRS_VERSION4_REVISION 13 #endif diff --git a/trunk/src/kernel/srs_kernel_codec.hpp b/trunk/src/kernel/srs_kernel_codec.hpp index 2f8d436b6..a8d674c2b 100644 --- a/trunk/src/kernel/srs_kernel_codec.hpp +++ b/trunk/src/kernel/srs_kernel_codec.hpp @@ -304,6 +304,9 @@ extern int srs_flv_srates[]; */ extern int srs_aac_srates[]; +// The number of aac samplerates, size for srs_aac_srates. +#define SrsAAcSampleRateNumbers 16 + // The impossible aac sample rate index. #define SrsAacSampleRateUnset 15 diff --git a/trunk/src/protocol/srs_raw_avc.cpp b/trunk/src/protocol/srs_raw_avc.cpp index da0fd1835..f05af8221 100644 --- a/trunk/src/protocol/srs_raw_avc.cpp +++ b/trunk/src/protocol/srs_raw_avc.cpp @@ -438,7 +438,6 @@ srs_error_t SrsRawAacStream::adts_demux(SrsBuffer* stream, char** pframe, int* p srs_error_t SrsRawAacStream::mux_sequence_header(SrsRawAacStreamCodec* codec, string& sh) { srs_error_t err = srs_success; - char samplingFrequencyIndex = codec->sampling_frequency_index; // only support aac profile 1-4. if (codec->aac_object == SrsAacObjectTypeReserved) { @@ -447,9 +446,10 @@ srs_error_t SrsRawAacStream::mux_sequence_header(SrsRawAacStreamCodec* codec, st SrsAacObjectType audioObjectType = codec->aac_object; char channelConfiguration = codec->channel_configuration; - - if (samplingFrequencyIndex >= 16) { - samplingFrequencyIndex = 4;//default 44100 + + char samplingFrequencyIndex = codec->sampling_frequency_index; + if (samplingFrequencyIndex >= SrsAAcSampleRateNumbers) { + samplingFrequencyIndex = 4; // Default to 44100 } char chs[2]; diff --git a/trunk/src/protocol/srs_raw_avc.hpp b/trunk/src/protocol/srs_raw_avc.hpp index fc6b00f32..de81bf2ad 100644 --- a/trunk/src/protocol/srs_raw_avc.hpp +++ b/trunk/src/protocol/srs_raw_avc.hpp @@ -30,11 +30,6 @@ #include -static const int mpeg4audio_sample_rates[16] = { - 96000, 88200, 64000, 48000, 44100, 32000, - 24000, 22050, 16000, 12000, 11025, 8000, 7350 -}; - class SrsBuffer; // The raw h.264 stream, in annexb. diff --git a/trunk/src/srt/srt_to_rtmp.cpp b/trunk/src/srt/srt_to_rtmp.cpp index 6cc52fde6..c01477fb9 100644 --- a/trunk/src/srt/srt_to_rtmp.cpp +++ b/trunk/src/srt/srt_to_rtmp.cpp @@ -520,9 +520,10 @@ srs_error_t rtmp_client::on_ts_video(std::shared_ptr avs_ptr, uint64_ int rtmp_client::get_sample_rate(char sample_index) { int sample_rate = 44100; - if ((sample_index >= 0) && (sample_index < 16)) { - sample_rate = mpeg4audio_sample_rates[sample_index]; + if ((sample_index >= 0) && (sample_index < SrsAAcSampleRateNumbers)) { + sample_rate = srs_aac_srates[(uint8_t)sample_index]; } + return sample_rate; }