]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Added parsing for additional parameters for UI team to test their code
authorDavid Yat Sin <dyatsin@sangoma.com>
Tue, 19 Jun 2012 21:30:03 +0000 (17:30 -0400)
committerDavid Yat Sin <dyatsin@sangoma.com>
Tue, 19 Jun 2012 21:30:03 +0000 (17:30 -0400)
src/mod/endpoints/mod_media_gateway/media_gateway_xml.c
src/mod/endpoints/mod_media_gateway/mod_media_gateway.h

index 710cc7e6c49d61d8c45760d401f611f8db01eb15..2d584ed0edd9d895bf51c6df347c32aa61acd262 100644 (file)
@@ -19,7 +19,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
        switch_xml_t cfg, xml, param, mg_interfaces, mg_interface, mg_peers, mg_peer, peer_interfaces ;
        switch_status_t status = SWITCH_STATUS_FALSE;
        switch_event_t *event = NULL;
-       const char *file = "megaco.conf";
+       const char *file = "media_gateway.conf";
        switch_xml_config_item_t *instructions = (profile ? get_instructions(profile) : NULL);
        int count;
        int idx;
@@ -63,6 +63,11 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
                break;
        }
 
+       if (!mg_interface) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error profile %s not found\n", profile->name);
+                       return SWITCH_STATUS_FALSE;
+       }
+
        /* go through the peer configuration and get the mg profile associated peers only */
        if (!(mg_peers = switch_xml_child(cfg, "mg_peers"))) {
                goto done;
@@ -144,10 +149,25 @@ static switch_xml_config_item_t *get_instructions(megaco_profile_t *profile) {
        static switch_xml_config_int_options_t opt_version = { 
                SWITCH_TRUE,  /* enforce min */
                1,
-               SWITCH_TRUE, /* Enforce Max */
+               SWITCH_TRUE, /* enforce Max */
                3
        };
 
+       static switch_xml_config_int_options_t opt_termination_id_len = {
+               SWITCH_TRUE,  /* enforce min */
+               1,
+               SWITCH_TRUE, /* enforce Max */
+               9
+       };
+
+       static switch_xml_config_enum_item_t opt_default_codec_enum[] = {
+               {  "PCMA",  MEGACO_CODEC_PCMA},
+               {  "PCMU",  MEGACO_CODEC_PCMU},
+               {  "G.729",  MEGACO_CODEC_G729},
+               {  "G.723.1",  MEGACO_CODEC_G723_1},
+               {  "ILBC", MEGACO_CODEC_ILBC },
+       };
+
        switch_xml_config_item_t instructions[] = {
                /* parameter name        type                 reloadable   pointer                         default value     options structure */
                SWITCH_CONFIG_ITEM("protocol", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->protocol_type, "MEGACO", &switch_config_string_strdup, "", "MG Protocol type"),
@@ -156,6 +176,11 @@ static switch_xml_config_item_t *get_instructions(megaco_profile_t *profile) {
                SWITCH_CONFIG_ITEM("port", SWITCH_CONFIG_STRING, 0, &profile->port, "2944", &switch_config_string_strdup, "", "port"),
                SWITCH_CONFIG_ITEM("domain-name", SWITCH_CONFIG_STRING, 0, &profile->my_domain, "", &switch_config_string_strdup, "", "domain name"),
                SWITCH_CONFIG_ITEM("message-identifier", SWITCH_CONFIG_STRING, 0, &profile->mid, "", &switch_config_string_strdup, "", "message identifier "),
+
+               SWITCH_CONFIG_ITEM("default-codec", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &profile->default_codec, "PCMU", &opt_default_codec_enum, "", "default codec"),
+               SWITCH_CONFIG_ITEM("rtp-port-range", SWITCH_CONFIG_STRING, CONFIG_REQUIRED, &profile->rtp_port_range, "1-65535", &switch_config_string_strdup, "", "rtp port range"),
+               SWITCH_CONFIG_ITEM("rtp-termination-id-prefix", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->rtp_termination_id_prefix, "", &switch_config_string_strdup, "", "rtp termination prefix"),
+               SWITCH_CONFIG_ITEM("rtp-termination-id-len", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &profile->rtp_termination_id_len, "", &opt_termination_id_len, "", "rtp termination id"),
                SWITCH_CONFIG_ITEM_END()
        };
        
index 2e0db8cb62e892d9714ce0c6c3f8ea6ed4f3f40f..d4c6e430774e12b7cd3c49f4274337295f9a2d94 100644 (file)
@@ -32,6 +32,14 @@ typedef enum {
        PF_RUNNING = (1 << 0)
 } megaco_profile_flags_t;
 
+typedef enum {
+       MEGACO_CODEC_PCMA,
+       MEGACO_CODEC_PCMU,
+       MEGACO_CODEC_G729,
+       MEGACO_CODEC_G723_1,
+       MEGACO_CODEC_ILBC,
+} megaco_codec_t;
+
 typedef struct mg_peer_profile_s{
        char                            *name;
        switch_memory_pool_t            *pool;
@@ -47,18 +55,22 @@ typedef struct mg_peer_profile_s{
 
 typedef struct megaco_profile_s {
        char                            *name;
-       switch_memory_pool_t            *pool;
-       switch_thread_rwlock_t          *rwlock; /* < Reference counting rwlock */
-       megaco_profile_flags_t          flags;
-       int                             idx;         /* Trillium MEGACO SAP identification*/
-       char*                           mid;         /* MG H.248 MID */
-       char*                           my_domain;   /* local domain name */
-       char*                           my_ipaddr;   /* local domain name */
-       char*                           port;                        /* port */
-       char*                           protocol_type;               /* MEGACO/MGCP */
-       int                             protocol_version;            /* Protocol supported version */
-       int                             total_peers;            
-       char*                           peer_list[MG_MAX_PEERS];     /* MGC Peer ID LIST */
+       switch_memory_pool_t    *pool;
+       switch_thread_rwlock_t  *rwlock; /* < Reference counting rwlock */
+       megaco_profile_flags_t  flags;
+       int                                     idx;         /* Trillium MEGACO SAP identification*/
+       char*                                   mid;         /* MG H.248 MID */
+       char*                                   my_domain;   /* local domain name */
+       char*                                   my_ipaddr;   /* local domain name */
+       char*                                   port;                        /* port */
+       char*                                   protocol_type;               /* MEGACO/MGCP */
+       int                                     protocol_version;            /* Protocol supported version */
+       int                                     total_peers;
+       megaco_codec_t                  default_codec;
+       char*                                   rtp_port_range;
+       char*                                   rtp_termination_id_prefix;
+       int                                             rtp_termination_id_len;
+       char*                   peer_list[MG_MAX_PEERS];     /* MGC Peer ID LIST */
 } megaco_profile_t;