add RtspMediaSource::Clone

This commit is contained in:
Johnny
2023-05-11 20:47:40 +08:00
committed by 夏楚
parent 51e9313275
commit f4ee607feb
6 changed files with 21 additions and 9 deletions

View File

@@ -10,13 +10,14 @@
#include "WebRtcPusher.h"
#include "Common/config.h"
#include "Rtsp/RtspMediaSourceImp.h"
using namespace std;
namespace mediakit {
WebRtcPusher::Ptr WebRtcPusher::create(const EventPoller::Ptr &poller,
const RtspMediaSourceImp::Ptr &src,
const RtspMediaSource::Ptr &src,
const std::shared_ptr<void> &ownership,
const MediaInfo &info,
const ProtocolOption &option,
@@ -30,7 +31,7 @@ WebRtcPusher::Ptr WebRtcPusher::create(const EventPoller::Ptr &poller,
}
WebRtcPusher::WebRtcPusher(const EventPoller::Ptr &poller,
const RtspMediaSourceImp::Ptr &src,
const RtspMediaSource::Ptr &src,
const std::shared_ptr<void> &ownership,
const MediaInfo &info,
const ProtocolOption &option,
@@ -98,10 +99,8 @@ void WebRtcPusher::onRecvRtp(MediaTrack &track, const string &rid, RtpPacket::Pt
auto &src = _push_src_sim[rid];
if (!src) {
auto stream_id = rid.empty() ? _push_src->getId() : _push_src->getId() + "_" + rid;
auto src_imp = std::make_shared<RtspMediaSourceImp>(_push_src->getVhost(), _push_src->getApp(), stream_id);
auto src_imp = _push_src->Clone(stream_id);
_push_src_sim_ownership[rid] = src_imp->getOwnership();
src_imp->setSdp(_push_src->getSdp());
src_imp->setProtocolOption(_push_src->getProtocolOption());
src_imp->setListener(static_pointer_cast<WebRtcPusher>(shared_from_this()));
src = src_imp;
}