mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
support all sample rate in aac
This commit is contained in:
parent
a2839aacdf
commit
b9195122cf
3 changed files with 13 additions and 31 deletions
|
@ -438,7 +438,8 @@ 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) {
|
||||
return srs_error_new(ERROR_AAC_DATA_INVALID, "invalid aac object");
|
||||
|
@ -446,21 +447,11 @@ srs_error_t SrsRawAacStream::mux_sequence_header(SrsRawAacStreamCodec* codec, st
|
|||
|
||||
SrsAacObjectType audioObjectType = codec->aac_object;
|
||||
char channelConfiguration = codec->channel_configuration;
|
||||
char samplingFrequencyIndex = codec->sampling_frequency_index;
|
||||
|
||||
// override the aac samplerate by user specified.
|
||||
// @see https://github.com/ossrs/srs/issues/212#issuecomment-64146899
|
||||
switch (codec->sound_rate) {
|
||||
case SrsAudioSampleRate11025:
|
||||
samplingFrequencyIndex = 0x0a; break;
|
||||
case SrsAudioSampleRate22050:
|
||||
samplingFrequencyIndex = 0x07; break;
|
||||
case SrsAudioSampleRate44100:
|
||||
samplingFrequencyIndex = 0x04; break;
|
||||
default:
|
||||
break;
|
||||
if (samplingFrequencyIndex >= 16) {
|
||||
samplingFrequencyIndex = 4;//default 44100
|
||||
}
|
||||
|
||||
|
||||
char chs[2];
|
||||
// @see ISO_IEC_14496-3-AAC-2001.pdf
|
||||
// AudioSpecificConfig (), page 33
|
||||
|
|
|
@ -30,6 +30,11 @@
|
|||
|
||||
#include <srs_kernel_codec.hpp>
|
||||
|
||||
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.
|
||||
|
|
|
@ -516,25 +516,11 @@ srs_error_t rtmp_client::on_ts_video(std::shared_ptr<SrsBuffer> avs_ptr, uint64_
|
|||
return err;
|
||||
}
|
||||
|
||||
int rtmp_client::get_sample_rate(char sound_rate) {
|
||||
int rtmp_client::get_sample_rate(char sample_index) {
|
||||
int sample_rate = 44100;
|
||||
|
||||
switch (sound_rate)
|
||||
{
|
||||
case SrsAudioSampleRate44100:
|
||||
sample_rate = 44100;
|
||||
break;
|
||||
case SrsAudioSampleRate22050:
|
||||
sample_rate = 22050;
|
||||
break;
|
||||
case SrsAudioSampleRate11025:
|
||||
sample_rate = 11025;
|
||||
break;
|
||||
case SrsAudioSampleRate5512:
|
||||
sample_rate = 5512;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if ((sample_index >= 0) && (sample_index < 16)) {
|
||||
sample_rate = mpeg4audio_sample_rates[sample_index];
|
||||
}
|
||||
return sample_rate;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue