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

Merge branch v4.0.269 into 5.0release

1. MP3: Fix bug for TS or HLS with mp3 codec. v4.0.269 (#296) (#3333)
This commit is contained in:
winlin 2022-12-25 12:10:03 +08:00
commit 05d7400cd5
9 changed files with 108 additions and 21 deletions

View file

@ -543,6 +543,9 @@ srs_error_t SrsFrame::initialize(SrsCodecConfig* c)
srs_error_t SrsFrame::add_sample(char* bytes, int size)
{
srs_error_t err = srs_success;
// Ignore empty sample.
if (!bytes || size <= 0) return err;
if (nb_samples >= SrsMaxNbSamples) {
return srs_error_new(ERROR_HLS_DECODE_ERROR, "Frame samples overflow");
@ -1472,20 +1475,13 @@ srs_error_t SrsFormat::audio_mp3_demux(SrsBuffer* stream, int64_t timestamp)
// we always decode aac then mp3.
srs_assert(acodec->id == SrsAudioCodecIdMP3);
// Update the RAW MP3 data.
// Update the RAW MP3 data. Note the start is 12 bits syncword 0xFFF, so we should not skip any bytes, for detail
// please see ISO_IEC_11172-3-MP3-1993.pdf page 20 and 26.
raw = stream->data() + stream->pos();
nb_raw = stream->size() - stream->pos();
stream->skip(1);
if (stream->empty()) {
return err;
}
char* data = stream->data() + stream->pos();
int size = stream->size() - stream->pos();
// mp3 payload.
if ((err = audio->add_sample(data, size)) != srs_success) {
if ((err = audio->add_sample(raw, nb_raw)) != srs_success) {
return srs_error_wrap(err, "add audio frame");
}