From 3284ab2464b5cbbbd56ec6c49cd5a67d1a48c6b3 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 9 Apr 2019 11:42:28 +0800 Subject: [PATCH] =?UTF-8?q?rtmp=E8=BD=ACrtsp=E5=85=BC=E5=AE=B9=E6=97=A0met?= =?UTF-8?q?edata=E7=9A=84=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtmp/RtmpToRtspMediaSource.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) 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);