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

for #512, write audio frame by frame for video+audio hls.

This commit is contained in:
winlin 2015-10-27 16:20:02 +08:00
parent e08beba89e
commit 3683f06e4d
6 changed files with 36 additions and 44 deletions

View file

@ -246,12 +246,6 @@ extern int aac_sample_rates[];
#define SRS_SRS_MAX_CODEC_SAMPLE 128
#define SRS_AAC_SAMPLE_RATE_UNSET 15
// in ms, for HLS aac flush the audio
#define SRS_CONF_DEFAULT_AAC_DELAY 60
// max PES packets size to flush the video.
#define SRS_AUTO_HLS_AUDIO_CACHE_SIZE 128 * 1024
/**
* the FLV/RTMP supported audio sample size.
* Size of each audio sample. This parameter only pertains to

View file

@ -2760,6 +2760,11 @@ void SrsTSMuxer::close()
writer->close();
}
SrsCodecVideo SrsTSMuxer::video_codec()
{
return vcodec;
}
SrsTsCache::SrsTsCache()
{
audio = NULL;
@ -3134,20 +3139,9 @@ int SrsTsEncoder::write_audio(int64_t timestamp, char* data, int size)
return ret;
}
// flush if buffer exceed max size.
if (cache->audio->payload->length() > SRS_AUTO_HLS_AUDIO_CACHE_SIZE) {
return flush_video();
}
// TODO: config it.
// in ms, audio delay to flush the audios.
int64_t audio_delay = SRS_CONF_DEFAULT_AAC_DELAY;
// flush if audio delay exceed
if (dts - cache->audio->start_pts > audio_delay * 90) {
return flush_audio();
}
return ret;
// always flush audio frame by frame.
// @see https://github.com/simple-rtmp-server/srs/issues/512
return flush_audio();
}
int SrsTsEncoder::write_video(int64_t timestamp, char* data, int size)

View file

@ -1586,6 +1586,11 @@ public:
* close the writer.
*/
virtual void close();
public:
/**
* get the video codec of ts muxer.
*/
virtual SrsCodecVideo video_codec();
};
/**