From ee2024f7bdc61c887068a66f844e28e0a44dc495 Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Mon, 17 Mar 2008 20:10:22 +0000 Subject: enabled port window --- anyrtpproxy/commandHandler.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'anyrtpproxy') diff --git a/anyrtpproxy/commandHandler.cpp b/anyrtpproxy/commandHandler.cpp index dd37fcc..78cff4b 100644 --- a/anyrtpproxy/commandHandler.cpp +++ b/anyrtpproxy/commandHandler.cpp @@ -170,10 +170,14 @@ string CommandHandler::handleRequest(string modifiers, string call_id, string ad RtpSession& session = gRtpSessionTable.getOrNewSession(call_id, is_new); if(is_new) { - static u_int16_t port1 = 35000; // TODO: get next available port - static u_int16_t port2 = 35001; // TODO: get next available port - port1+=2; - port2+=2; + u_int16_t port1 = port_window_.newPort(); // TODO: get next available port + u_int16_t port2 = port_window_.newPort(); // TODO: get next available port + if( !port1 || !port2) + { + if( port1) port_window_.freePort(port1); + if( port2) port_window_.freePort(port2); + throw std::runtime_error("no free port found"); + } session.setLocalAddr("0.0.0.0"); // TODO: read this from config session.setLocalPort1(port1); -- cgit v1.2.3