diff --git a/src/Rtmp/RtmpToRtspMediaSource.h b/src/Rtmp/RtmpToRtspMediaSource.h index 361ac38e..4ce62e59 100644 --- a/src/Rtmp/RtmpToRtspMediaSource.h +++ b/src/Rtmp/RtmpToRtspMediaSource.h @@ -56,6 +56,7 @@ public: bool bEnableMp4 = false, int ringSize = 0):RtmpMediaSource(vhost, app, id,ringSize){ _recorder = std::make_shared(vhost, app, id, bEnableHls, bEnableMp4); + _rtmpDemuxer = std::make_shared(); } virtual ~RtmpToRtspMediaSource(){} @@ -65,20 +66,17 @@ public: } void onWrite(const RtmpPacket::Ptr &pkt,bool key_pos) override { - if(_rtmpDemuxer){ - _rtmpDemuxer->inputRtmp(pkt); - if(!_rtspMuxer && _rtmpDemuxer->isInited(2000)){ - _rtspMuxer = std::make_shared(getVhost(), - getApp(), - getId(), - std::make_shared( - _rtmpDemuxer->getDuration())); - for (auto &track : _rtmpDemuxer->getTracks(false)){ - _rtspMuxer->addTrack(track); - _recorder->addTrack(track); - track->addDelegate(_rtspMuxer); - track->addDelegate(_recorder); - } + _rtmpDemuxer->inputRtmp(pkt); + if(!_rtspMuxer && _rtmpDemuxer->isInited(2000)){ + _rtspMuxer = std::make_shared(getVhost(), + getApp(), + getId(), + std::make_shared(_rtmpDemuxer->getDuration())); + for (auto &track : _rtmpDemuxer->getTracks(false)){ + _rtspMuxer->addTrack(track); + _recorder->addTrack(track); + track->addDelegate(_rtspMuxer); + track->addDelegate(_recorder); } } RtmpMediaSource::onWrite(pkt,key_pos);