change conference

no more <rooms>
rooms will just be created on the fly.

<action application="conference" data="myconf@myprofile+1234"/>

+1234 is optional on-the-fly pin





git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2381 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-08-24 02:22:57 +00:00
parent 9d3d3a5d69
commit d8703f5bd2
2 changed files with 64 additions and 58 deletions

View File

@ -349,9 +349,6 @@
<param name="caller-id-number" value="8777423583"/> <param name="caller-id-number" value="8777423583"/>
</profile> </profile>
</profiles> </profiles>
<rooms>
<room name="freeswitch" profile="default"/>
</rooms>
</configuration> </configuration>
</section> </section>
<section name="dialplan" description="Regex/XML Dialplan"> <section name="dialplan" description="Regex/XML Dialplan">

View File

@ -121,6 +121,7 @@ struct conference_obj {
char *pin; char *pin;
char *pin_sound; char *pin_sound;
char *bad_pin_sound; char *bad_pin_sound;
char *profile_name;
uint32_t flags; uint32_t flags;
switch_mutex_t *flag_mutex; switch_mutex_t *flag_mutex;
uint32_t rate; uint32_t rate;
@ -2070,6 +2071,8 @@ static void conference_function(switch_core_session_t *session, char *data)
char *flags_str; char *flags_str;
member_flag_t uflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR; member_flag_t uflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR;
switch_core_session_message_t msg = {0}; switch_core_session_message_t msg = {0};
uint8_t isbr = 0;
char *dpin = NULL;
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
assert(channel != NULL); assert(channel != NULL);
@ -2103,32 +2106,39 @@ static void conference_function(switch_core_session_t *session, char *data)
} }
if (!strncasecmp(mydata, bridge_prefix, strlen(bridge_prefix))) { if (!strncasecmp(mydata, bridge_prefix, strlen(bridge_prefix))) {
char *uuid = switch_core_session_get_uuid(session); isbr = 1;
mydata += strlen(bridge_prefix); mydata += strlen(bridge_prefix);
conf_name = mydata; if ((bridgeto = strchr(mydata, ':'))) {
if ((bridgeto = strchr(conf_name, ':'))) {
*bridgeto++ = '\0'; *bridgeto++ = '\0';
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Config Error!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Config Error!\n");
goto done; goto done;
} }
}
if ((profile_name = strchr(conf_name, '@'))) { conf_name = mydata;
*profile_name++ = '\0';
/* Open the config from the xml registry */ if ((dpin = strchr(conf_name, '+'))) {
if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, NULL))) { *dpin++ = '\0';
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name); }
goto done;
} if ((profile_name = strchr(conf_name, '@'))) {
*profile_name++ = '\0';
if ((profiles = switch_xml_child(cfg, "profiles"))) {
profile = switch_xml_find_child(profiles, "profile", "name", profile_name); /* Open the config from the xml registry */
} if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
goto done;
} }
if ((profiles = switch_xml_child(cfg, "profiles"))) {
profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
}
}
if (isbr) {
char *uuid = switch_core_session_get_uuid(session);
if (!strcmp(conf_name, "_uuid_")) { if (!strcmp(conf_name, "_uuid_")) {
conf_name = uuid; conf_name = uuid;
} }
@ -2141,10 +2151,6 @@ static void conference_function(switch_core_session_t *session, char *data)
/* Create the conference object. */ /* Create the conference object. */
conference = conference_new(conf_name, profile, pool); conference = conference_new(conf_name, profile, pool);
/* Release the config registry handle */
switch_xml_free(cxml);
cxml = NULL;
if (!conference) { if (!conference) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
goto done; goto done;
@ -2153,6 +2159,11 @@ static void conference_function(switch_core_session_t *session, char *data)
/* Set the minimum number of members (once you go above it you cannot go below it) */ /* Set the minimum number of members (once you go above it you cannot go below it) */
conference->min = 2; conference->min = 2;
if (dpin) {
printf("ASS [%s]\n", dpin);
conference->pin = switch_core_strdup(conference->pool, dpin);
}
/* Indicate the conference is dynamic */ /* Indicate the conference is dynamic */
switch_set_flag_locked(conference, CFLAG_DYNAMIC); switch_set_flag_locked(conference, CFLAG_DYNAMIC);
@ -2160,12 +2171,32 @@ static void conference_function(switch_core_session_t *session, char *data)
launch_conference_thread(conference); launch_conference_thread(conference);
} else { } else {
conf_name = mydata;
freepool = pool;
/* Figure out what conference to call. */ /* Figure out what conference to call. */
if (!(conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) { if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Conference called %s found.\n", conf_name); freepool = pool;
goto done; } else {
/* Create the conference object. */
conference = conference_new(conf_name, profile, pool);
if (!conference) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
goto done;
}
if (dpin) {
conference->pin = switch_core_strdup(conference->pool, dpin);
}
/* Set the minimum number of members (once you go above it you cannot go below it) */
conference->min = 1;
/* Indicate the conference is dynamic */
switch_set_flag_locked(conference, CFLAG_DYNAMIC);
/* Start the conference thread for this conference */
launch_conference_thread(conference);
} }
if (conference->pin) { if (conference->pin) {
@ -2178,7 +2209,7 @@ static void conference_function(switch_core_session_t *session, char *data)
if (conference->pin_sound) { if (conference->pin_sound) {
conference_local_play_file(session, conference->pin_sound, 20, pin, sizeof(pin)); conference_local_play_file(session, conference->pin_sound, 20, pin, sizeof(pin));
} }
if (strlen(pin) < strlen(conference->pin)) { if (strlen(pin) < strlen(conference->pin)) {
buf = pin + strlen(pin); buf = pin + strlen(pin);
@ -2209,6 +2240,13 @@ static void conference_function(switch_core_session_t *session, char *data)
} }
/* Release the config registry handle */
if (cxml) {
switch_xml_free(cxml);
cxml = NULL;
}
if (!switch_strlen_zero(bridgeto) && strcasecmp(bridgeto, "none")) { if (!switch_strlen_zero(bridgeto) && strcasecmp(bridgeto, "none")) {
if (conference_outcall(conference, session, bridgeto, 60, NULL, NULL) != SWITCH_STATUS_SUCCESS) { if (conference_outcall(conference, session, bridgeto, 60, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
goto done; goto done;
@ -2757,8 +2795,6 @@ static conference_obj_t *conference_new(char *name, switch_xml_t profile, switch
/* Called by FreeSWITCH when the module loads */ /* Called by FreeSWITCH when the module loads */
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename) SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
{ {
switch_xml_t cfg, cxml, room, rooms, profiles, profile = NULL;
conference_obj_t *conference;
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;
memset(&globals, 0, sizeof(globals)); memset(&globals, 0, sizeof(globals));
@ -2777,39 +2813,12 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
return SWITCH_STATUS_TERM; return SWITCH_STATUS_TERM;
} }
/* Open the config from the xml registry */
if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
return SWITCH_STATUS_TERM;
}
/* Setup a hash to store conferences by name */ /* Setup a hash to store conferences by name */
switch_core_hash_init(&globals.conference_hash, globals.conference_pool); switch_core_hash_init(&globals.conference_hash, globals.conference_pool);
switch_mutex_init(&globals.conference_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool); switch_mutex_init(&globals.conference_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
switch_mutex_init(&globals.id_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool); switch_mutex_init(&globals.id_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
switch_mutex_init(&globals.hash_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool); switch_mutex_init(&globals.hash_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
/* Itterate the config */
if ((rooms = switch_xml_child(cfg, "rooms"))) {
/* Parse various rooms. */
for (room = switch_xml_child(rooms, "room"); room; room = room->next) {
char *name = (char *) switch_xml_attr_soft(room, "name");
char *pname = (char *) switch_xml_attr_soft(room, "profile");
if ((profiles = switch_xml_child(cfg, "profiles"))) {
profile = switch_xml_find_child(profiles, "profile", "name", pname);
}
if ((conference = conference_new(name, profile, NULL))) {
/* Start the conference thread for this conference */
launch_conference_thread(conference);
}
}
}
/* Release the config registry handle */
switch_xml_free(cxml);
globals.running = 1; globals.running = 1;
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return status; return status;