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

for #310, refine code to support he/hev2, use aac object.

This commit is contained in:
winlin 2015-03-08 17:56:49 +08:00
parent 8dbabe3708
commit 885b9af122
10 changed files with 23 additions and 21 deletions

View file

@ -43,7 +43,7 @@ SrsAacEncoder::SrsAacEncoder()
_fs = NULL;
got_sequence_header = false;
tag_stream = new SrsStream();
aac_profile = SrsAacProfileReserved;
aac_object = SrsAacObjectTypeReserved;
}
SrsAacEncoder::~SrsAacEncoder()
@ -131,7 +131,7 @@ int SrsAacEncoder::write_audio(int64_t timestamp, char* data, int size)
aac_sample_rate = ((audioObjectType << 1) & 0x0e) | ((aac_sample_rate >> 7) & 0x01);
audioObjectType = (audioObjectType >> 3) & 0x1f;
aac_profile = srs_codec_aac_rtmp2ts((SrsAacObjectType)audioObjectType);
aac_object = (SrsAacObjectType)audioObjectType;
got_sequence_header = true;
@ -186,6 +186,7 @@ int SrsAacEncoder::write_audio(int64_t timestamp, char* data, int size)
// channel_configuration 3 uimsbf
// original/copy 1 bslbf
// home 1 bslbf
SrsAacProfile aac_profile = srs_codec_aac_rtmp2ts(aac_object);
*pp++ = ((aac_profile << 6) & 0xc0) | ((aac_sample_rate << 2) & 0x3c) | ((aac_channels >> 2) & 0x01);
// 4bits left.
// adts_variable_header(), 1.A.2.2.2 Variable Header of ADTS

View file

@ -45,7 +45,7 @@ class SrsAacEncoder
private:
SrsFileWriter* _fs;
private:
SrsAacProfile aac_profile;
SrsAacObjectType aac_object;
int8_t aac_sample_rate;
int8_t aac_channels;
bool got_sequence_header;

View file

@ -294,7 +294,7 @@ SrsAvcAacCodec::SrsAvcAacCodec()
avc_profile = 0;
avc_level = 0;
aac_profile = SrsAacProfileReserved;
aac_object = SrsAacObjectTypeReserved;
aac_sample_rate = __SRS_AAC_SAMPLE_RATE_UNSET; // sample rate ignored
aac_channels = 0;
avc_extra_size = 0;
@ -493,8 +493,8 @@ int SrsAvcAacCodec::audio_aac_sequence_header_demux(char* data, int size)
aac_sample_rate = samplingFrequencyIndex;
// convert the object type in sequence header to aac profile of ADTS.
aac_profile = srs_codec_aac_rtmp2ts((SrsAacObjectType)profile_ObjectType);
if (aac_profile == SrsAacProfileReserved) {
aac_object = (SrsAacObjectType)profile_ObjectType;
if (aac_object == SrsAacObjectTypeReserved) {
ret = ERROR_HLS_DECODE_ERROR;
srs_error("audio codec decode aac sequence header failed, "
"adts object=%d invalid. ret=%d", profile_ObjectType, ret);

View file

@ -472,7 +472,7 @@ public:
* 1.5.1.1 Audio object type definition, page 23,
* in aac-mp4a-format-ISO_IEC_14496-3+2001.pdf.
*/
SrsAacProfile aac_profile;
SrsAacObjectType aac_object;
/**
* samplingFrequencyIndex
*/

View file

@ -2797,7 +2797,8 @@ int SrsTsCache::do_cache_aac(SrsAvcAacCodec* codec, SrsCodecSample* sample)
int8_t number_of_raw_data_blocks_in_frame; //2bits, 0 indicating 1 raw_data_block()
*/
// profile, 2bits
adts_header[2] = (codec->aac_profile << 6) & 0xc0;
SrsAacProfile aac_profile = srs_codec_aac_rtmp2ts(codec->aac_object);
adts_header[2] = (aac_profile << 6) & 0xc0;
// sampling_frequency_index 4bits
adts_header[2] |= (codec->aac_sample_rate << 2) & 0x3c;
// channel_configuration 3bits