完善获取媒体读取器个数方法

This commit is contained in:
xiongziliang 2019-05-27 16:09:29 +08:00
parent 0fa2452657
commit 3917b6451c
7 changed files with 24 additions and 4 deletions

@ -1 +1 @@
Subproject commit 8f656dfdff2d7c83583a609212716ae8db921fbf Subproject commit 079fae2798687300ff55cfd53b6f80010abe6b81

View File

@ -54,10 +54,13 @@ public:
//拖动进度条 //拖动进度条
return false; return false;
} }
virtual bool close() { virtual bool close() {
//通知其停止推流 //通知其停止推流
return false; return false;
} }
virtual void onReaderChanged(const EventPoller::Ptr &poller,int size,bool add_flag){}
}; };
class MediaInfo class MediaInfo
{ {
@ -166,6 +169,7 @@ public:
} }
} }
virtual int readerCount() = 0;
protected: protected:
void regist() ; void regist() ;
bool unregist() ; bool unregist() ;

View File

@ -64,6 +64,10 @@ public:
return _pRing; return _pRing;
} }
int readerCount() override {
return _pRing->readerCount();
}
const AMFValue &getMetaData() const { const AMFValue &getMetaData() const {
lock_guard<recursive_mutex> lock(_mtxMap); lock_guard<recursive_mutex> lock(_mtxMap);
return _metadata; return _metadata;
@ -87,7 +91,7 @@ public:
_mapCfgFrame[pkt->typeId] = pkt; _mapCfgFrame[pkt->typeId] = pkt;
} else{ } else{
if(!_bRegisted){ if(!_bRegisted){
MediaSource::regist(); regist();
_bRegisted = true; _bRegisted = true;
} }
_mapStamp[pkt->typeId] = pkt->timeStamp; _mapStamp[pkt->typeId] = pkt->timeStamp;

View File

@ -89,6 +89,10 @@ public:
_rtspMuxer->setListener(listener); _rtspMuxer->setListener(listener);
} }
} }
int readerCount() override {
return RtmpMediaSource::readerCount() + _rtspMuxer->readerCount();
}
private: private:
RtmpDemuxer::Ptr _rtmpDemuxer; RtmpDemuxer::Ptr _rtmpDemuxer;
RtspMediaSourceMuxer::Ptr _rtspMuxer; RtspMediaSourceMuxer::Ptr _rtspMuxer;

View File

@ -65,7 +65,12 @@ public:
//获取媒体源的rtp环形缓冲 //获取媒体源的rtp环形缓冲
return _pRing; return _pRing;
} }
const string& getSdp() const {
int readerCount() override {
return _pRing->readerCount();
}
const string& getSdp() const {
//获取该源的媒体描述信息 //获取该源的媒体描述信息
return _strSdp; return _strSdp;
} }

View File

@ -716,7 +716,7 @@ bool RtspSession::handleReq_Play(const Parser &parser) {
auto iStartTime = 1000 * atof(strStart.data()); auto iStartTime = 1000 * atof(strStart.data());
InfoL << "rtsp seekTo(ms):" << iStartTime; InfoL << "rtsp seekTo(ms):" << iStartTime;
useBuf = !pMediaSrc->seekTo(iStartTime); useBuf = !pMediaSrc->seekTo(iStartTime);
}else if(pMediaSrc->getRing()->readerCount() == 0){ }else if(pMediaSrc->readerCount() == 0){
//第一个消费者 //第一个消费者
pMediaSrc->seekTo(0); pMediaSrc->seekTo(0);
} }

View File

@ -85,6 +85,9 @@ public:
_rtmpMuxer->setListener(listener); _rtmpMuxer->setListener(listener);
} }
} }
int readerCount() override {
return RtspMediaSource::readerCount() + _rtmpMuxer->readerCount();
}
private: private:
RtspDemuxer::Ptr _rtspDemuxer; RtspDemuxer::Ptr _rtspDemuxer;
RtmpMediaSourceMuxer::Ptr _rtmpMuxer; RtmpMediaSourceMuxer::Ptr _rtmpMuxer;