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

fix ts audio bug, aac adts header and PES_packet_length fixed

This commit is contained in:
winlin 2013-11-25 00:02:01 +08:00
parent 4fca914694
commit 38e66be490
2 changed files with 15 additions and 6 deletions

View file

@ -560,6 +560,9 @@ int SrsTSMuxer::write_audio(u_int32_t time, SrsCodec* codec, SrsCodecSample* sam
return ret;
}
// the frame length is the AAC raw data plus the adts header size.
int32_t frame_length = size + 7;
// AAC-ADTS
// 6.2 Audio Data Transport Stream, ADTS
// in aac-iso-13818-7.pdf, page 26.
@ -593,12 +596,14 @@ int SrsTSMuxer::write_audio(u_int32_t time, SrsCodec* codec, SrsCodecSample* sam
// sampling_frequency_index 4bits
adts_header[2] |= (codec->aac_sample_rate << 2) & 0x3c;
// channel_configuration 3bits
adts_header[2] |= (codec->aac_channels >> 1) & 0x01;
adts_header[3] = (codec->aac_channels << 5) & 0xc0;
adts_header[2] |= (codec->aac_channels >> 2) & 0x01;
adts_header[3] = (codec->aac_channels << 6) & 0xc0;
// frame_length 13bits
adts_header[3] |= (size >> 11) & 0x03;
adts_header[4] = (size >> 3) & 0xff;
adts_header[5] = (size << 5) & 0xcf;
adts_header[3] |= (frame_length >> 11) & 0x03;
adts_header[4] = (frame_length >> 3) & 0xff;
adts_header[5] = ((frame_length << 5) & 0xe0);
// adts_buffer_fullness; //11bits
adts_header[5] |= 0x1f;
// copy to audio buffer
audio_buffer->append(adts_header, sizeof(adts_header));