Skip to content

Commit d1979c7

Browse files
committed
for #512, partical hotfix the hls pure audio. 2.0.196
1 parent 3683f06 commit d1979c7

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ Remark:
336336

337337
## History
338338

339+
* v2.0, 2015-10-27, for [#512][bug #512] partical hotfix the hls pure audio. 2.0.196
339340
* <strong>v2.0, 2015-10-08, [2.0 alpha2(2.0.195)][r2.0a2] released. 89358 lines.</strong>
340341
* v2.0, 2015-10-04, for [#448][bug #448] fix the bug of response of http hooks. 2.0.195
341342
* v2.0, 2015-10-01, for [#497][bug #497] response error when client not found to kickoff. 2.0.194

trunk/src/app/srs_app_hls.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
578578
current->full_path.c_str(), tmp_file.c_str());
579579

580580
// set the segment muxer audio codec.
581+
// TODO: FIXME: refine code, use event instead.
581582
if (acodec != SrsCodecAudioReserved1) {
582583
current->muxer->update_acodec(acodec);
583584
}
@@ -1044,7 +1045,7 @@ int SrsHlsCache::on_sequence_header(SrsHlsMuxer* muxer)
10441045
// when the sequence header changed, the stream is not republish.
10451046
return muxer->on_sequence_header();
10461047
}
1047-
1048+
10481049
int SrsHlsCache::write_audio(SrsAvcAacCodec* codec, SrsHlsMuxer* muxer, int64_t pts, SrsCodecSample* sample)
10491050
{
10501051
int ret = ERROR_SUCCESS;
@@ -1069,6 +1070,13 @@ int SrsHlsCache::write_audio(SrsAvcAacCodec* codec, SrsHlsMuxer* muxer, int64_t
10691070
}
10701071
}
10711072

1073+
// for pure audio, aggregate some frame to one.
1074+
if (muxer->pure_audio() && cache->audio) {
1075+
if (pts - cache->audio->start_pts < SRS_CONSTS_HLS_PURE_AUDIO_AGGREGATE) {
1076+
return ret;
1077+
}
1078+
}
1079+
10721080
// directly write the audio frame by frame to ts,
10731081
// it's ok for the hls overload, or maybe cause the audio corrupt,
10741082
// which introduced by aggregate the audios to a big one.

trunk/src/core/srs_core.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3131
// current release version
3232
#define VERSION_MAJOR 2
3333
#define VERSION_MINOR 0
34-
#define VERSION_REVISION 195
34+
#define VERSION_REVISION 196
3535

3636
// server info.
3737
#define RTMP_SIG_SRS_KEY "SRS"

trunk/src/kernel/srs_kernel_ts.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,11 @@ int SrsTsContext::encode_pes(SrsFileWriter* writer, SrsTsMessage* msg, int16_t p
459459
while (p < end) {
460460
SrsTsPacket* pkt = NULL;
461461
if (p == start) {
462-
// for pure audio stream, always write pcr.
462+
// write pcr according to message.
463463
bool write_pcr = msg->write_pcr;
464+
465+
// for pure audio, always write pcr.
466+
// TODO: FIXME: maybe only need to write at begin and end of ts.
464467
if (pure_audio && msg->is_audio()) {
465468
write_pcr = true;
466469
}
@@ -2785,11 +2788,12 @@ int SrsTsCache::cache_audio(SrsAvcAacCodec* codec, int64_t dts, SrsCodecSample*
27852788
if (!audio) {
27862789
audio = new SrsTsMessage();
27872790
audio->write_pcr = false;
2788-
audio->start_pts = dts;
2791+
audio->dts = audio->pts = audio->start_pts = dts;
27892792
}
27902793

2791-
audio->dts = dts;
2792-
audio->pts = audio->dts;
2794+
// TODO: FIXME: refine code.
2795+
//audio->dts = dts;
2796+
//audio->pts = audio->dts;
27932797
audio->sid = SrsTsPESStreamIdAudioCommon;
27942798

27952799
// must be aac or mp3
@@ -3139,6 +3143,8 @@ int SrsTsEncoder::write_audio(int64_t timestamp, char* data, int size)
31393143
return ret;
31403144
}
31413145

3146+
// TODO: FIXME: for pure audio, aggregate some frame to one.
3147+
31423148
// always flush audio frame by frame.
31433149
// @see https://github.com/simple-rtmp-server/srs/issues/512
31443150
return flush_audio();

trunk/src/kernel/srs_kernel_ts.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ class SrsTsContext;
5454
// Transport Stream packets are 188 bytes in length.
5555
#define SRS_TS_PACKET_SIZE 188
5656

57+
// the aggregate pure audio for hls, in ts tbn(ms * 90).
58+
#define SRS_CONSTS_HLS_PURE_AUDIO_AGGREGATE 720 * 90
59+
5760
/**
5861
* the pid of ts packet,
5962
* Table 2-3 - PID table, hls-mpeg-ts-iso13818-1.pdf, page 37
@@ -359,6 +362,7 @@ class SrsTsContext
359362
/**
360363
* whether the hls stream is pure audio stream.
361364
*/
365+
// TODO: FIXME: merge with muxer codec detect.
362366
virtual bool is_pure_audio();
363367
/**
364368
* when PMT table parsed, we know some info about stream.

0 commit comments

Comments
 (0)