From 4908ab4b4719ebabf668a6728cccbe4b38a2314a Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 9 Apr 2019 11:31:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96RTMP=E7=9A=84=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtmp/RtmpMediaSource.h | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/Rtmp/RtmpMediaSource.h b/src/Rtmp/RtmpMediaSource.h index 74ec8f70..9b8d9df8 100644 --- a/src/Rtmp/RtmpMediaSource.h +++ b/src/Rtmp/RtmpMediaSource.h @@ -76,36 +76,19 @@ public: } } - virtual void onGetMetaData(const AMFValue &metadata) { lock_guard lock(_mtxMap); _metadata = metadata; - _iCfgFrameSize = RtmpDemuxer::getTrackCount(metadata); - if(ready()){ - MediaSource::regist(); - _bRegisted = true; - } else{ - _bAsyncRegist = true; - } } void onWrite(const RtmpPacket::Ptr &pkt,bool isKey = true) override { lock_guard lock(_mtxMap); if (pkt->isCfgFrame()) { _mapCfgFrame[pkt->typeId] = pkt; - - if(_bAsyncRegist && !_bRegisted && _mapCfgFrame.size() == _iCfgFrameSize){ - _bAsyncRegist = false; - MediaSource::regist(); - _bRegisted = true; - } } else{ if(!_bRegisted){ - //强制在3秒后注册,不管是否有metedata或config包 - if(_ticker.createdTime() > 3 * 1000){ - MediaSource::regist(); - _bRegisted = true; - } + MediaSource::regist(); + _bRegisted = true; } _mapStamp[pkt->typeId] = pkt->timeStamp; _pRing->write(pkt,pkt->isVideoKeyFrame()); @@ -123,21 +106,13 @@ public: return MAX(_mapStamp[MSG_VIDEO],_mapStamp[MSG_AUDIO]); } } -private: - bool ready(){ - lock_guard lock(_mtxMap); - return _iCfgFrameSize != -1 && _iCfgFrameSize == _mapCfgFrame.size(); - } protected: AMFValue _metadata; map _mapCfgFrame; map _mapStamp; mutable recursive_mutex _mtxMap; RingBuffer::Ptr _pRing; //rtp环形缓冲 - int _iCfgFrameSize = -1; - bool _bAsyncRegist = false; bool _bRegisted = false; - Ticker _ticker; }; } /* namespace mediakit */