winlin

fix #85, fix the segment-dvr sequence header missing. 0.9.187.

@@ -207,6 +207,7 @@ Supported operating systems and hardware: @@ -207,6 +207,7 @@ Supported operating systems and hardware:
207 * 2013-10-17, Created.<br/> 207 * 2013-10-17, Created.<br/>
208 208
209 ## History 209 ## History
  210 +* 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.
210 * 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. 211 * 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.
211 * 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. 212 * 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.
212 * 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. 213 * 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.
@@ -399,10 +399,13 @@ void SrsDvrSessionPlan::on_unpublish() @@ -399,10 +399,13 @@ void SrsDvrSessionPlan::on_unpublish()
399 SrsDvrSegmentPlan::SrsDvrSegmentPlan() 399 SrsDvrSegmentPlan::SrsDvrSegmentPlan()
400 { 400 {
401 segment_duration = -1; 401 segment_duration = -1;
  402 + sh_video = sh_audio = NULL;
402 } 403 }
403 404
404 SrsDvrSegmentPlan::~SrsDvrSegmentPlan() 405 SrsDvrSegmentPlan::~SrsDvrSegmentPlan()
405 { 406 {
  407 + srs_freep(sh_video);
  408 + srs_freep(sh_audio);
406 } 409 }
407 410
408 int SrsDvrSegmentPlan::initialize(SrsSource* source, SrsRequest* req) 411 int SrsDvrSegmentPlan::initialize(SrsSource* source, SrsRequest* req)
@@ -445,6 +448,26 @@ void SrsDvrSegmentPlan::on_unpublish() @@ -445,6 +448,26 @@ void SrsDvrSegmentPlan::on_unpublish()
445 dvr_enabled = false; 448 dvr_enabled = false;
446 } 449 }
447 450
  451 +int SrsDvrSegmentPlan::on_audio(SrsSharedPtrMessage* audio)
  452 +{
  453 + if (SrsFlvCodec::audio_is_sequence_header(audio->payload, audio->size)) {
  454 + srs_freep(sh_audio);
  455 + sh_audio = audio->copy();
  456 + }
  457 +
  458 + return SrsDvrPlan::on_audio(audio);
  459 +}
  460 +
  461 +int SrsDvrSegmentPlan::on_video(SrsSharedPtrMessage* video)
  462 +{
  463 + if (SrsFlvCodec::video_is_sequence_header(video->payload, video->size)) {
  464 + srs_freep(sh_video);
  465 + sh_video = video->copy();
  466 + }
  467 +
  468 + return SrsDvrPlan::on_video(video);
  469 +}
  470 +
448 int SrsDvrSegmentPlan::update_duration(SrsSharedPtrMessage* msg) 471 int SrsDvrSegmentPlan::update_duration(SrsSharedPtrMessage* msg)
449 { 472 {
450 int ret = ERROR_SUCCESS; 473 int ret = ERROR_SUCCESS;
@@ -463,9 +486,18 @@ int SrsDvrSegmentPlan::update_duration(SrsSharedPtrMessage* msg) @@ -463,9 +486,18 @@ int SrsDvrSegmentPlan::update_duration(SrsSharedPtrMessage* msg)
463 } 486 }
464 on_unpublish(); 487 on_unpublish();
465 488
  489 + // open new flv file
466 if ((ret = open_new_segment()) != ERROR_SUCCESS) { 490 if ((ret = open_new_segment()) != ERROR_SUCCESS) {
467 return ret; 491 return ret;
468 } 492 }
  493 +
  494 + // update sequence header
  495 + if (sh_video && (ret = SrsDvrPlan::on_video(sh_video)) != ERROR_SUCCESS) {
  496 + return ret;
  497 + }
  498 + if (sh_audio && (ret = SrsDvrPlan::on_audio(sh_audio)) != ERROR_SUCCESS) {
  499 + return ret;
  500 + }
469 } 501 }
470 502
471 return ret; 503 return ret;
@@ -161,6 +161,8 @@ class SrsDvrSegmentPlan : public SrsDvrPlan @@ -161,6 +161,8 @@ class SrsDvrSegmentPlan : public SrsDvrPlan
161 private: 161 private:
162 // in config, in ms 162 // in config, in ms
163 int segment_duration; 163 int segment_duration;
  164 + SrsSharedPtrMessage* sh_audio;
  165 + SrsSharedPtrMessage* sh_video;
164 public: 166 public:
165 SrsDvrSegmentPlan(); 167 SrsDvrSegmentPlan();
166 virtual ~SrsDvrSegmentPlan(); 168 virtual ~SrsDvrSegmentPlan();
@@ -168,6 +170,8 @@ public: @@ -168,6 +170,8 @@ public:
168 virtual int initialize(SrsSource* source, SrsRequest* req); 170 virtual int initialize(SrsSource* source, SrsRequest* req);
169 virtual int on_publish(); 171 virtual int on_publish();
170 virtual void on_unpublish(); 172 virtual void on_unpublish();
  173 + virtual int on_audio(SrsSharedPtrMessage* audio);
  174 + virtual int on_video(SrsSharedPtrMessage* video);
171 private: 175 private:
172 virtual int update_duration(SrsSharedPtrMessage* msg); 176 virtual int update_duration(SrsSharedPtrMessage* msg);
173 }; 177 };
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "186" 34 +#define VERSION_REVISION "187"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"