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

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;
}
virtual bool close() {
//通知其停止推流
return false;
}
virtual void onReaderChanged(const EventPoller::Ptr &poller,int size,bool add_flag){}
};
class MediaInfo
{
@ -166,6 +169,7 @@ public:
}
}
virtual int readerCount() = 0;
protected:
void regist() ;
bool unregist() ;

View File

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

View File

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

View File

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

View File

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

View File

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