From 6dd065bcc39ebff950b8e1aa042959236e684aec Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 3 Aug 2014 20:27:57 +0800 Subject: [PATCH] fix #85, fix the segment-dvr sequence header missing. 0.9.187. --- README.md | 1 + trunk/src/app/srs_app_dvr.cpp | 32 ++++++++++++++++++++++++++++++++ trunk/src/app/srs_app_dvr.hpp | 4 ++++ trunk/src/core/srs_core.hpp | 2 +- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ee25ddcf..84fbdce2c 100755 --- a/README.md +++ b/README.md @@ -207,6 +207,7 @@ Supported operating systems and hardware: * 2013-10-17, Created.
## History +* v1.0, 2014-08-03, fix [#85](https://github.com/winlinvip/simple-rtmp-server/issues/85), fix the segment-dvr sequence header missing. 0.9.187. * v1.0, 2014-08-03, fix [#145](https://github.com/winlinvip/simple-rtmp-server/issues/145), refine ffmpeg log, check abitrate for libaacplus. 0.9.186. * v1.0, 2014-08-03, fix [#143](https://github.com/winlinvip/simple-rtmp-server/issues/143), fix retrieve sys stat bug for all linux. 0.9.185. * v1.0, 2014-08-02, fix [#138](https://github.com/winlinvip/simple-rtmp-server/issues/138), fix http hooks bug, regression bug. 0.9.184. diff --git a/trunk/src/app/srs_app_dvr.cpp b/trunk/src/app/srs_app_dvr.cpp index 016e25c8e..75dba5eee 100644 --- a/trunk/src/app/srs_app_dvr.cpp +++ b/trunk/src/app/srs_app_dvr.cpp @@ -399,10 +399,13 @@ void SrsDvrSessionPlan::on_unpublish() SrsDvrSegmentPlan::SrsDvrSegmentPlan() { segment_duration = -1; + sh_video = sh_audio = NULL; } SrsDvrSegmentPlan::~SrsDvrSegmentPlan() { + srs_freep(sh_video); + srs_freep(sh_audio); } int SrsDvrSegmentPlan::initialize(SrsSource* source, SrsRequest* req) @@ -445,6 +448,26 @@ void SrsDvrSegmentPlan::on_unpublish() dvr_enabled = false; } +int SrsDvrSegmentPlan::on_audio(SrsSharedPtrMessage* audio) +{ + if (SrsFlvCodec::audio_is_sequence_header(audio->payload, audio->size)) { + srs_freep(sh_audio); + sh_audio = audio->copy(); + } + + return SrsDvrPlan::on_audio(audio); +} + +int SrsDvrSegmentPlan::on_video(SrsSharedPtrMessage* video) +{ + if (SrsFlvCodec::video_is_sequence_header(video->payload, video->size)) { + srs_freep(sh_video); + sh_video = video->copy(); + } + + return SrsDvrPlan::on_video(video); +} + int SrsDvrSegmentPlan::update_duration(SrsSharedPtrMessage* msg) { int ret = ERROR_SUCCESS; @@ -463,9 +486,18 @@ int SrsDvrSegmentPlan::update_duration(SrsSharedPtrMessage* msg) } on_unpublish(); + // open new flv file if ((ret = open_new_segment()) != ERROR_SUCCESS) { return ret; } + + // update sequence header + if (sh_video && (ret = SrsDvrPlan::on_video(sh_video)) != ERROR_SUCCESS) { + return ret; + } + if (sh_audio && (ret = SrsDvrPlan::on_audio(sh_audio)) != ERROR_SUCCESS) { + return ret; + } } return ret; diff --git a/trunk/src/app/srs_app_dvr.hpp b/trunk/src/app/srs_app_dvr.hpp index baf27bb50..3a48d83de 100644 --- a/trunk/src/app/srs_app_dvr.hpp +++ b/trunk/src/app/srs_app_dvr.hpp @@ -161,6 +161,8 @@ class SrsDvrSegmentPlan : public SrsDvrPlan private: // in config, in ms int segment_duration; + SrsSharedPtrMessage* sh_audio; + SrsSharedPtrMessage* sh_video; public: SrsDvrSegmentPlan(); virtual ~SrsDvrSegmentPlan(); @@ -168,6 +170,8 @@ public: virtual int initialize(SrsSource* source, SrsRequest* req); virtual int on_publish(); virtual void on_unpublish(); + virtual int on_audio(SrsSharedPtrMessage* audio); + virtual int on_video(SrsSharedPtrMessage* video); private: virtual int update_duration(SrsSharedPtrMessage* msg); }; diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index c6bc3574e..9c11bc8c7 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 "0" #define VERSION_MINOR "9" -#define VERSION_REVISION "186" +#define VERSION_REVISION "187" #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION // server info. #define RTMP_SIG_SRS_KEY "SRS"