mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
Fix #547, support HLS audio in TS. 3.0.22
This commit is contained in:
parent
6ee85aea83
commit
a98c9e04e3
5 changed files with 30 additions and 4 deletions
|
@ -174,7 +174,7 @@ Please select your language:
|
||||||
- [x] [experiment] Support push POST FLV over HTTP, please read [wiki]([CN][v2_CN_Streamer2], [EN][v2_EN_Streamer2]).
|
- [x] [experiment] Support push POST FLV over HTTP, please read [wiki]([CN][v2_CN_Streamer2], [EN][v2_EN_Streamer2]).
|
||||||
- [x] [experiment] Support multiple processes by [dolphin][srs-dolphin] or [oryx][oryx].
|
- [x] [experiment] Support multiple processes by [dolphin][srs-dolphin] or [oryx][oryx].
|
||||||
- [x] [experiment] Support [mgmt console][console], please read [srs-ngb][srs-ngb].
|
- [x] [experiment] Support [mgmt console][console], please read [srs-ngb][srs-ngb].
|
||||||
- [ ] Enhanced HLS audio-only use aac instead of ts.
|
- [x] Enhanced HLS audio-only use ts, see [#547][bug #547].
|
||||||
- [ ] Enhanced forward with vhost and url variables.
|
- [ ] Enhanced forward with vhost and url variables.
|
||||||
- [ ] Support source or idle stream cleanup.
|
- [ ] Support source or idle stream cleanup.
|
||||||
- [ ] Support origin cluster, please read [#464][bug #464], [RTMP 302][bug #92].
|
- [ ] Support origin cluster, please read [#464][bug #464], [RTMP 302][bug #92].
|
||||||
|
@ -186,6 +186,7 @@ Please select your language:
|
||||||
|
|
||||||
### V3 changes
|
### V3 changes
|
||||||
|
|
||||||
|
* v3.0, 2017-04-16, Fix [#547][bug #547], support HLS audio in TS. 3.0.22
|
||||||
* v3.0, 2017-03-26, Fix [#820][bug #820], extract service for modules. 3.0.21
|
* v3.0, 2017-03-26, Fix [#820][bug #820], extract service for modules. 3.0.21
|
||||||
* v3.0, 2017-03-02, Fix [#786][bug #786], simply don't reuse object. 3.0.20
|
* v3.0, 2017-03-02, Fix [#786][bug #786], simply don't reuse object. 3.0.20
|
||||||
* v3.0, 2017-03-01, For [#110][bug #110], refine thread object. 3.0.19
|
* v3.0, 2017-03-01, For [#110][bug #110], refine thread object. 3.0.19
|
||||||
|
@ -1400,6 +1401,7 @@ Winlin
|
||||||
[bug #738]: https://github.com/ossrs/srs/issues/738
|
[bug #738]: https://github.com/ossrs/srs/issues/738
|
||||||
[bug #786]: https://github.com/ossrs/srs/issues/786
|
[bug #786]: https://github.com/ossrs/srs/issues/786
|
||||||
[bug #820]: https://github.com/ossrs/srs/issues/820
|
[bug #820]: https://github.com/ossrs/srs/issues/820
|
||||||
|
[bug #547]: https://github.com/ossrs/srs/issues/547
|
||||||
[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
|
[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
|
||||||
|
|
||||||
[exo #828]: https://github.com/google/ExoPlayer/pull/828
|
[exo #828]: https://github.com/google/ExoPlayer/pull/828
|
||||||
|
|
|
@ -969,6 +969,9 @@ SrsHls::SrsHls()
|
||||||
disposable = false;
|
disposable = false;
|
||||||
last_update_time = 0;
|
last_update_time = 0;
|
||||||
|
|
||||||
|
previous_audio_dts = 0;
|
||||||
|
aac_samples = 0;
|
||||||
|
|
||||||
jitter = new SrsRtmpJitter();
|
jitter = new SrsRtmpJitter();
|
||||||
controller = new SrsHlsController();
|
controller = new SrsHlsController();
|
||||||
|
|
||||||
|
@ -1115,8 +1118,22 @@ int SrsHls::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the dts calc from rtmp/flv header.
|
// Reset the aac samples counter when DTS jitter.
|
||||||
int64_t dts = audio->timestamp * 90;
|
if (previous_audio_dts > audio->timestamp) {
|
||||||
|
previous_audio_dts = audio->timestamp;
|
||||||
|
aac_samples = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the diff to guess whether the samples is 1024 or 960.
|
||||||
|
int nb_samples_per_frame = 1024;
|
||||||
|
int diff = ::abs((int)(audio->timestamp - previous_audio_dts)) * srs_flv_srates[format->acodec->sound_rate];
|
||||||
|
if (diff > 100 && diff < 950) {
|
||||||
|
nb_samples_per_frame = 960;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recalc the DTS by the samples of AAC.
|
||||||
|
int64_t dts = 90000 * aac_samples / srs_flv_srates[format->acodec->sound_rate];
|
||||||
|
aac_samples += nb_samples_per_frame;
|
||||||
|
|
||||||
if ((ret = controller->write_audio(format->audio, dts)) != ERROR_SUCCESS) {
|
if ((ret = controller->write_audio(format->audio, dts)) != ERROR_SUCCESS) {
|
||||||
srs_error("hls cache write audio failed. ret=%d", ret);
|
srs_error("hls cache write audio failed. ret=%d", ret);
|
||||||
|
|
|
@ -298,6 +298,12 @@ private:
|
||||||
bool enabled;
|
bool enabled;
|
||||||
bool disposable;
|
bool disposable;
|
||||||
int64_t last_update_time;
|
int64_t last_update_time;
|
||||||
|
private:
|
||||||
|
// If the diff=dts-previous_audio_dts is about 23,
|
||||||
|
// that's the AAC samples is 1024, and we use the samples to calc the dts.
|
||||||
|
int64_t previous_audio_dts;
|
||||||
|
// The total aac samples.
|
||||||
|
uint64_t aac_samples;
|
||||||
private:
|
private:
|
||||||
SrsOriginHub* hub;
|
SrsOriginHub* hub;
|
||||||
SrsRtmpJitter* jitter;
|
SrsRtmpJitter* jitter;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR 3
|
#define VERSION_MAJOR 3
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 21
|
#define VERSION_REVISION 22
|
||||||
|
|
||||||
// generated by configure, only macros.
|
// generated by configure, only macros.
|
||||||
#include <srs_auto_headers.hpp>
|
#include <srs_auto_headers.hpp>
|
||||||
|
|
|
@ -183,6 +183,7 @@ enum SrsAudioAacFrameTrait
|
||||||
* 2 = 22 kHz = 22050 Hz
|
* 2 = 22 kHz = 22050 Hz
|
||||||
* 3 = 44 kHz = 44100 Hz
|
* 3 = 44 kHz = 44100 Hz
|
||||||
* However, we can extends this table.
|
* However, we can extends this table.
|
||||||
|
* @remark Use srs_flv_srates to convert it.
|
||||||
*/
|
*/
|
||||||
enum SrsAudioSampleRate
|
enum SrsAudioSampleRate
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue