mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-01 15:32:23 +08:00
rtp tcp级联速度太慢时主动限制上游接收速度
防止发送速度跟不上接受速度导致发送超时
This commit is contained in:
@@ -35,7 +35,16 @@ RtpSender::~RtpSender() {
|
||||
}
|
||||
}
|
||||
|
||||
void RtpSender::startSend(const MediaSourceEvent::SendRtpArgs &args, const function<void(uint16_t local_port, const SockException &ex)> &cb){
|
||||
void RtpSender::startSend(const MediaSource &sender, const MediaSourceEvent::SendRtpArgs &args, const function<void(uint16_t local_port, const SockException &ex)> &cb){
|
||||
auto origin_socket = sender.getOriginSock();
|
||||
_origin_socket = dynamic_pointer_cast<Socket>(origin_socket);
|
||||
if (!_origin_socket) {
|
||||
auto process = dynamic_pointer_cast<RtpProcess>(origin_socket);
|
||||
if (process) {
|
||||
_origin_socket = process->getSock();
|
||||
}
|
||||
}
|
||||
|
||||
_args = args;
|
||||
if (!_interface) {
|
||||
// 重连时不重新创建对象 [AUTO-TRANSLATED:b788cd5d]
|
||||
@@ -313,6 +322,15 @@ void RtpSender::onConnect() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (_socket_rtp->sockType() == toolkit::SockNum::Sock_TCP && _origin_socket) {
|
||||
// rtp 端口是TCP端口,转发速度应当控制收流速度
|
||||
auto origin_socket = _origin_socket;
|
||||
_socket_rtp->setOnFlush([origin_socket]() {
|
||||
origin_socket->enableRecv(true);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
InfoL << "startSend rtp success: " << _socket_rtp->get_peer_ip() << ":" << _socket_rtp->get_peer_port() << ", data_type: " << _args.data_type << ", con_type: " << _args.con_type;
|
||||
}
|
||||
|
||||
@@ -433,6 +451,9 @@ void RtpSender::onFlushRtpList(shared_ptr<List<Buffer::Ptr>> rtp_list) {
|
||||
}
|
||||
default: CHECK(0);
|
||||
}
|
||||
if (_socket_rtp->sockType() == toolkit::SockNum::Sock_TCP && _socket_rtp->isSocketBusy() && _origin_socket) {
|
||||
_origin_socket->enableRecv(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
if (_args.con_type != MediaSourceEvent::SendRtpArgs::kVoiceTalk) {
|
||||
|
||||
Reference in New Issue
Block a user