mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
add RtspMediaSource::Clone
This commit is contained in:
parent
51e9313275
commit
f4ee607feb
@ -76,6 +76,10 @@ public:
|
||||
return _sdp;
|
||||
}
|
||||
|
||||
virtual RtspMediaSource::Ptr Clone(const std::string& stream) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取相应轨道的ssrc
|
||||
*/
|
||||
|
@ -126,6 +126,12 @@ void RtspMediaSourceImp::setProtocolOption(const ProtocolOption &option)
|
||||
}
|
||||
}
|
||||
|
||||
RtspMediaSource::Ptr RtspMediaSourceImp::Clone(const std::string &stream) {
|
||||
auto src_imp = std::make_shared<RtspMediaSourceImp>(getVhost(), getApp(), stream);
|
||||
src_imp->setSdp(getSdp());
|
||||
src_imp->setProtocolOption(getProtocolOption());
|
||||
return src_imp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -107,6 +107,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
RtspMediaSource::Ptr Clone(const std::string& stream) override;
|
||||
private:
|
||||
bool _all_track_ready = false;
|
||||
ProtocolOption _option;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define ZLMEDIAKIT_WEBRTCPUSHER_H
|
||||
|
||||
#include "WebRtcTransport.h"
|
||||
#include "Rtsp/RtspMediaSourceImp.h"
|
||||
#include "Rtsp/RtspMediaSource.h"
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
@ -20,7 +20,7 @@ class WebRtcPusher : public WebRtcTransportImp, public MediaSourceEvent {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<WebRtcPusher>;
|
||||
~WebRtcPusher() override = default;
|
||||
static Ptr create(const EventPoller::Ptr &poller, const RtspMediaSourceImp::Ptr &src,
|
||||
static Ptr create(const EventPoller::Ptr &poller, const RtspMediaSource::Ptr &src,
|
||||
const std::shared_ptr<void> &ownership, const MediaInfo &info, const ProtocolOption &option, bool preferred_tcp = false);
|
||||
|
||||
protected:
|
||||
@ -51,7 +51,7 @@ protected:
|
||||
float getLossRate(MediaSource &sender,TrackType type) override;
|
||||
|
||||
private:
|
||||
WebRtcPusher(const EventPoller::Ptr &poller, const RtspMediaSourceImp::Ptr &src,
|
||||
WebRtcPusher(const EventPoller::Ptr &poller, const RtspMediaSource::Ptr &src,
|
||||
const std::shared_ptr<void> &ownership, const MediaInfo &info, const ProtocolOption &option, bool preferred_tcp);
|
||||
|
||||
private:
|
||||
@ -61,7 +61,7 @@ private:
|
||||
//媒体相关元数据
|
||||
MediaInfo _media_info;
|
||||
//推流的rtsp源
|
||||
RtspMediaSourceImp::Ptr _push_src;
|
||||
RtspMediaSource::Ptr _push_src;
|
||||
//推流所有权
|
||||
std::shared_ptr<void> _push_src_ownership;
|
||||
//推流的rtsp源,支持simulcast
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "WebRtcPlayer.h"
|
||||
#include "WebRtcPusher.h"
|
||||
|
||||
#include "Rtsp/RtspMediaSourceImp.h"
|
||||
|
||||
#define RTP_SSRC_OFFSET 1
|
||||
#define RTX_SSRC_OFFSET 2
|
||||
#define RTP_CNAME "zlmediakit-rtp"
|
||||
|
Loading…
Reference in New Issue
Block a user