[Asterisk-code-review] Binaural synthesis (confbridge): DTFM conference management. (asterisk[master])

Frank Haase asteriskteam at digium.com
Fri Aug 12 11:33:28 CDT 2016


Frank Haase has uploaded a new change for review.

  https://gerrit.asterisk.org/3525

Change subject: Binaural synthesis (confbridge): DTFM conference management.
......................................................................

Binaural synthesis (confbridge): DTFM conference management.

DTFM configuration options for the binaural softmix bridge:
* toggle binaural rendering (per channel), and
* randomly reposition all participants in the conference (all channels).

ASTERISK-26292

Change-Id: Ibfe708b9fe26097c1798fcbfcc4dc461267d8af8
---
M apps/app_confbridge.c
M apps/confbridge/conf_config_parser.c
M apps/confbridge/include/confbridge.h
3 files changed, 75 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/25/3525/1

diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c
index 93c6b2b..65f332f 100644
--- a/apps/app_confbridge.c
+++ b/apps/app_confbridge.c
@@ -439,6 +439,12 @@
 		return S_OR(custom_sounds->muted, "conf-muted");
 	case CONF_SOUND_UNMUTED:
 		return S_OR(custom_sounds->unmuted, "conf-unmuted");
+	case CONF_SOUND_BINAURAL_ON:
+		return S_OR(custom_sounds->binauralon, "confbridge-binaural-on");
+	case CONF_SOUND_BINAURAL_OFF:
+		return S_OR(custom_sounds->binauraloff, "confbridge-binaural-off");
+	case CONF_SOUND_RANDOM_POS:
+		return S_OR(custom_sounds->randompos, "confbridge-switching-positions");
 	case CONF_SOUND_ONLY_ONE:
 		return S_OR(custom_sounds->onlyone, "conf-onlyone");
 	case CONF_SOUND_THERE_ARE:
@@ -1980,6 +1986,40 @@
 			conference->b_profile.sounds)) < 0;
 }
 
+static int action_toggle_binaural(struct confbridge_conference *conference,
+		struct confbridge_user *user, 
+		struct ast_bridge_channel *bridge_channel) 
+{
+	unsigned int binaural;
+	ast_bridge_channel_lock_bridge(bridge_channel);
+	binaural = !bridge_channel->binaural_suspended;
+	bridge_channel->binaural_suspended = binaural;
+	ast_bridge_unlock(bridge_channel->bridge);
+	return play_file(bridge_channel, NULL, (binaural ?
+				conf_get_sound(CONF_SOUND_BINAURAL_OFF, user->b_profile.sounds) :
+				conf_get_sound(CONF_SOUND_BINAURAL_ON, user->b_profile.sounds))) < 0;
+}
+
+static int action_random_pos(struct confbridge_conference *conference,
+		struct confbridge_user *user, 
+		struct ast_bridge_channel *bridge_channel) 
+{
+	/* The action is only allowed for admin users! */
+	/* An announcement will be played for each user in the conference. */
+	if (ast_test_flag(&user->u_profile, USER_OPT_ADMIN)) {
+		const char *sound_to_play;
+		sound_to_play = conf_get_sound(CONF_SOUND_RANDOM_POS,user->b_profile.sounds);
+		ast_stream_and_wait(user->chan, sound_to_play, "");
+		ast_autoservice_start(user->chan);
+		play_sound_helper(conference, sound_to_play, 0);
+		ast_autoservice_stop(user->chan);
+		ast_bridge_channel_lock_bridge(bridge_channel);
+		bridge_channel->binaural_pos_change = 1;
+		ast_bridge_unlock(bridge_channel->bridge);
+	}
+	return 0;
+}
+
 static int action_toggle_mute_participants(struct confbridge_conference *conference, struct confbridge_user *user)
 {
 	struct confbridge_user *cur_user = NULL;
@@ -2193,6 +2233,12 @@
 		case MENU_ACTION_TOGGLE_MUTE:
 			res |= action_toggle_mute(conference, user, bridge_channel);
 			break;
+		case MENU_ACTION_TOGGLE_BINAURAL:
+			action_toggle_binaural(conference, user, bridge_channel);
+			break;
+		case MENU_ACTION_RANDOM_POS:
+			action_random_pos(conference, user, bridge_channel);
+			break;
 		case MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS:
 			if (!isadmin) {
 				break;
diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c
index 489deb0..b353652 100644
--- a/apps/confbridge/conf_config_parser.c
+++ b/apps/confbridge/conf_config_parser.c
@@ -917,6 +917,12 @@
 		ast_string_field_set(sounds, muted, sound_file);
 	} else if (!strcasecmp(sound_name, "sound_unmuted")) {
 		ast_string_field_set(sounds, unmuted, sound_file);
+	} else if (!strcasecmp(sound_name, "sound_binaural_on")) {
+		ast_string_field_set(sounds, binauralon, sound_file);
+	} else if (!strcasecmp(sound_name, "sound_binaural_off")) {
+		ast_string_field_set(sounds, binauraloff, sound_file);
+	} else if (!strcasecmp(sound_name, "random_pos")) {
+		ast_string_field_set(sounds, randompos, sound_file);
 	} else if (!strcasecmp(sound_name, "sound_there_are")) {
 		ast_string_field_set(sounds, thereare, sound_file);
 	} else if (!strcasecmp(sound_name, "sound_other_in_party")) {
@@ -1142,6 +1148,8 @@
 	switch (id) {
 	case MENU_ACTION_NOOP:
 	case MENU_ACTION_TOGGLE_MUTE:
+	case MENU_ACTION_TOGGLE_BINAURAL:
+	case MENU_ACTION_RANDOM_POS:
 	case MENU_ACTION_INCREASE_LISTENING:
 	case MENU_ACTION_DECREASE_LISTENING:
 	case MENU_ACTION_INCREASE_TALKING:
@@ -1250,6 +1258,10 @@
 		ast_copy_string(menu_entry->dtmf, dtmf, sizeof(menu_entry->dtmf));
 		if (!strcasecmp(action, "toggle_mute")) {
 			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_TOGGLE_MUTE, NULL);
+		} else if (!strcasecmp(action, "toggle_binaural")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_TOGGLE_BINAURAL, NULL);
+		} else if (!strcasecmp(action, "random_pos")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RANDOM_POS, NULL);	
 		} else if (!strcasecmp(action, "no_op")) {
 			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_NOOP, NULL);
 		} else if (!strcasecmp(action, "increase_listening_volume")) {
@@ -1648,6 +1660,9 @@
 	ast_cli(a->fd,"sound_kicked:         %s\n", conf_get_sound(CONF_SOUND_KICKED, b_profile.sounds));
 	ast_cli(a->fd,"sound_muted:          %s\n", conf_get_sound(CONF_SOUND_MUTED, b_profile.sounds));
 	ast_cli(a->fd,"sound_unmuted:        %s\n", conf_get_sound(CONF_SOUND_UNMUTED, b_profile.sounds));
+	ast_cli(a->fd,"binaural_on:          %s\n", conf_get_sound(CONF_SOUND_BINAURAL_ON, b_profile.sounds));
+	ast_cli(a->fd,"binaural_off:         %s\n", conf_get_sound(CONF_SOUND_BINAURAL_OFF, b_profile.sounds));
+	ast_cli(a->fd,"random_pos:           %s\n", conf_get_sound(CONF_SOUND_RANDOM_POS, b_profile.sounds));
 	ast_cli(a->fd,"sound_there_are:      %s\n", conf_get_sound(CONF_SOUND_THERE_ARE, b_profile.sounds));
 	ast_cli(a->fd,"sound_other_in_party: %s\n", conf_get_sound(CONF_SOUND_OTHER_IN_PARTY, b_profile.sounds));
 	ast_cli(a->fd,"sound_place_into_conference: %s\n", conf_get_sound(CONF_SOUND_PLACE_IN_CONF, b_profile.sounds));
@@ -1776,6 +1791,12 @@
 			case MENU_ACTION_TOGGLE_MUTE:
 				ast_cli(a->fd, "toggle_mute");
 				break;
+			case MENU_ACTION_TOGGLE_BINAURAL:
+				ast_cli(a->fd, "toggle_binaural");
+				break;
+			case MENU_ACTION_RANDOM_POS:
+				ast_cli(a->fd, "random_pos");
+				break;
 			case MENU_ACTION_NOOP:
 				ast_cli(a->fd, "no_op");
 				break;
diff --git a/apps/confbridge/include/confbridge.h b/apps/confbridge/include/confbridge.h
index 735bc50..108d607 100644
--- a/apps/confbridge/include/confbridge.h
+++ b/apps/confbridge/include/confbridge.h
@@ -92,6 +92,8 @@
 	MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC,
 	MENU_ACTION_PARTICIPANT_COUNT,
 	MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS,
+	MENU_ACTION_TOGGLE_BINAURAL,
+	MENU_ACTION_RANDOM_POS,
 };
 
 /*! The conference menu action contains both
@@ -151,6 +153,9 @@
 	CONF_SOUND_KICKED,
 	CONF_SOUND_MUTED,
 	CONF_SOUND_UNMUTED,
+	CONF_SOUND_BINAURAL_ON,
+	CONF_SOUND_BINAURAL_OFF,
+	CONF_SOUND_RANDOM_POS,
 	CONF_SOUND_ONLY_ONE,
 	CONF_SOUND_THERE_ARE,
 	CONF_SOUND_OTHER_IN_PARTY,
@@ -196,6 +201,9 @@
 		AST_STRING_FIELD(participantsmuted);
 		AST_STRING_FIELD(participantsunmuted);
 		AST_STRING_FIELD(begin);
+		AST_STRING_FIELD(binauralon);
+		AST_STRING_FIELD(binauraloff);
+		AST_STRING_FIELD(randompos);
 	);
 };
 

-- 
To view, visit https://gerrit.asterisk.org/3525
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibfe708b9fe26097c1798fcbfcc4dc461267d8af8
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Frank Haase <fra.haase at googlemail.com>



More information about the asterisk-code-review mailing list