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

Fix #1506, support directly turn FLV timestamp to TS DTS. 3.0.68

This commit is contained in:
winlin 2019-12-05 20:47:23 +08:00
parent 31f341e205
commit b4870a6d6f
7 changed files with 47 additions and 2 deletions

View file

@ -1062,6 +1062,7 @@ SrsHls::SrsHls()
enabled = false;
disposable = false;
last_update_time = 0;
hls_dts_directly = false;
previous_audio_dts = 0;
aac_samples = 0;
@ -1160,6 +1161,11 @@ srs_error_t SrsHls::on_publish()
if ((err = controller->on_publish(req)) != srs_success) {
return srs_error_wrap(err, "hls: on publish");
}
// TODO: FIXME: Support reload.
// TODO: FIXME: Support RAW API.
// If enabled, directly turn FLV timestamp to TS DTS.
hls_dts_directly = _srs_config->get_vhost_hls_dts_directly(req->vhost);
// if enabled, open the muxer.
enabled = true;
@ -1255,6 +1261,12 @@ srs_error_t SrsHls::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* forma
// Recalc the DTS by the samples of AAC.
aac_samples += nb_samples_per_frame;
int64_t dts = 90000 * aac_samples / srs_flv_srates[format->acodec->sound_rate];
// If directly turn FLV timestamp, overwrite the guessed DTS.
// @doc https://github.com/ossrs/srs/issues/1506#issuecomment-562063095
if (hls_dts_directly) {
dts = audio->timestamp * 90;
}
if ((err = controller->write_audio(format->audio, dts)) != srs_success) {
return srs_error_wrap(err, "hls: write audio");