修复rtp tcp推流情况下获取Origin相关失败的问题

This commit is contained in:
xiongziliang 2020-10-24 23:34:22 +08:00
parent d74604e014
commit b5a25793c4
4 changed files with 20 additions and 26 deletions

View File

@ -176,11 +176,7 @@ int RtpProcess::totalReaderCount() {
}
void RtpProcess::setListener(const std::weak_ptr<MediaSourceEvent> &listener) {
if (_muxer) {
_muxer->setMediaListener(listener);
} else {
_listener = listener;
}
setDelegate(listener);
}
void RtpProcess::emitOnPublish() {
@ -195,7 +191,7 @@ void RtpProcess::emitOnPublish() {
strongSelf->_media_info._app,
strongSelf->_media_info._streamid, 0,
true, true, enableHls, enableMP4);
strongSelf->_muxer->setMediaListener(strongSelf->_listener);
strongSelf->_muxer->setMediaListener(strongSelf);
InfoP(strongSelf) << "允许RTP推流";
} else {
WarnP(strongSelf) << "禁止RTP推流:" << err;
@ -212,5 +208,17 @@ void RtpProcess::emitOnPublish() {
}
}
MediaOriginType RtpProcess::getOriginType(MediaSource &sender) const{
return MediaOriginType::rtp_push;
}
string RtpProcess::getOriginUrl(MediaSource &sender) const {
return _media_info._full_url;
}
std::shared_ptr<SockInfo> RtpProcess::getOriginSock(MediaSource &sender) const{
return const_cast<RtpProcess *>(this)->shared_from_this();
}
}//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)

View File

@ -19,7 +19,7 @@ using namespace mediakit;
namespace mediakit {
class RtpProcess : public SockInfo, public MediaSinkInterface, public std::enable_shared_from_this<RtpProcess>{
class RtpProcess : public SockInfo, public MediaSinkInterface, public MediaSourceEventInterceptor, public std::enable_shared_from_this<RtpProcess>{
public:
typedef std::shared_ptr<RtpProcess> Ptr;
friend class RtpProcessHelper;
@ -68,6 +68,11 @@ protected:
void addTrack(const Track::Ptr & track) override;
void resetTracks() override {};
//// MediaSourceEvent override ////
MediaOriginType getOriginType(MediaSource &sender) const override;
string getOriginUrl(MediaSource &sender) const override;
std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const override;
private:
void emitOnPublish();
@ -81,7 +86,6 @@ private:
function<void()> _on_detach;
std::shared_ptr<FILE> _save_file_rtp;
std::shared_ptr<FILE> _save_file_video;
std::weak_ptr<MediaSourceEvent> _listener;
ProcessInterface::Ptr _process;
MultiMediaSourceMuxer::Ptr _muxer;
};

View File

@ -154,18 +154,6 @@ int RtpProcessHelper::totalReaderCount(MediaSource &sender) {
return _process ? _process->totalReaderCount() : sender.totalReaderCount();
}
MediaOriginType RtpProcessHelper::getOriginType(MediaSource &sender) const{
return MediaOriginType::rtp_push;
}
string RtpProcessHelper::getOriginUrl(MediaSource &sender) const {
return _process ? _process->_media_info._full_url : "";
}
std::shared_ptr<SockInfo> RtpProcessHelper::getOriginSock(MediaSource &sender) const{
return _process;
}
RtpProcess::Ptr &RtpProcessHelper::getProcess() {
return _process;
}

View File

@ -34,12 +34,6 @@ protected:
bool close(MediaSource &sender,bool force) override;
// 观看总人数
int totalReaderCount(MediaSource &sender) override;
// 获取媒体源类型
MediaOriginType getOriginType(MediaSource &sender) const override;
// 获取媒体源url或者文件路径
string getOriginUrl(MediaSource &sender) const override;
// 获取媒体源客户端相关信息
std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const override;
private:
weak_ptr<RtpSelector > _parent;