diff --git a/src/Rtmp/RtmpMediaSource.h b/src/Rtmp/RtmpMediaSource.h index 437aa33a..181efa1a 100644 --- a/src/Rtmp/RtmpMediaSource.h +++ b/src/Rtmp/RtmpMediaSource.h @@ -94,16 +94,14 @@ public: } } virtual void onGetMedia(const RtmpPacket::Ptr &pkt) { - if(!m_bRegisted){ - lock_guard lock(m_mtxMap); - if (m_mapCfgFrame.size() != m_iCfgFrameSize && pkt->isCfgFrame()) { - m_mapCfgFrame.emplace(pkt->typeId, pkt); + lock_guard lock(m_mtxMap); + if (pkt->isCfgFrame()) { + m_mapCfgFrame.emplace(pkt->typeId, pkt); - if( m_mapCfgFrame.size() == m_iCfgFrameSize && m_bAsyncRegist){ - m_bAsyncRegist = false; - MediaSource::regist(); - m_bRegisted = true; - } + if(m_bAsyncRegist && !m_bRegisted && m_mapCfgFrame.size() == m_iCfgFrameSize){ + m_bAsyncRegist = false; + MediaSource::regist(); + m_bRegisted = true; } }