Commit 97116e12 by xiongziliang

完善getOwnerPoller相关逻辑

parent b6d3ec52
......@@ -64,6 +64,7 @@ MediaSource::MediaSource(const string &schema, const string &vhost, const string
_app = app;
_stream_id = stream_id;
_create_stamp = time(NULL);
_default_poller = EventPollerPool::Instance().getPoller();
}
MediaSource::~MediaSource() {
......@@ -222,11 +223,12 @@ int MediaSource::getLossRate(mediakit::TrackType type) {
}
toolkit::EventPoller::Ptr MediaSource::getOwnerPoller() {
toolkit::EventPoller::Ptr ret;
auto listener = _listener.lock();
if (!listener) {
return nullptr;
if (listener) {
ret = listener->getOwnerPoller(*this);
}
return listener->getOwnerPoller(*this);
return ret ? ret : _default_poller;
}
void MediaSource::onReaderChanged(int size) {
......
......@@ -343,6 +343,7 @@ private:
std::string _app;
std::string _stream_id;
std::weak_ptr<MediaSourceEvent> _listener;
toolkit::EventPoller::Ptr _default_poller;
//对象个数统计
toolkit::ObjectStatistic<MediaSource> _statistic;
};
......
......@@ -185,6 +185,10 @@ std::shared_ptr<SockInfo> PlayerProxy::getOriginSock(MediaSource &sender) const
return getSockInfo();
}
toolkit::EventPoller::Ptr PlayerProxy::getOwnerPoller(MediaSource &sender) {
return getPoller();
}
void PlayerProxy::onPlaySuccess() {
GET_CONFIG(bool, reset_when_replay, General::kResetWhenRePlay);
if (dynamic_pointer_cast<RtspMediaSource>(_media_src)) {
......
......@@ -59,6 +59,7 @@ private:
MediaOriginType getOriginType(MediaSource &sender) const override;
std::string getOriginUrl(MediaSource &sender) const override;
std::shared_ptr<toolkit::SockInfo> getOriginSock(MediaSource &sender) const override;
toolkit::EventPoller::Ptr getOwnerPoller(MediaSource &sender) override;
void rePlay(const std::string &strUrl,int iFailedCnt);
void onPlaySuccess();
......
......@@ -598,6 +598,10 @@ std::shared_ptr<SockInfo> RtmpSession::getOriginSock(MediaSource &sender) const
return const_cast<RtmpSession *>(this)->shared_from_this();
}
toolkit::EventPoller::Ptr RtmpSession::getOwnerPoller(MediaSource &sender) {
return getPoller();
}
void RtmpSession::setSocketFlags(){
GET_CONFIG(int, merge_write_ms, General::kMergeWriteMS);
if (merge_write_ms > 0) {
......
......@@ -80,6 +80,7 @@ private:
std::string getOriginUrl(MediaSource &sender) const override;
// 获取媒体源客户端相关信息
std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const override;
toolkit::EventPoller::Ptr getOwnerPoller(MediaSource &sender) override;
void setSocketFlags();
std::string getStreamId(const std::string &str);
......
......@@ -1153,6 +1153,10 @@ std::shared_ptr<SockInfo> RtspSession::getOriginSock(MediaSource &sender) const
return const_cast<RtspSession *>(this)->shared_from_this();
}
toolkit::EventPoller::Ptr RtspSession::getOwnerPoller(MediaSource &sender) {
return getPoller();
}
void RtspSession::onBeforeRtpSorted(const RtpPacket::Ptr &rtp, int track_index){
updateRtcpContext(rtp);
}
......
......@@ -91,6 +91,7 @@ protected:
std::string getOriginUrl(MediaSource &sender) const override;
// 获取媒体源客户端相关信息
std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const override;
toolkit::EventPoller::Ptr getOwnerPoller(MediaSource &sender) override;
/////TcpSession override////
ssize_t send(toolkit::Buffer::Ptr pkt) override;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论