From cab88dfe701cd1e2d6a6211a350df28e8e28f77a Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 6 Dec 2013 14:02:10 +0800 Subject: [PATCH] hls support multiple publish/unpublish. disable hls when not support --- README.md | 20 ++++++++++---------- trunk/src/core/srs_core_hls.cpp | 10 ++++++++++ trunk/src/core/srs_core_source.cpp | 18 ++++++++++++++---- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index cb599875b..c2af1518b 100755 --- a/README.md +++ b/README.md @@ -126,16 +126,16 @@ Supported operating systems and hardware: 16. support live stream transcoding by ffmpeg.
17. support live stream transcoding by ffmpeg.
18. support ffmpeg filters(logo/overlay/crop), x264 params.
-19. [plan] support network based cli and json result.
-20. [plan] support http callback api hooks(for authentication).
-21. [plan] support bandwidth test api and flash client.
-22. [plan] support adobe flash refer/token/swf verification.
-23. [plan] support adobe amf3 codec.
-24. [plan] support dvr(record live to vod file)
-25. [plan] support FMS edge protocol
-26. [plan] support encryption: RTMPE/RTMPS, HLS DRM
-27. [plan] support RTMPT, http to tranverse firewalls
-28. [plan] support audio transcode only, speex to aac
+19. [dev] support audio transcode only, speex/mp3 to aac
+20. [plan] support network based cli and json result.
+21. [plan] support http callback api hooks(for authentication).
+22. [plan] support bandwidth test api and flash client.
+23. [plan] support adobe flash refer/token/swf verification.
+24. [plan] support adobe amf3 codec.
+25. [plan] support dvr(record live to vod file)
+26. [plan] support FMS edge protocol
+27. [plan] support encryption: RTMPE/RTMPS, HLS DRM
+28. [plan] support RTMPT, http to tranverse firewalls
29. [plan] support file source, transcoding file to live stream
### Performance diff --git a/trunk/src/core/srs_core_hls.cpp b/trunk/src/core/srs_core_hls.cpp index 054468df4..37848f6e3 100644 --- a/trunk/src/core/srs_core_hls.cpp +++ b/trunk/src/core/srs_core_hls.cpp @@ -1138,6 +1138,11 @@ SrsHls::~SrsHls() int SrsHls::on_publish(SrsRequest* req) { int ret = ERROR_SUCCESS; + + // support multiple publish. + if (hls_enabled) { + return ret; + } std::string vhost = req->vhost; std::string stream = req->stream; @@ -1194,6 +1199,11 @@ void SrsHls::on_unpublish() { int ret = ERROR_SUCCESS; + // support multiple unpublish. + if (!hls_enabled) { + return; + } + // close muxer when unpublish. ret = ts_cache->flush_audio(muxer); ret += muxer->segment_close(); diff --git a/trunk/src/core/srs_core_source.cpp b/trunk/src/core/srs_core_source.cpp index 27d4f7507..3277ebb85 100644 --- a/trunk/src/core/srs_core_source.cpp +++ b/trunk/src/core/srs_core_source.cpp @@ -508,8 +508,13 @@ int SrsSource::on_audio(SrsCommonMessage* audio) #ifdef SRS_HLS if ((ret = hls->on_audio(msg->copy())) != ERROR_SUCCESS) { - srs_error("hls process audio message failed. ret=%d", ret); - return ret; + srs_warn("hls process audio message failed, ignore and disable hls. ret=%d", ret); + + // unpublish, ignore ret. + hls->on_unpublish(); + + // ignore. + ret = ERROR_SUCCESS; } #endif @@ -570,8 +575,13 @@ int SrsSource::on_video(SrsCommonMessage* video) #ifdef SRS_HLS if ((ret = hls->on_video(msg->copy())) != ERROR_SUCCESS) { - srs_error("hls process video message failed. ret=%d", ret); - return ret; + srs_warn("hls process video message failed, ignore and disable hls. ret=%d", ret); + + // unpublish, ignore ret. + hls->on_unpublish(); + + // ignore. + ret = ERROR_SUCCESS; } #endif