mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
PICK 95defe6dad
This commit is contained in:
parent
2e1d99002f
commit
35c89cc436
8 changed files with 100 additions and 77 deletions
|
@ -737,7 +737,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();
|
||||
}
|
||||
|
@ -753,7 +754,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);
|
||||
|
@ -824,6 +825,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);
|
||||
|
@ -2040,13 +2047,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();
|
||||
|
|
|
@ -161,7 +161,8 @@ enum SrsAudioAacFrameTrait
|
|||
// set to the max value to reserved, for array map.
|
||||
SrsAudioAacFrameTraitReserved = 0xff,
|
||||
SrsAudioAacFrameTraitForbidden = 0xff,
|
||||
|
||||
|
||||
// For AAC, we detect the sequence header by content.
|
||||
SrsAudioAacFrameTraitSequenceHeader = 0,
|
||||
SrsAudioAacFrameTraitRawData = 1,
|
||||
|
||||
|
@ -172,8 +173,10 @@ enum SrsAudioAacFrameTrait
|
|||
|
||||
// 16/32 reserved for g711a/g711u
|
||||
|
||||
// For MP3
|
||||
SrsAudioMp3FrameTrait = 64,
|
||||
// For MP3 we assume the first packet is sequence header, while it actually is not the same thing, because we do
|
||||
// this to simplify the workflow, to make sure we can detect the audio codec from the sequence headers.
|
||||
SrsAudioMp3FrameTraitSequenceHeader = 63,
|
||||
SrsAudioMp3FrameTraitRawData = 64,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -972,6 +975,7 @@ public:
|
|||
virtual srs_error_t on_aac_sequence_header(char* data, int size);
|
||||
public:
|
||||
virtual bool is_aac_sequence_header();
|
||||
virtual bool is_mp3_sequence_header();
|
||||
virtual bool is_avc_sequence_header();
|
||||
private:
|
||||
// Demux the video packet in H.264 codec.
|
||||
|
@ -1006,7 +1010,7 @@ private:
|
|||
// Demux the asc from sequence header.
|
||||
// Demux the sampels from RAW data.
|
||||
virtual srs_error_t audio_aac_demux(SrsBuffer* stream, int64_t timestamp);
|
||||
virtual srs_error_t audio_mp3_demux(SrsBuffer* stream, int64_t timestamp);
|
||||
virtual srs_error_t audio_mp3_demux(SrsBuffer* stream, int64_t timestamp, bool fresh);
|
||||
public:
|
||||
// Directly demux the sequence header, without RTMP packet header.
|
||||
virtual srs_error_t audio_aac_sequence_header_demux(char* data, int size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue