From 4f5cc9c403aedd836fb1ef40220afff9bce03841 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 23 Jan 2015 15:14:29 +0800 Subject: [PATCH 1/2] for #151, use absolutely overflow to make jwplayer happy. 1.0.23 --- README.md | 1 + trunk/src/app/srs_app_hls.cpp | 11 +++++++++-- trunk/src/app/srs_app_hls.hpp | 10 ++++++++-- trunk/src/core/srs_core.hpp | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 11be6d538..dc64a5014 100755 --- a/README.md +++ b/README.md @@ -385,6 +385,7 @@ Supported operating systems and hardware: ## History +* v1.0, 2015-01-23, hotfix [#151](https://github.com/winlinvip/simple-rtmp-server/issues/151), use absolutely overflow to make jwplayer happy. 1.0.23 * v1.0, 2015-01-17, hotfix [#290](https://github.com/winlinvip/simple-rtmp-server/issues/290), use iformat only for rtmp input. 1.0.22 * v1.0, 2015-01-15, [1.0r1 release(1.0.21)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0r1) released. 59472 lines. * v1.0, 2015-01-08, hotfix [#281](https://github.com/winlinvip/simple-rtmp-server/issues/281), fix hls bug ignore type-9 send aud. 1.0.20 diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index af294ddb2..7fe9a1c15 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -655,10 +655,15 @@ int SrsHlsMuxer::on_sequence_header() bool SrsHlsMuxer::is_segment_overflow() { srs_assert(current); - return current->duration >= hls_fragment; } +bool SrsHlsMuxer::is_segment_absolutely_overflow() +{ + srs_assert(current); + return current->duration >= 2 * hls_fragment; +} + int SrsHlsMuxer::flush_audio(SrsMpegtsFrame* af, SrsBuffer* ab) { int ret = ERROR_SUCCESS; @@ -1090,7 +1095,9 @@ int SrsHlsCache::write_audio(SrsAvcAacCodec* codec, SrsHlsMuxer* muxer, int64_t // pure audio again for audio disabled. // so we reap event when the audio incoming when segment overflow. // @see https://github.com/winlinvip/simple-rtmp-server/issues/151 - if (muxer->is_segment_overflow()) { + // we use absolutely overflow of segment to make jwplayer/ffplay happy + // @see https://github.com/winlinvip/simple-rtmp-server/issues/151#issuecomment-71155184 + if (muxer->is_segment_absolutely_overflow()) { if ((ret = reap_segment("audio", muxer, af->pts)) != ERROR_SUCCESS) { return ret; } diff --git a/trunk/src/app/srs_app_hls.hpp b/trunk/src/app/srs_app_hls.hpp index d31820367..fff25c90b 100644 --- a/trunk/src/app/srs_app_hls.hpp +++ b/trunk/src/app/srs_app_hls.hpp @@ -192,10 +192,16 @@ public: virtual int segment_open(int64_t segment_start_dts); virtual int on_sequence_header(); /** - * whether video overflow, - * that is whether the current segment duration >= the segment in config + * whether segment overflow, + * that is whether the current segment duration>=(the segment in config) */ virtual bool is_segment_overflow(); + /** + * whether segment absolutely overflow, for pure audio to reap segment, + * that is whether the current segment duration>=2*(the segment in config) + * @see https://github.com/winlinvip/simple-rtmp-server/issues/151#issuecomment-71155184 + */ + virtual bool is_segment_absolutely_overflow(); virtual int flush_audio(SrsMpegtsFrame* af, SrsBuffer* ab); virtual int flush_video(SrsMpegtsFrame* af, SrsBuffer* ab, SrsMpegtsFrame* vf, SrsBuffer* vb); /** diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index a6797e1a9..d3745e539 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 1 #define VERSION_MINOR 0 -#define VERSION_REVISION 22 +#define VERSION_REVISION 23 // server info. #define RTMP_SIG_SRS_KEY "SRS" #define RTMP_SIG_SRS_ROLE "origin/edge server" From 1835957a2b09b4dc7f393649f7e7b295c90e5b64 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 25 Jan 2015 13:04:12 +0800 Subject: [PATCH 2/2] for #151, refine pcr=dts-800ms and use dts/pts directly. 1.0.24 --- README.md | 1 + trunk/src/app/srs_app_hls.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dc64a5014..b38ca768b 100755 --- a/README.md +++ b/README.md @@ -385,6 +385,7 @@ Supported operating systems and hardware: ## History +* v1.0, 2015-01-25, hotfix [#151](https://github.com/winlinvip/simple-rtmp-server/issues/151), refine pcr=dts-800ms and use dts/pts directly. 1.0.24 * v1.0, 2015-01-23, hotfix [#151](https://github.com/winlinvip/simple-rtmp-server/issues/151), use absolutely overflow to make jwplayer happy. 1.0.23 * v1.0, 2015-01-17, hotfix [#290](https://github.com/winlinvip/simple-rtmp-server/issues/290), use iformat only for rtmp input. 1.0.22 * v1.0, 2015-01-15, [1.0r1 release(1.0.21)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0r1) released. 59472 lines. diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index 7fe9a1c15..8fcaaf3f8 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -78,7 +78,9 @@ using namespace std; // @see: NGX_RTMP_HLS_DELAY, // 63000: 700ms, ts_tbn=90000 -#define SRS_AUTO_HLS_DELAY 63000 +// 72000: 800ms, ts_tbn=90000 +// @see https://github.com/winlinvip/simple-rtmp-server/issues/151#issuecomment-71352511 +#define SRS_AUTO_HLS_DELAY 72000 // the mpegts header specifed the video/audio pid. #define TS_VIDEO_PID 256 @@ -237,6 +239,7 @@ public: p[-1] |= 0x20; // Both Adaption and Payload *p++ = 7; // size *p++ = 0x50; // random access + PCR + // about the pcr, read https://github.com/winlinvip/simple-rtmp-server/issues/151#issuecomment-71352511 p = write_pcr(p, frame->dts - SRS_AUTO_HLS_DELAY); } @@ -293,11 +296,11 @@ public: *p++ = header_size; // pts; // 33bits - p = write_pts(p, flags >> 6, frame->pts + SRS_AUTO_HLS_DELAY); + p = write_pts(p, flags >> 6, frame->pts); // dts; // 33bits if (frame->dts != frame->pts) { - p = write_pts(p, 1, frame->dts + SRS_AUTO_HLS_DELAY); + p = write_pts(p, 1, frame->dts); } }