mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 12:11:36 +08:00
startSendRtp接口新增支持同ssrc向多个服务器推流 (#2951)
新增ssrc_multi_send参数,支持同ssrc向多个服务器推流,兼容当前startSendRtp/stopSendRtp接口
This commit is contained in:
parent
1609fe67d7
commit
f8285a3f6c
@ -1710,10 +1710,16 @@
|
||||
"value": "obs",
|
||||
"description": "流id,例如 obs"
|
||||
},
|
||||
{
|
||||
"key": "ssrc_multi_send",
|
||||
"value": "0",
|
||||
"description": "是否支持同ssrc推流到多个上级服务器,该参数非必选参数 默认false",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"key": "ssrc",
|
||||
"value": "1",
|
||||
"description": "rtp推流的ssrc,ssrc不同时,可以推流到多个上级服务器"
|
||||
"description": "rtp推流的ssrc"
|
||||
},
|
||||
{
|
||||
"key": "dst_url",
|
||||
|
@ -1245,6 +1245,7 @@ void installWebApi() {
|
||||
args.passive = false;
|
||||
args.dst_url = allArgs["dst_url"];
|
||||
args.dst_port = allArgs["dst_port"];
|
||||
args.ssrc_multi_send = allArgs["ssrc_multi_send"].empty() ? false : allArgs["ssrc_multi_send"].as<bool>();
|
||||
args.ssrc = allArgs["ssrc"];
|
||||
args.is_udp = allArgs["is_udp"];
|
||||
args.src_port = allArgs["src_port"];
|
||||
|
@ -104,6 +104,8 @@ public:
|
||||
bool passive = false;
|
||||
// rtp payload type
|
||||
uint8_t pt = 96;
|
||||
//是否支持同ssrc多服务器发送
|
||||
bool ssrc_multi_send = false;
|
||||
// 指定rtp ssrc
|
||||
std::string ssrc;
|
||||
// 指定本地发送端口
|
||||
|
@ -291,12 +291,14 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceE
|
||||
|
||||
auto ring = _ring;
|
||||
auto ssrc = args.ssrc;
|
||||
auto ssrc_multi_send = args.ssrc_multi_send;
|
||||
auto tracks = getTracks(false);
|
||||
auto poller = getOwnerPoller(sender);
|
||||
auto rtp_sender = std::make_shared<RtpSender>(poller);
|
||||
|
||||
weak_ptr<MultiMediaSourceMuxer> weak_self = shared_from_this();
|
||||
|
||||
rtp_sender->startSend(args, [ssrc, weak_self, rtp_sender, cb, tracks, ring, poller](uint16_t local_port, const SockException &ex) mutable {
|
||||
rtp_sender->startSend(args, [ssrc,ssrc_multi_send, weak_self, rtp_sender, cb, tracks, ring, poller](uint16_t local_port, const SockException &ex) mutable {
|
||||
cb(local_port, ex);
|
||||
auto strong_self = weak_self.lock();
|
||||
if (!strong_self || ex) {
|
||||
@ -325,7 +327,10 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceE
|
||||
|
||||
// 可能归属线程发生变更
|
||||
strong_self->getOwnerPoller(MediaSource::NullMediaSource())->async([=]() {
|
||||
strong_self->_rtp_sender[ssrc] = std::move(reader);
|
||||
if(!ssrc_multi_send) {
|
||||
strong_self->_rtp_sender.erase(ssrc);
|
||||
}
|
||||
strong_self->_rtp_sender.emplace(ssrc,reader);
|
||||
});
|
||||
});
|
||||
#else
|
||||
|
@ -168,7 +168,7 @@ private:
|
||||
toolkit::Ticker _last_check;
|
||||
Stamp _stamp[2];
|
||||
std::weak_ptr<Listener> _track_listener;
|
||||
std::unordered_map<std::string, RingType::RingReader::Ptr> _rtp_sender;
|
||||
std::unordered_multimap<std::string, RingType::RingReader::Ptr> _rtp_sender;
|
||||
FMP4MediaSourceMuxer::Ptr _fmp4;
|
||||
RtmpMediaSourceMuxer::Ptr _rtmp;
|
||||
RtspMediaSourceMuxer::Ptr _rtsp;
|
||||
|
Loading…
Reference in New Issue
Block a user