[Freeswitch-svn] [commit] r4881 - in freeswitch/trunk: conf src src/include

Freeswitch SVN anthm at freeswitch.org
Fri Apr 6 23:07:43 EDT 2007


Author: anthm
Date: Fri Apr  6 23:07:43 2007
New Revision: 4881

Modified:
   freeswitch/trunk/conf/freeswitch_combined.xml
   freeswitch/trunk/conf/switch.conf.xml
   freeswitch/trunk/src/include/switch_rtp.h
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/src/switch_rtp.c

Log:
added patch from http://jira.freeswitch.org/browse/FSCORE-25

Modified: freeswitch/trunk/conf/freeswitch_combined.xml
==============================================================================
--- freeswitch/trunk/conf/freeswitch_combined.xml	(original)
+++ freeswitch/trunk/conf/freeswitch_combined.xml	Fri Apr  6 23:07:43 2007
@@ -7,6 +7,9 @@
       <settings>
 	<!--Most channels to allow at once -->
 	<param name="max-sessions" value="1000"/>
+	<!--RTP port range -->
+	<!--<param name="rtp-start-port" value="16384"/>-->
+	<!--<param name="rtp-end-port" value="32768"/>-->
       </settings>
       <!--Any variables defined here will be available in every channel, in the dialplan etc -->
       <variables>

Modified: freeswitch/trunk/conf/switch.conf.xml
==============================================================================
--- freeswitch/trunk/conf/switch.conf.xml	(original)
+++ freeswitch/trunk/conf/switch.conf.xml	Fri Apr  6 23:07:43 2007
@@ -2,6 +2,9 @@
   <settings>
     <!--Most channels to allow at once -->
     <param name="max-sessions" value="1000"/>
+    <!--RTP port range -->
+    <!--<param name="rtp-start-port" value="16384"/>-->
+    <!--<param name="rtp-end-port" value="32768"/>-->
   </settings>
   <!--Any variables defined here will be available in every channel, in the dialplan etc -->
   <variables>

Modified: freeswitch/trunk/src/include/switch_rtp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_rtp.h	(original)
+++ freeswitch/trunk/src/include/switch_rtp.h	Fri Apr  6 23:07:43 2007
@@ -27,6 +27,7 @@
  *
  *
  * switch_channel.h -- Media Channel Interface
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  */
 /** 
@@ -53,6 +54,20 @@
 */
 SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool);
 
+/*!
+  \brief Set/Get RTP start port
+  \param port new value (if > 0)
+  \return the current RTP start port
+*/
+SWITCH_DECLARE(switch_port_t) switch_rtp_set_start_port(switch_port_t port);
+
+/*!
+  \brief Set/Get RTP end port
+  \param port new value (if > 0)
+  \return the current RTP end port
+*/
+SWITCH_DECLARE(switch_port_t) switch_rtp_set_end_port(switch_port_t port);
+
 /*! 
   \brief Request a new port to be used for media
   \return the new port to use

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Fri Apr  6 23:07:43 2007
@@ -26,6 +26,7 @@
  * Anthony Minessale II <anthmct at yahoo.com>
  * Michael Jerris <mike at jerris.com>
  * Paul D. Tinsley <pdt at jackhammer.org>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  *
  * switch_core.c -- Main Core Library
@@ -445,6 +446,12 @@
 				if (!strcasecmp(var, "max-sessions")) {
 					switch_core_session_limit(atoi(val));
 				}
+				else if (!strcasecmp(var, "rtp-start-port")) {
+					switch_rtp_set_start_port(atoi(val));
+				}
+				else if (!strcasecmp(var, "rtp-end-port")) {
+					switch_rtp_set_end_port(atoi(val));
+				}
 			}
 		}
 

Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c	(original)
+++ freeswitch/trunk/src/switch_rtp.c	Fri Apr  6 23:07:43 2007
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Anthony Minessale II <anthmct at yahoo.com>
+ * Marcel Barbulescu <marcelbarbulescu at gmail.com>
  *
  *
  * switch_rtp.c -- RTP
@@ -50,6 +51,8 @@
 #define MASTER_KEY_LEN   30
 #define RTP_MAGIC_NUMBER 42
 
+static switch_port_t START_PORT = RTP_START_PORT;
+static switch_port_t END_PORT = RTP_END_PORT;
 static switch_port_t NEXT_PORT = RTP_START_PORT;
 static switch_mutex_t *port_lock = NULL;
 
@@ -263,6 +266,43 @@
 	global_init = 1;
 }
 
+SWITCH_DECLARE(switch_port_t) switch_rtp_set_start_port(switch_port_t port)
+{
+	if (port) {
+		if (port_lock) {
+			switch_mutex_lock(port_lock);
+		}
+		if (NEXT_PORT == START_PORT) {
+			NEXT_PORT = port;
+		}
+		START_PORT = port;
+		if (NEXT_PORT < START_PORT) {
+			NEXT_PORT = START_PORT;
+		}
+		if (port_lock) {
+			switch_mutex_unlock(port_lock);
+		}
+        }
+        return START_PORT;
+}
+
+SWITCH_DECLARE(switch_port_t) switch_rtp_set_end_port(switch_port_t port)
+{
+	if (port) {
+		if (port_lock) {
+			switch_mutex_lock(port_lock);
+		}
+		END_PORT = port;
+		if (NEXT_PORT > END_PORT) {
+			NEXT_PORT = START_PORT;
+		}
+		if (port_lock) {
+			switch_mutex_unlock(port_lock);
+		}
+        }
+        return END_PORT;
+}
+
 SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(void)
 {
 	switch_port_t port;
@@ -270,8 +310,8 @@
 	switch_mutex_lock(port_lock);
 	port = NEXT_PORT;
 	NEXT_PORT += 2;
-	if (NEXT_PORT > RTP_END_PORT) {
-		NEXT_PORT = RTP_START_PORT;
+	if (NEXT_PORT > END_PORT) {
+		NEXT_PORT = START_PORT;
 	}
 	switch_mutex_unlock(port_lock);
 	return port;



More information about the Freeswitch-svn mailing list