[Freeswitch-svn] [commit] r2381 - in freeswitch/trunk: conf src/mod/applications/mod_conference

Freeswitch SVN anthm at freeswitch.org
Wed Aug 23 22:22:57 EDT 2006


Author: anthm
Date: Wed Aug 23 22:22:57 2006
New Revision: 2381

Modified:
   freeswitch/trunk/conf/freeswitch.xml
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c

Log:
change conference

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

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

+1234 is optional on-the-fly pin





Modified: freeswitch/trunk/conf/freeswitch.xml
==============================================================================
--- freeswitch/trunk/conf/freeswitch.xml	(original)
+++ freeswitch/trunk/conf/freeswitch.xml	Wed Aug 23 22:22:57 2006
@@ -349,9 +349,6 @@
           <param name="caller-id-number" value="8777423583"/>
         </profile>
       </profiles>
-      <rooms>
-        <room name="freeswitch" profile="default"/>
-      </rooms>
     </configuration>
   </section>
   <section name="dialplan" description="Regex/XML Dialplan">

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Wed Aug 23 22:22:57 2006
@@ -121,6 +121,7 @@
 	char *pin;
 	char *pin_sound;
 	char *bad_pin_sound;
+	char *profile_name;
 	uint32_t flags;
 	switch_mutex_t *flag_mutex;
 	uint32_t rate;
@@ -2070,6 +2071,8 @@
 	char *flags_str;
 	member_flag_t uflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR;
 	switch_core_session_message_t msg = {0};
+	uint8_t isbr = 0;
+	char *dpin = NULL;
 	
 	channel = switch_core_session_get_channel(session);
     assert(channel != NULL);
@@ -2103,32 +2106,39 @@
 	}
 
 	if (!strncasecmp(mydata, bridge_prefix, strlen(bridge_prefix))) {
-		char *uuid = switch_core_session_get_uuid(session);
-		
+		isbr = 1;
 		mydata += strlen(bridge_prefix);
-		conf_name = mydata;
-
-		if ((bridgeto = strchr(conf_name, ':'))) {
+		if ((bridgeto = strchr(mydata, ':'))) {
 			*bridgeto++ = '\0';
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Config Error!\n");
 			goto done;
 		}
+	}
 
-		if ((profile_name = strchr(conf_name, '@'))) {
-			*profile_name++ = '\0';
+	conf_name = mydata;
 
-			/* 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 ((dpin = strchr(conf_name, '+'))) {
+		*dpin++ = '\0';
+	}
+
+	if ((profile_name = strchr(conf_name, '@'))) {
+		*profile_name++ = '\0';
+
+		/* 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_")) {
 			conf_name = uuid;
 		}
@@ -2141,10 +2151,6 @@
 		/* Create the conference object. */
 		conference = conference_new(conf_name, profile, pool);
 
-		/* Release the config registry handle */
-		switch_xml_free(cxml);
-		cxml = NULL;
-
 		if (!conference) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 			goto done;
@@ -2153,6 +2159,11 @@
 		/* Set the minimum number of members (once you go above it you cannot go below it) */
 		conference->min = 2;
 
+		if (dpin) {
+			printf("ASS [%s]\n", dpin);
+			conference->pin = switch_core_strdup(conference->pool, dpin);
+		}
+
 		/* Indicate the conference is dynamic */
 		switch_set_flag_locked(conference, CFLAG_DYNAMIC);	
 
@@ -2160,12 +2171,32 @@
 		launch_conference_thread(conference);
 
 	} else {
-		conf_name = mydata;
-		freepool = pool;
 		/* Figure out what conference to call. */
-		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);
-			goto done;
+		if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
+			freepool = pool;
+		} 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) {
@@ -2178,7 +2209,7 @@
 
 			if (conference->pin_sound) {
 				conference_local_play_file(session, conference->pin_sound, 20, pin, sizeof(pin));
-			}
+			} 
 
 			if (strlen(pin) < strlen(conference->pin)) {
 				buf = pin + strlen(pin);
@@ -2209,6 +2240,13 @@
 		
 	}
 
+	/* Release the config registry handle */
+	if (cxml) {
+		switch_xml_free(cxml);
+		cxml = NULL;
+	}
+
+
 	if (!switch_strlen_zero(bridgeto) && strcasecmp(bridgeto, "none")) {
 		if (conference_outcall(conference, session, bridgeto, 60, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
 			goto done;
@@ -2757,8 +2795,6 @@
 /* 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_xml_t cfg, cxml, room, rooms, profiles, profile = NULL;
-	conference_obj_t *conference;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	
 	memset(&globals, 0, sizeof(globals));
@@ -2777,38 +2813,11 @@
 		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 */
 	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.id_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;
 	/* indicate that the module should continue to be loaded */



More information about the Freeswitch-svn mailing list