startSendRtp接口支持rtcp接收超时主动停止

This commit is contained in:
xiongziliang
2022-08-20 12:48:27 +08:00
parent b7ef766701
commit 9f0c15a4f0
7 changed files with 155 additions and 27 deletions

View File

@@ -223,7 +223,7 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &, const MediaSourceEvent::
#if defined(ENABLE_RTPPROXY)
auto rtp_sender = std::make_shared<RtpSender>();
weak_ptr<MultiMediaSourceMuxer> weak_self = shared_from_this();
rtp_sender->startSend(args, [args, weak_self, rtp_sender, cb](uint16_t local_port, const SockException &ex) {
rtp_sender->startSend(args, [args, weak_self, rtp_sender, cb](uint16_t local_port, const SockException &ex) mutable {
cb(local_port, ex);
auto strong_self = weak_self.lock();
if (!strong_self || ex) {
@@ -233,7 +233,15 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &, const MediaSourceEvent::
rtp_sender->addTrack(track);
}
rtp_sender->addTrackCompleted();
strong_self->_rtp_sender[args.ssrc] = rtp_sender;
auto ssrc = args.ssrc;
rtp_sender->setOnClose([weak_self, ssrc]() {
if (auto strong_self = weak_self.lock()) {
strong_self->_rtp_sender.erase(ssrc);
WarnL << "stream:" << strong_self->_get_origin_url() << " stop send rtp:" << ssrc;
}
});
strong_self->_rtp_sender[args.ssrc] = std::move(rtp_sender);
});
#else
cb(0, SockException(Err_other, "该功能未启用编译时请打开ENABLE_RTPPROXY宏"));