mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
parent
23b7939574
commit
95defe6dad
8 changed files with 100 additions and 77 deletions
|
@ -670,7 +670,8 @@ srs_error_t SrsFormat::on_audio(int64_t timestamp, char* data, int size)
|
|||
if (codec != SrsAudioCodecIdMP3 && codec != SrsAudioCodecIdAAC) {
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
bool fresh = !acodec;
|
||||
if (!acodec) {
|
||||
acodec = new SrsAudioCodecConfig();
|
||||
}
|
||||
|
@ -686,7 +687,7 @@ srs_error_t SrsFormat::on_audio(int64_t timestamp, char* data, int size)
|
|||
buffer->skip(-1 * buffer->pos());
|
||||
|
||||
if (codec == SrsAudioCodecIdMP3) {
|
||||
return audio_mp3_demux(buffer, timestamp);
|
||||
return audio_mp3_demux(buffer, timestamp, fresh);
|
||||
}
|
||||
|
||||
return audio_aac_demux(buffer, timestamp);
|
||||
|
@ -755,6 +756,12 @@ bool SrsFormat::is_aac_sequence_header()
|
|||
&& audio && audio->aac_packet_type == SrsAudioAacFrameTraitSequenceHeader;
|
||||
}
|
||||
|
||||
bool SrsFormat::is_mp3_sequence_header()
|
||||
{
|
||||
return acodec && acodec->id == SrsAudioCodecIdMP3
|
||||
&& audio && audio->aac_packet_type == SrsAudioMp3FrameTraitSequenceHeader;
|
||||
}
|
||||
|
||||
bool SrsFormat::is_avc_sequence_header()
|
||||
{
|
||||
bool h264 = (vcodec && vcodec->id == SrsVideoCodecIdAVC);
|
||||
|
@ -1449,13 +1456,13 @@ srs_error_t SrsFormat::audio_aac_demux(SrsBuffer* stream, int64_t timestamp)
|
|||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsFormat::audio_mp3_demux(SrsBuffer* stream, int64_t timestamp)
|
||||
srs_error_t SrsFormat::audio_mp3_demux(SrsBuffer* stream, int64_t timestamp, bool fresh)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
audio->cts = 0;
|
||||
audio->dts = timestamp;
|
||||
audio->aac_packet_type = SrsAudioMp3FrameTrait;
|
||||
audio->aac_packet_type = fresh ? SrsAudioMp3FrameTraitSequenceHeader : SrsAudioMp3FrameTraitRawData;
|
||||
|
||||
// @see: E.4.2 Audio Tags, video_file_format_spec_v10_1.pdf, page 76
|
||||
int8_t sound_format = stream->read_1bytes();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue