startSendRtp接口udp发送不指定端口时,从端口池获取端口

This commit is contained in:
xiongziliang 2022-04-09 10:33:27 +08:00
parent a6e82799f5
commit a1b350c9f0

View File

@ -31,7 +31,15 @@ void RtpSender::startSend(const MediaSourceEvent::SendRtpArgs &args, const funct
_socket = Socket::createSocket(_poller, false);
weak_ptr<RtpSender> weak_self = shared_from_this();
if (args.is_udp) {
_socket->bindUdpSock(args.src_port);
if (args.src_port) {
//指定端口
_socket->bindUdpSock(args.src_port);
} else {
auto pr = std::make_pair(std::move(_socket), Socket::createSocket(_poller, false));
//从端口池获取随机端口
makeSockPair(pr, "0.0.0.0", true);
_socket = std::move(pr.first);
}
auto poller = _poller;
auto local_port = _socket->get_local_port();
WorkThreadPool::Instance().getPoller()->async([cb, args, weak_self, poller, local_port]() {