]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
added patch from http://jira.freeswitch.org/browse/FSCORE-25
authorAnthony Minessale <anthony.minessale@gmail.com>
Sat, 7 Apr 2007 03:07:43 +0000 (03:07 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sat, 7 Apr 2007 03:07:43 +0000 (03:07 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4881 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/freeswitch_combined.xml
conf/switch.conf.xml
src/include/switch_rtp.h
src/switch_core.c
src/switch_rtp.c

index 4cd52a97b3e1f39cf2c7f551f08d27938b8444c5..40f7d7bfda5de727825665e0f52ae4b115f8ceff 100644 (file)
@@ -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>
index 818f91542e293ef4783a5ee5e87d25c6f218be5f..89d91519e850ce803275c9ed0d55f256b7154a9e 100644 (file)
@@ -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>
index f2cc1f291095e05f7352c4c1c0ed93f951c852d9..dbba4fdfcf4984fb2cc24774f01207d72c5a08ae 100644 (file)
@@ -27,6 +27,7 @@
  *
  *
  * switch_channel.h -- Media Channel Interface
+ * Marcel Barbulescu <marcelbarbulescu@gmail.com>
  *
  */
 /** 
@@ -53,6 +54,20 @@ typedef void (*switch_rtp_invalid_handler_t) (switch_rtp_t *rtp_session,
 */
 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
index 62e4de2dd7293ebc978ee75759c7e5bd5372fedf..2d965d52d26729141c863296012c8b370987fd5e 100644 (file)
@@ -26,6 +26,7 @@
  * Anthony Minessale II <anthmct@yahoo.com>
  * Michael Jerris <mike@jerris.com>
  * Paul D. Tinsley <pdt at jackhammer.org>
+ * Marcel Barbulescu <marcelbarbulescu@gmail.com>
  *
  *
  * switch_core.c -- Main Core Library
@@ -445,6 +446,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err
                                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));
+                               }
                        }
                }
 
index 54b64910eece368946ab7faf1cbf273267a7dde0..9d548146f45fa2f618006a28d74c4f96745bde6f 100644 (file)
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Anthony Minessale II <anthmct@yahoo.com>
+ * Marcel Barbulescu <marcelbarbulescu@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 @@ SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool)
        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_DECLARE(switch_port_t) switch_rtp_request_port(void)
        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;