[asterisk-commits] rmudgett: trunk r382764 - in /trunk/apps: ./ confbridge/ confbridge/include/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 8 18:21:50 CST 2013


Author: rmudgett
Date: Fri Mar  8 18:21:46 2013
New Revision: 382764

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382764
Log:
confbridge: Rename items for clarity and consistency.

struct conference_bridge_user -> struct confbridge_user
struct conference_bridge -> struct confbridge_conference
struct conference_state -> struct confbridge_state

struct conference_bridge_user *conference_bridge_user -> struct confbridge_user *user
struct conference_bridge_user *cbu -> struct confbridge_user *user
struct conference_bridge *conference_bridge -> struct confbridge_conference *conference

The names are now generally shorter, consistently used, and don't conflict
with the struct names.

This patch handles the renaming part of the issue.

(issue ASTERISK-20776)
Reported by: rmudgett

Modified:
    trunk/apps/app_confbridge.c
    trunk/apps/confbridge/conf_config_parser.c
    trunk/apps/confbridge/conf_state.c
    trunk/apps/confbridge/conf_state_empty.c
    trunk/apps/confbridge/conf_state_inactive.c
    trunk/apps/confbridge/conf_state_multi.c
    trunk/apps/confbridge/conf_state_multi_marked.c
    trunk/apps/confbridge/conf_state_single.c
    trunk/apps/confbridge/conf_state_single_marked.c
    trunk/apps/confbridge/include/conf_state.h
    trunk/apps/confbridge/include/confbridge.h

Modified: trunk/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_confbridge.c?view=diff&rev=382764&r1=382763&r2=382764
==============================================================================
--- trunk/apps/app_confbridge.c (original)
+++ trunk/apps/app_confbridge.c Fri Mar  8 18:21:46 2013
@@ -305,10 +305,10 @@
 /*! \brief Container to hold all conference bridges in progress */
 static struct ao2_container *conference_bridges;
 
-static void leave_conference(struct conference_bridge_user *user);
-static int play_sound_number(struct conference_bridge *conference_bridge, int say_number);
-static int execute_menu_entry(struct conference_bridge *conference_bridge,
-	struct conference_bridge_user *conference_bridge_user,
+static void leave_conference(struct confbridge_user *user);
+static int play_sound_number(struct confbridge_conference *conference, int say_number);
+static int execute_menu_entry(struct confbridge_conference *conference,
+	struct confbridge_user *user,
 	struct ast_bridge_channel *bridge_channel,
 	struct conf_menu_entry *menu_entry,
 	struct conf_menu *menu);
@@ -316,15 +316,15 @@
 /*! \brief Hashing function used for conference bridges container */
 static int conference_bridge_hash_cb(const void *obj, const int flags)
 {
-	const struct conference_bridge *conference_bridge = obj;
-	return ast_str_case_hash(conference_bridge->name);
+	const struct confbridge_conference *conference = obj;
+	return ast_str_case_hash(conference->name);
 }
 
 /*! \brief Comparison function used for conference bridges container */
 static int conference_bridge_cmp_cb(void *obj, void *arg, int flags)
 {
-	const struct conference_bridge *conference_bridge0 = obj, *conference_bridge1 = arg;
-	return (!strcasecmp(conference_bridge0->name, conference_bridge1->name) ? CMP_MATCH | CMP_STOP : 0);
+	const struct confbridge_conference *conference0 = obj, *conference1 = arg;
+	return (!strcasecmp(conference0->name, conference1->name) ? CMP_MATCH | CMP_STOP : 0);
 }
 
 const char *conf_get_sound(enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds)
@@ -596,13 +596,13 @@
 	return tmp;
 }
 
-static void set_rec_filename(struct conference_bridge *bridge, struct ast_str **filename, int is_new)
-{
-	char *rec_file = bridge->b_profile.rec_file;
+static void set_rec_filename(struct confbridge_conference *conference, struct ast_str **filename, int is_new)
+{
+	char *rec_file = conference->b_profile.rec_file;
 	time_t now;
 	char *ext;
 
-	if (ast_str_strlen(*filename) && ast_test_flag(&bridge->b_profile, BRIDGE_OPT_RECORD_FILE_APPEND) && !is_new) {
+	if (ast_str_strlen(*filename) && ast_test_flag(&conference->b_profile, BRIDGE_OPT_RECORD_FILE_APPEND) && !is_new) {
 		    return;
 	}
 
@@ -610,7 +610,7 @@
 
 	ast_str_reset(*filename);
 	if (ast_strlen_zero(rec_file)) {
-		ast_str_set(filename, 0, "confbridge-%s-%u.wav", bridge->name, (unsigned int)now);
+		ast_str_set(filename, 0, "confbridge-%s-%u.wav", conference->name, (unsigned int)now);
 	} else {
 		/* insert time before file extension */
 		ext = strrchr(rec_file, '.');
@@ -622,7 +622,7 @@
 		}
 	}
 
-	if (ast_test_flag(&bridge->b_profile, BRIDGE_OPT_RECORD_FILE_APPEND)) {
+	if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_RECORD_FILE_APPEND)) {
 		ast_str_append(filename, 0, ",a");
 	}
 }
@@ -644,69 +644,69 @@
 
 static void *record_thread(void *obj)
 {
-	struct conference_bridge *conference_bridge = obj;
+	struct confbridge_conference *conference = obj;
 	struct ast_app *mixmonapp = pbx_findapp("MixMonitor");
 	struct ast_channel *chan;
 	struct ast_str *filename = ast_str_alloca(PATH_MAX);
 	struct ast_str *orig_rec_file = NULL;
 
-	ast_mutex_lock(&conference_bridge->record_lock);
+	ast_mutex_lock(&conference->record_lock);
 	if (!mixmonapp) {
 		ast_log(LOG_WARNING, "Can not record ConfBridge, MixMonitor app is not installed\n");
-		conference_bridge->record_thread = AST_PTHREADT_NULL;
-		ast_mutex_unlock(&conference_bridge->record_lock);
-		ao2_ref(conference_bridge, -1);
+		conference->record_thread = AST_PTHREADT_NULL;
+		ast_mutex_unlock(&conference->record_lock);
+		ao2_ref(conference, -1);
 		return NULL;
 	}
 
 	/* XXX If we get an EXIT right here, START will essentially be a no-op */
-	while (conference_bridge->record_state != CONF_RECORD_EXIT) {
-		set_rec_filename(conference_bridge, &filename,
-				 is_new_rec_file(conference_bridge->b_profile.rec_file, &orig_rec_file));
-		chan = ast_channel_ref(conference_bridge->record_chan);
+	while (conference->record_state != CONF_RECORD_EXIT) {
+		set_rec_filename(conference, &filename,
+				 is_new_rec_file(conference->b_profile.rec_file, &orig_rec_file));
+		chan = ast_channel_ref(conference->record_chan);
 		ast_answer(chan);
 		pbx_exec(chan, mixmonapp, ast_str_buffer(filename));
-		ast_bridge_join(conference_bridge->bridge, chan, NULL, NULL, NULL);
+		ast_bridge_join(conference->bridge, chan, NULL, NULL, NULL);
 
 		ast_hangup(chan); /* This will eat this thread's reference to the channel as well */
 		/* STOP has been called. Wait for either a START or an EXIT */
-		ast_cond_wait(&conference_bridge->record_cond, &conference_bridge->record_lock);
+		ast_cond_wait(&conference->record_cond, &conference->record_lock);
 	}
 	ast_free(orig_rec_file);
-	ast_mutex_unlock(&conference_bridge->record_lock);
-	ao2_ref(conference_bridge, -1);
+	ast_mutex_unlock(&conference->record_lock);
+	ao2_ref(conference, -1);
 	return NULL;
 }
 
 /*! \brief Returns whether or not conference is being recorded.
- * \param conference_bridge The bridge to check for recording
+ * \param conference The bridge to check for recording
  * \retval 1, conference is recording.
  * \retval 0, conference is NOT recording.
  */
-static int conf_is_recording(struct conference_bridge *conference_bridge)
-{
-	return conference_bridge->record_state == CONF_RECORD_START;
+static int conf_is_recording(struct confbridge_conference *conference)
+{
+	return conference->record_state == CONF_RECORD_START;
 }
 
 /*! \brief Stop recording a conference bridge
  * \internal
- * \param conference_bridge The conference bridge on which to stop the recording
+ * \param conference The conference bridge on which to stop the recording
  * \retval -1 Failure
  * \retval 0 Success
  */
-static int conf_stop_record(struct conference_bridge *conference_bridge)
+static int conf_stop_record(struct confbridge_conference *conference)
 {
 	struct ast_channel *chan;
-	if (conference_bridge->record_thread == AST_PTHREADT_NULL || !conf_is_recording(conference_bridge)) {
+	if (conference->record_thread == AST_PTHREADT_NULL || !conf_is_recording(conference)) {
 		return -1;
 	}
-	conference_bridge->record_state = CONF_RECORD_STOP;
-	chan = ast_channel_ref(conference_bridge->record_chan);
-	ast_bridge_remove(conference_bridge->bridge, chan);
+	conference->record_state = CONF_RECORD_STOP;
+	chan = ast_channel_ref(conference->record_chan);
+	ast_bridge_remove(conference->bridge, chan);
 	ast_queue_frame(chan, &ast_null_frame);
 	chan = ast_channel_unref(chan);
-	ast_test_suite_event_notify("CONF_STOP_RECORD", "Message: stopped conference recording channel\r\nConference: %s", conference_bridge->b_profile.name);
-	send_stop_record_event(conference_bridge->name);
+	ast_test_suite_event_notify("CONF_STOP_RECORD", "Message: stopped conference recording channel\r\nConference: %s", conference->b_profile.name);
+	send_stop_record_event(conference->name);
 
 	return 0;
 }
@@ -715,26 +715,26 @@
  * \internal
  * \brief Stops the confbridge recording thread.
  *
- * \note Must be called with the conference_bridge locked
+ * \note Must be called with the conference locked
  */
-static int conf_stop_record_thread(struct conference_bridge *conference_bridge)
-{
-	if (conference_bridge->record_thread == AST_PTHREADT_NULL) {
+static int conf_stop_record_thread(struct confbridge_conference *conference)
+{
+	if (conference->record_thread == AST_PTHREADT_NULL) {
 		return -1;
 	}
-	conf_stop_record(conference_bridge);
-
-	ast_mutex_lock(&conference_bridge->record_lock);
-	conference_bridge->record_state = CONF_RECORD_EXIT;
-	ast_cond_signal(&conference_bridge->record_cond);
-	ast_mutex_unlock(&conference_bridge->record_lock);
-
-	pthread_join(conference_bridge->record_thread, NULL);
-	conference_bridge->record_thread = AST_PTHREADT_NULL;
+	conf_stop_record(conference);
+
+	ast_mutex_lock(&conference->record_lock);
+	conference->record_state = CONF_RECORD_EXIT;
+	ast_cond_signal(&conference->record_cond);
+	ast_mutex_unlock(&conference->record_lock);
+
+	pthread_join(conference->record_thread, NULL);
+	conference->record_thread = AST_PTHREADT_NULL;
 
 	/* this is the reference given to the channel during the channel alloc */
-	if (conference_bridge->record_chan) {
-		conference_bridge->record_chan = ast_channel_unref(conference_bridge->record_chan);
+	if (conference->record_chan) {
+		conference->record_chan = ast_channel_unref(conference->record_chan);
 	}
 
 	return 0;
@@ -742,18 +742,18 @@
 
 /*! \brief Start recording the conference
  * \internal
- * \note conference_bridge must be locked when calling this function
- * \param conference_bridge The conference bridge to start recording
+ * \note The conference must be locked when calling this function
+ * \param conference The conference bridge to start recording
  * \retval 0 success
  * \rteval non-zero failure
  */
-static int conf_start_record(struct conference_bridge *conference_bridge)
+static int conf_start_record(struct confbridge_conference *conference)
 {
 	struct ast_format_cap *cap;
 	struct ast_format tmpfmt;
 	int cause;
 
-	if (conference_bridge->record_state != CONF_RECORD_STOP) {
+	if (conference->record_state != CONF_RECORD_STOP) {
 		return -1;
 	}
 
@@ -768,45 +768,45 @@
 
 	ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
 
-	if (!(conference_bridge->record_chan = ast_request("ConfBridgeRec", cap, NULL, conference_bridge->name, &cause))) {
+	if (!(conference->record_chan = ast_request("ConfBridgeRec", cap, NULL, conference->name, &cause))) {
 		cap = ast_format_cap_destroy(cap);
 		return -1;
 	}
 
 	cap = ast_format_cap_destroy(cap);
 
-	conference_bridge->record_state = CONF_RECORD_START;
-	ast_mutex_lock(&conference_bridge->record_lock);
-	ast_cond_signal(&conference_bridge->record_cond);
-	ast_mutex_unlock(&conference_bridge->record_lock);
-	ast_test_suite_event_notify("CONF_START_RECORD", "Message: started conference recording channel\r\nConference: %s", conference_bridge->b_profile.name);
-	send_start_record_event(conference_bridge->name);
+	conference->record_state = CONF_RECORD_START;
+	ast_mutex_lock(&conference->record_lock);
+	ast_cond_signal(&conference->record_cond);
+	ast_mutex_unlock(&conference->record_lock);
+	ast_test_suite_event_notify("CONF_START_RECORD", "Message: started conference recording channel\r\nConference: %s", conference->b_profile.name);
+	send_start_record_event(conference->name);
 
 	return 0;
 }
 
 /*! \brief Start the recording thread on a conference bridge
  * \internal
- * \param conference_bridge The conference bridge on which to start the recording thread
+ * \param conference The conference bridge on which to start the recording thread
  * \retval 0 success
  * \retval -1 failure
  */
-static int start_conf_record_thread(struct conference_bridge *conference_bridge)
-{
-	conf_start_record(conference_bridge);
+static int start_conf_record_thread(struct confbridge_conference *conference)
+{
+	conf_start_record(conference);
 
 	/*
 	 * if the thread has already been started, don't start another
 	 */
-	if (conference_bridge->record_thread != AST_PTHREADT_NULL) {
-		return 0;
-	}
-
-	ao2_ref(conference_bridge, +1); /* give the record thread a ref */
-
-	if (ast_pthread_create_background(&conference_bridge->record_thread, NULL, record_thread, conference_bridge)) {
-		ast_log(LOG_WARNING, "Failed to create recording channel for conference %s\n", conference_bridge->name);
-		ao2_ref(conference_bridge, -1); /* error so remove ref */
+	if (conference->record_thread != AST_PTHREADT_NULL) {
+		return 0;
+	}
+
+	ao2_ref(conference, +1); /* give the record thread a ref */
+
+	if (ast_pthread_create_background(&conference->record_thread, NULL, record_thread, conference)) {
+		ast_log(LOG_WARNING, "Failed to create recording channel for conference %s\n", conference->name);
+		ao2_ref(conference, -1); /* error so remove ref */
 		return -1;
 	}
 
@@ -833,52 +833,52 @@
 /*!
  * \brief Announce number of users in the conference bridge to the caller
  *
- * \param conference_bridge Conference bridge to peek at
- * \param conference_bridge_user Optional Caller
+ * \param conference Conference bridge to peek at
+ * \param user Optional Caller
  *
  * \note if caller is NULL, the announcment will be sent to all participants in the conference.
  * \return Returns 0 on success, -1 if the user hung up
  */
-static int announce_user_count(struct conference_bridge *conference_bridge, struct conference_bridge_user *conference_bridge_user)
-{
-	const char *other_in_party = conf_get_sound(CONF_SOUND_OTHER_IN_PARTY, conference_bridge->b_profile.sounds);
-	const char *only_one = conf_get_sound(CONF_SOUND_ONLY_ONE, conference_bridge->b_profile.sounds);
-	const char *there_are = conf_get_sound(CONF_SOUND_THERE_ARE, conference_bridge->b_profile.sounds);
-
-	if (conference_bridge->activeusers <= 1) {
+static int announce_user_count(struct confbridge_conference *conference, struct confbridge_user *user)
+{
+	const char *other_in_party = conf_get_sound(CONF_SOUND_OTHER_IN_PARTY, conference->b_profile.sounds);
+	const char *only_one = conf_get_sound(CONF_SOUND_ONLY_ONE, conference->b_profile.sounds);
+	const char *there_are = conf_get_sound(CONF_SOUND_THERE_ARE, conference->b_profile.sounds);
+
+	if (conference->activeusers <= 1) {
 		/* Awww we are the only person in the conference bridge OR we only have waitmarked users */
 		return 0;
-	} else if (conference_bridge->activeusers == 2) {
-		if (conference_bridge_user) {
+	} else if (conference->activeusers == 2) {
+		if (user) {
 			/* Eep, there is one other person */
-			if (ast_stream_and_wait(conference_bridge_user->chan,
+			if (ast_stream_and_wait(user->chan,
 				only_one,
 				"")) {
 				return -1;
 			}
 		} else {
-			play_sound_file(conference_bridge, only_one);
+			play_sound_file(conference, only_one);
 		}
 	} else {
 		/* Alas multiple others in here */
-		if (conference_bridge_user) {
-			if (ast_stream_and_wait(conference_bridge_user->chan,
+		if (user) {
+			if (ast_stream_and_wait(user->chan,
 				there_are,
 				"")) {
 				return -1;
 			}
-			if (ast_say_number(conference_bridge_user->chan, conference_bridge->activeusers - 1, "", ast_channel_language(conference_bridge_user->chan), NULL)) {
+			if (ast_say_number(user->chan, conference->activeusers - 1, "", ast_channel_language(user->chan), NULL)) {
 				return -1;
 			}
-			if (ast_stream_and_wait(conference_bridge_user->chan,
+			if (ast_stream_and_wait(user->chan,
 				other_in_party,
 				"")) {
 				return -1;
 			}
 		} else if (sound_file_exists(there_are) && sound_file_exists(other_in_party)) {
-			play_sound_file(conference_bridge, there_are);
-			play_sound_number(conference_bridge, conference_bridge->activeusers - 1);
-			play_sound_file(conference_bridge, other_in_party);
+			play_sound_file(conference, there_are);
+			play_sound_number(conference, conference->activeusers - 1);
+			play_sound_file(conference, other_in_party);
 		}
 	}
 	return 0;
@@ -887,7 +887,7 @@
 /*!
  * \brief Play back an audio file to a channel
  *
- * \param cbu User to play audio prompt to
+ * \param user User to play audio prompt to
  * \param filename Prompt to play
  *
  * \return Returns 0 on success, -1 if the user hung up
@@ -895,78 +895,79 @@
  * the entire conference while the sound is played. But don't unlock the conference bridge
  * in the middle of a state transition.
  */
-static int play_prompt_to_user(struct conference_bridge_user *cbu, const char *filename)
-{
-	return ast_stream_and_wait(cbu->chan, filename, "");
-}
-
-static void handle_video_on_join(struct conference_bridge *conference_bridge, struct ast_channel *chan, int marked)
+static int play_prompt_to_user(struct confbridge_user *user, const char *filename)
+{
+	return ast_stream_and_wait(user->chan, filename, "");
+}
+
+static void handle_video_on_join(struct confbridge_conference *conference, struct ast_channel *chan, int marked)
 {
 	/* Right now, only marked users are automatically set as the single src of video.*/
 	if (!marked) {
 		return;
 	}
 
-	if (ast_test_flag(&conference_bridge->b_profile, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED)) {
+	if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED)) {
 		int set = 1;
-		struct conference_bridge_user *tmp_user = NULL;
-		ao2_lock(conference_bridge);
+		struct confbridge_user *user = NULL;
+
+		ao2_lock(conference);
 		/* see if anyone is already the video src */
-		AST_LIST_TRAVERSE(&conference_bridge->active_list, tmp_user, list) {
-			if (tmp_user->chan == chan) {
+		AST_LIST_TRAVERSE(&conference->active_list, user, list) {
+			if (user->chan == chan) {
 				continue;
 			}
-			if (ast_bridge_is_video_src(conference_bridge->bridge, tmp_user->chan)) {
+			if (ast_bridge_is_video_src(conference->bridge, user->chan)) {
 				set = 0;
 				break;
 			}
 		}
-		ao2_unlock(conference_bridge);
+		ao2_unlock(conference);
 		if (set) {
-			ast_bridge_set_single_src_video_mode(conference_bridge->bridge, chan);
-		}
-	} else if (ast_test_flag(&conference_bridge->b_profile, BRIDGE_OPT_VIDEO_SRC_LAST_MARKED)) {
+			ast_bridge_set_single_src_video_mode(conference->bridge, chan);
+		}
+	} else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_VIDEO_SRC_LAST_MARKED)) {
 		/* we joined and are video capable, we override anyone else that may have already been the video feed */
-		ast_bridge_set_single_src_video_mode(conference_bridge->bridge, chan);
-	}
-}
-
-static void handle_video_on_exit(struct conference_bridge *conference_bridge, struct ast_channel *chan)
-{
-	struct conference_bridge_user *tmp_user = NULL;
+		ast_bridge_set_single_src_video_mode(conference->bridge, chan);
+	}
+}
+
+static void handle_video_on_exit(struct confbridge_conference *conference, struct ast_channel *chan)
+{
+	struct confbridge_user *user = NULL;
 
 	/* if this isn't a video source, nothing to update */
-	if (!ast_bridge_is_video_src(conference_bridge->bridge, chan)) {
+	if (!ast_bridge_is_video_src(conference->bridge, chan)) {
 		return;
 	}
 
-	ast_bridge_remove_video_src(conference_bridge->bridge, chan);
+	ast_bridge_remove_video_src(conference->bridge, chan);
 
 	/* If in follow talker mode, make sure to restore this mode on the
 	 * bridge when a source is removed.  It is possible this channel was
 	 * only set temporarily as a video source by an AMI or DTMF action. */
-	if (ast_test_flag(&conference_bridge->b_profile, BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER)) {
-		ast_bridge_set_talker_src_video_mode(conference_bridge->bridge);
+	if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER)) {
+		ast_bridge_set_talker_src_video_mode(conference->bridge);
 	}
 
 	/* if the video_mode isn't set to automatically pick the video source, do nothing on exit. */
-	if (!ast_test_flag(&conference_bridge->b_profile, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED) &&
-		!ast_test_flag(&conference_bridge->b_profile, BRIDGE_OPT_VIDEO_SRC_LAST_MARKED)) {
+	if (!ast_test_flag(&conference->b_profile, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED) &&
+		!ast_test_flag(&conference->b_profile, BRIDGE_OPT_VIDEO_SRC_LAST_MARKED)) {
 		return;
 	}
 
 	/* Make the next available marked user the video src.  */
-	ao2_lock(conference_bridge);
-	AST_LIST_TRAVERSE(&conference_bridge->active_list, tmp_user, list) {
-		if (tmp_user->chan == chan) {
+	ao2_lock(conference);
+	AST_LIST_TRAVERSE(&conference->active_list, user, list) {
+		if (user->chan == chan) {
 			continue;
 		}
-		if (ast_test_flag(&tmp_user->u_profile, USER_OPT_MARKEDUSER)) {
-			ast_bridge_set_single_src_video_mode(conference_bridge->bridge, tmp_user->chan);
+		if (ast_test_flag(&user->u_profile, USER_OPT_MARKEDUSER)) {
+			ast_bridge_set_single_src_video_mode(conference->bridge, user->chan);
 			break;
 		}
 	}
-	ao2_unlock(conference_bridge);
+	ao2_unlock(conference);
 }
 
 /*!
@@ -978,75 +979,75 @@
  */
 static void destroy_conference_bridge(void *obj)
 {
-	struct conference_bridge *conference_bridge = obj;
-
-	ast_debug(1, "Destroying conference bridge '%s'\n", conference_bridge->name);
-
-	if (conference_bridge->playback_chan) {
-		struct ast_channel *underlying_channel = ast_channel_tech(conference_bridge->playback_chan)->bridged_channel(conference_bridge->playback_chan, NULL);
+	struct confbridge_conference *conference = obj;
+
+	ast_debug(1, "Destroying conference bridge '%s'\n", conference->name);
+
+	if (conference->playback_chan) {
+		struct ast_channel *underlying_channel = ast_channel_tech(conference->playback_chan)->bridged_channel(conference->playback_chan, NULL);
 		if (underlying_channel) {
 			ast_hangup(underlying_channel);
 		}
-		ast_hangup(conference_bridge->playback_chan);
-		conference_bridge->playback_chan = NULL;
+		ast_hangup(conference->playback_chan);
+		conference->playback_chan = NULL;
 	}
 
 	/* Destroying a conference bridge is simple, all we have to do is destroy the bridging object */
-	if (conference_bridge->bridge) {
-		ast_bridge_destroy(conference_bridge->bridge);
-		conference_bridge->bridge = NULL;
-	}
-
-	conf_bridge_profile_destroy(&conference_bridge->b_profile);
-	ast_cond_destroy(&conference_bridge->record_cond);
-	ast_mutex_destroy(&conference_bridge->record_lock);
-	ast_mutex_destroy(&conference_bridge->playback_lock);
+	if (conference->bridge) {
+		ast_bridge_destroy(conference->bridge);
+		conference->bridge = NULL;
+	}
+
+	conf_bridge_profile_destroy(&conference->b_profile);
+	ast_cond_destroy(&conference->record_cond);
+	ast_mutex_destroy(&conference->record_lock);
+	ast_mutex_destroy(&conference->playback_lock);
 }
 
 /*! \brief Call the proper join event handler for the user for the conference bridge's current state
  * \internal
- * \param cbu The conference bridge user that is joining
+ * \param user The conference bridge user that is joining
  * \retval 0 success
  * \retval -1 failure
  */
-static int handle_conf_user_join(struct conference_bridge_user *cbu)
+static int handle_conf_user_join(struct confbridge_user *user)
 {
 	conference_event_fn handler;
-	if (ast_test_flag(&cbu->u_profile, USER_OPT_MARKEDUSER)) {
-		handler = cbu->conference_bridge->state->join_marked;
-	} else if (ast_test_flag(&cbu->u_profile, USER_OPT_WAITMARKED)) {
-		handler = cbu->conference_bridge->state->join_waitmarked;
+	if (ast_test_flag(&user->u_profile, USER_OPT_MARKEDUSER)) {
+		handler = user->conference->state->join_marked;
+	} else if (ast_test_flag(&user->u_profile, USER_OPT_WAITMARKED)) {
+		handler = user->conference->state->join_waitmarked;
 	} else {
-		handler = cbu->conference_bridge->state->join_unmarked;
+		handler = user->conference->state->join_unmarked;
 	}
 
 	ast_assert(handler != NULL);
 
 	if (!handler) {
-		conf_invalid_event_fn(cbu);
+		conf_invalid_event_fn(user);
 		return -1;
 	}
 
-	handler(cbu);
+	handler(user);
 
 	return 0;
 }
 
 /*! \brief Call the proper leave event handler for the user for the conference bridge's current state
  * \internal
- * \param cbu The conference bridge user that is leaving
+ * \param user The conference bridge user that is leaving
  * \retval 0 success
  * \retval -1 failure
  */
-static int handle_conf_user_leave(struct conference_bridge_user *cbu)
+static int handle_conf_user_leave(struct confbridge_user *user)
 {
 	conference_event_fn handler;
-	if (ast_test_flag(&cbu->u_profile, USER_OPT_MARKEDUSER)) {
-		handler = cbu->conference_bridge->state->leave_marked;
-	} else if (ast_test_flag(&cbu->u_profile, USER_OPT_WAITMARKED)) {
-		handler = cbu->conference_bridge->state->leave_waitmarked;
+	if (ast_test_flag(&user->u_profile, USER_OPT_MARKEDUSER)) {
+		handler = user->conference->state->leave_marked;
+	} else if (ast_test_flag(&user->u_profile, USER_OPT_WAITMARKED)) {
+		handler = user->conference->state->leave_waitmarked;
 	} else {
-		handler = cbu->conference_bridge->state->leave_unmarked;
+		handler = user->conference->state->leave_unmarked;
 	}
 
 	ast_assert(handler != NULL);
@@ -1055,16 +1056,16 @@
 		/* This should never happen. If it does, though, it is bad. The user will not have been removed
 		 * from the appropriate list, so counts will be off and stuff. The conference won't be torn down, etc.
 		 * Shouldn't happen, though. */
-		conf_invalid_event_fn(cbu);
+		conf_invalid_event_fn(user);
 		return -1;
 	}
 
-	handler(cbu);
+	handler(user);
 
 	return 0;
 }
 
-void conf_moh_stop(struct conference_bridge_user *user)
+void conf_moh_stop(struct confbridge_user *user)
 {
 	user->playing_moh = 0;
 	if (!user->suspended_moh) {
@@ -1075,23 +1076,23 @@
 		 * call to ast_bridge_join() in confbridge_exec() from
 		 * interfering with the bridge and MOH operations here.
 		 */
-		ast_bridge_lock(user->conference_bridge->bridge);
+		ast_bridge_lock(user->conference->bridge);
 
 		/*
 		 * Temporarily suspend the user from the bridge so we have
 		 * control to stop MOH if needed.
 		 */
-		in_bridge = !ast_bridge_suspend(user->conference_bridge->bridge, user->chan);
+		in_bridge = !ast_bridge_suspend(user->conference->bridge, user->chan);
 		ast_moh_stop(user->chan);
 		if (in_bridge) {
-			ast_bridge_unsuspend(user->conference_bridge->bridge, user->chan);
-		}
-
-		ast_bridge_unlock(user->conference_bridge->bridge);
-	}
-}
-
-void conf_moh_start(struct conference_bridge_user *user)
+			ast_bridge_unsuspend(user->conference->bridge, user->chan);
+		}
+
+		ast_bridge_unlock(user->conference->bridge);
+	}
+}
+
+void conf_moh_start(struct confbridge_user *user)
 {
 	user->playing_moh = 1;
 	if (!user->suspended_moh) {
@@ -1102,19 +1103,19 @@
 		 * call to ast_bridge_join() in confbridge_exec() from
 		 * interfering with the bridge and MOH operations here.
 		 */
-		ast_bridge_lock(user->conference_bridge->bridge);
+		ast_bridge_lock(user->conference->bridge);
 
 		/*
 		 * Temporarily suspend the user from the bridge so we have
 		 * control to start MOH if needed.
 		 */
-		in_bridge = !ast_bridge_suspend(user->conference_bridge->bridge, user->chan);
+		in_bridge = !ast_bridge_suspend(user->conference->bridge, user->chan);
 		ast_moh_start(user->chan, user->u_profile.moh_class, NULL);
 		if (in_bridge) {
-			ast_bridge_unsuspend(user->conference_bridge->bridge, user->chan);
-		}
-
-		ast_bridge_unlock(user->conference_bridge->bridge);
+			ast_bridge_unsuspend(user->conference->bridge, user->chan);
+		}
+
+		ast_bridge_unlock(user->conference->bridge);
 	}
 }
 
@@ -1126,13 +1127,13 @@
  *
  * \return Nothing
  */
-static void conf_moh_unsuspend(struct conference_bridge_user *user)
-{
-	ao2_lock(user->conference_bridge);
+static void conf_moh_unsuspend(struct confbridge_user *user)
+{
+	ao2_lock(user->conference);
 	if (--user->suspended_moh == 0 && user->playing_moh) {
 		ast_moh_start(user->chan, user->u_profile.moh_class, NULL);
 	}
-	ao2_unlock(user->conference_bridge);
+	ao2_unlock(user->conference);
 }
 
 /*!
@@ -1143,40 +1144,40 @@
  *
  * \return Nothing
  */
-static void conf_moh_suspend(struct conference_bridge_user *user)
-{
-	ao2_lock(user->conference_bridge);
+static void conf_moh_suspend(struct confbridge_user *user)
+{
+	ao2_lock(user->conference);
 	if (user->suspended_moh++ == 0 && user->playing_moh) {
 		ast_moh_stop(user->chan);
 	}
-	ao2_unlock(user->conference_bridge);
-}
-
-int conf_handle_first_marked_common(struct conference_bridge_user *cbu)
-{
-	if (!ast_test_flag(&cbu->u_profile, USER_OPT_QUIET) && play_prompt_to_user(cbu, conf_get_sound(CONF_SOUND_PLACE_IN_CONF, cbu->b_profile.sounds))) {
+	ao2_unlock(user->conference);
+}
+
+int conf_handle_first_marked_common(struct confbridge_user *user)
+{
+	if (!ast_test_flag(&user->u_profile, USER_OPT_QUIET) && play_prompt_to_user(user, conf_get_sound(CONF_SOUND_PLACE_IN_CONF, user->b_profile.sounds))) {
 		return -1;
 	}
 	return 0;
 }
 
-int conf_handle_inactive_waitmarked(struct conference_bridge_user *cbu)
+int conf_handle_inactive_waitmarked(struct confbridge_user *user)
 {
 	/* If we have not been quieted play back that they are waiting for the leader */
-	if (!ast_test_flag(&cbu->u_profile, USER_OPT_QUIET) && play_prompt_to_user(cbu,
-			conf_get_sound(CONF_SOUND_WAIT_FOR_LEADER, cbu->b_profile.sounds))) {
+	if (!ast_test_flag(&user->u_profile, USER_OPT_QUIET) && play_prompt_to_user(user,
+			conf_get_sound(CONF_SOUND_WAIT_FOR_LEADER, user->b_profile.sounds))) {
 		/* user hungup while the sound was playing */
 		return -1;
 	}
 	return 0;
 }
 
-int conf_handle_only_unmarked(struct conference_bridge_user *cbu)
+int conf_handle_only_unmarked(struct confbridge_user *user)
 {
 	/* If audio prompts have not been quieted or this prompt quieted play it on out */
-	if (!ast_test_flag(&cbu->u_profile, USER_OPT_QUIET | USER_OPT_NOONLYPERSON)) {
-		if (play_prompt_to_user(cbu,
-			conf_get_sound(CONF_SOUND_ONLY_PERSON, cbu->b_profile.sounds))) {
+	if (!ast_test_flag(&user->u_profile, USER_OPT_QUIET | USER_OPT_NOONLYPERSON)) {
+		if (play_prompt_to_user(user,
+			conf_get_sound(CONF_SOUND_ONLY_PERSON, user->b_profile.sounds))) {
 			/* user hungup while the sound was playing */
 			return -1;
 		}
@@ -1184,217 +1185,217 @@
 	return 0;
 }
 
-int conf_add_post_join_action(struct conference_bridge_user *cbu, int (*func)(struct conference_bridge_user *cbu))
+int conf_add_post_join_action(struct confbridge_user *user, int (*func)(struct confbridge_user *user))
 {
 	struct post_join_action *action;
 	if (!(action = ast_calloc(1, sizeof(*action)))) {
 		return -1;
 	}
 	action->func = func;
-	AST_LIST_INSERT_TAIL(&cbu->post_join_list, action, list);
+	AST_LIST_INSERT_TAIL(&user->post_join_list, action, list);
 	return 0;
 }
 
 
-void conf_handle_first_join(struct conference_bridge *conference_bridge)
-{
-	ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "confbridge:%s", conference_bridge->name);
-}
-
-void conf_handle_second_active(struct conference_bridge *conference_bridge)
+void conf_handle_first_join(struct confbridge_conference *conference)
+{
+	ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "confbridge:%s", conference->name);
+}
+
+void conf_handle_second_active(struct confbridge_conference *conference)
 {
 	/* If we are the second participant we may need to stop music on hold on the first */
-	struct conference_bridge_user *first_participant = AST_LIST_FIRST(&conference_bridge->active_list);
-
-	if (ast_test_flag(&first_participant->u_profile, USER_OPT_MUSICONHOLD)) {
-		conf_moh_stop(first_participant);
-	}
-	if (!ast_test_flag(&first_participant->u_profile, USER_OPT_STARTMUTED)) {
-		first_participant->features.mute = 0;
-	}
-}
-
-void conf_ended(struct conference_bridge *conference_bridge)
-{
-	/* Called with a reference to conference_bridge */
-	ao2_unlink(conference_bridges, conference_bridge);
-	send_conf_end_event(conference_bridge->name);
-	conf_stop_record_thread(conference_bridge);
+	struct confbridge_user *first_user = AST_LIST_FIRST(&conference->active_list);
+
+	if (ast_test_flag(&first_user->u_profile, USER_OPT_MUSICONHOLD)) {
+		conf_moh_stop(first_user);
+	}
+	if (!ast_test_flag(&first_user->u_profile, USER_OPT_STARTMUTED)) {
+		first_user->features.mute = 0;
+	}
+}
+
+void conf_ended(struct confbridge_conference *conference)
+{
+	/* Called with a reference to conference */
+	ao2_unlink(conference_bridges, conference);
+	send_conf_end_event(conference->name);
+	conf_stop_record_thread(conference);
 }
 
 /*!
  * \brief Join a conference bridge
  *
- * \param name The conference name
- * \param conference_bridge_user Conference bridge user structure
+ * \param conference_name The conference name
+ * \param user Conference bridge user structure
  *
  * \return A pointer to the conference bridge struct, or NULL if the conference room wasn't found.
  */
-static struct conference_bridge *join_conference_bridge(const char *name, struct conference_bridge_user *conference_bridge_user)
-{
-	struct conference_bridge *conference_bridge = NULL;
+static struct confbridge_conference *join_conference_bridge(const char *conference_name, struct confbridge_user *user)
+{
+	struct confbridge_conference *conference = NULL;
 	struct post_join_action *action;
-	struct conference_bridge tmp;
+	struct confbridge_conference tmp;
 	int max_members_reached = 0;
 
-	ast_copy_string(tmp.name, name, sizeof(tmp.name));
+	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
 
 	/* We explictly lock the conference bridges container ourselves so that other callers can not create duplicate conferences at the same */
 	ao2_lock(conference_bridges);
 
-	ast_debug(1, "Trying to find conference bridge '%s'\n", name);
+	ast_debug(1, "Trying to find conference bridge '%s'\n", conference_name);
 
 	/* Attempt to find an existing conference bridge */
-	conference_bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
-
-	if (conference_bridge && conference_bridge->b_profile.max_members) {
-		max_members_reached = conference_bridge->b_profile.max_members > conference_bridge->activeusers ? 0 : 1;
+	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+
+	if (conference && conference->b_profile.max_members) {
+		max_members_reached = conference->b_profile.max_members > conference->activeusers ? 0 : 1;
 	}
 
 	/* When finding a conference bridge that already exists make sure that it is not locked, and if so that we are not an admin */
-	if (conference_bridge && (max_members_reached || conference_bridge->locked) && !ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ADMIN)) {
+	if (conference && (max_members_reached || conference->locked) && !ast_test_flag(&user->u_profile, USER_OPT_ADMIN)) {
 		ao2_unlock(conference_bridges);
-		ao2_ref(conference_bridge, -1);
-		ast_debug(1, "Conference '%s' is locked and caller is not an admin\n", name);
-		ast_stream_and_wait(conference_bridge_user->chan,
-				conf_get_sound(CONF_SOUND_LOCKED, conference_bridge_user->b_profile.sounds),
+		ao2_ref(conference, -1);
+		ast_debug(1, "Conference '%s' is locked and caller is not an admin\n", conference_name);
+		ast_stream_and_wait(user->chan,
+				conf_get_sound(CONF_SOUND_LOCKED, user->b_profile.sounds),
 				"");
 		return NULL;
 	}
 
 	/* If no conference bridge was found see if we can create one */
-	if (!conference_bridge) {
+	if (!conference) {
 		/* Try to allocate memory for a new conference bridge, if we fail... this won't end well. */
-		if (!(conference_bridge = ao2_alloc(sizeof(*conference_bridge), destroy_conference_bridge))) {
+		if (!(conference = ao2_alloc(sizeof(*conference), destroy_conference_bridge))) {
 			ao2_unlock(conference_bridges);
-			ast_log(LOG_ERROR, "Conference '%s' could not be created.\n", name);
+			ast_log(LOG_ERROR, "Conference '%s' could not be created.\n", conference_name);
 			return NULL;
 		}
 
 		/* Setup lock for playback channel */
-		ast_mutex_init(&conference_bridge->playback_lock);
+		ast_mutex_init(&conference->playback_lock);
 
 		/* Setup lock for the record channel */
-		ast_mutex_init(&conference_bridge->record_lock);
-		ast_cond_init(&conference_bridge->record_cond, NULL);
+		ast_mutex_init(&conference->record_lock);
+		ast_cond_init(&conference->record_cond, NULL);
 
 		/* Setup conference bridge parameters */
-		conference_bridge->record_thread = AST_PTHREADT_NULL;
-		ast_copy_string(conference_bridge->name, name, sizeof(conference_bridge->name));
-		conf_bridge_profile_copy(&conference_bridge->b_profile, &conference_bridge_user->b_profile);
+		conference->record_thread = AST_PTHREADT_NULL;
+		ast_copy_string(conference->name, conference_name, sizeof(conference->name));
+		conf_bridge_profile_copy(&conference->b_profile, &user->b_profile);
 
 		/* Create an actual bridge that will do the audio mixing */
-		if (!(conference_bridge->bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_MULTIMIX, 0))) {
-			ao2_ref(conference_bridge, -1);
-			conference_bridge = NULL;
+		if (!(conference->bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_MULTIMIX, 0))) {
+			ao2_ref(conference, -1);
+			conference = NULL;
 			ao2_unlock(conference_bridges);
-			ast_log(LOG_ERROR, "Conference '%s' mixing bridge could not be created.\n", name);
+			ast_log(LOG_ERROR, "Conference '%s' mixing bridge could not be created.\n", conference_name);
 			return NULL;
 		}
 
 		/* Set the internal sample rate on the bridge from the bridge profile */
-		ast_bridge_set_internal_sample_rate(conference_bridge->bridge, conference_bridge->b_profile.internal_sample_rate);
+		ast_bridge_set_internal_sample_rate(conference->bridge, conference->b_profile.internal_sample_rate);
 		/* Set the internal mixing interval on the bridge from the bridge profile */
-		ast_bridge_set_mixing_interval(conference_bridge->bridge, conference_bridge->b_profile.mix_interval);
-
-		if (ast_test_flag(&conference_bridge->b_profile, BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER)) {
-			ast_bridge_set_talker_src_video_mode(conference_bridge->bridge);
+		ast_bridge_set_mixing_interval(conference->bridge, conference->b_profile.mix_interval);
+
+		if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER)) {
+			ast_bridge_set_talker_src_video_mode(conference->bridge);
 		}
 
 		/* Link it into the conference bridges container */
-		if (!ao2_link(conference_bridges, conference_bridge)) {
-			ao2_ref(conference_bridge, -1);
-			conference_bridge = NULL;
+		if (!ao2_link(conference_bridges, conference)) {
+			ao2_ref(conference, -1);
+			conference = NULL;
 			ao2_unlock(conference_bridges);
 			ast_log(LOG_ERROR,
-				"Conference '%s' could not be added to the conferences list.\n", name);
+				"Conference '%s' could not be added to the conferences list.\n", conference_name);
 			return NULL;
 		}
 
 		/* Set the initial state to EMPTY */
-		conference_bridge->state = CONF_STATE_EMPTY;
-
-		conference_bridge->record_state = CONF_RECORD_STOP;
-		if (ast_test_flag(&conference_bridge->b_profile, BRIDGE_OPT_RECORD_CONFERENCE)) {
-			ao2_lock(conference_bridge);
-			start_conf_record_thread(conference_bridge);
-			ao2_unlock(conference_bridge);
-		}
-
-		send_conf_start_event(conference_bridge->name);
-		ast_debug(1, "Created conference '%s' and linked to container.\n", name);
+		conference->state = CONF_STATE_EMPTY;
+
+		conference->record_state = CONF_RECORD_STOP;

[... 2884 lines stripped ...]



More information about the asterisk-commits mailing list