diff options
author | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2011-06-30 20:33:15 +0000 |
---|---|---|
committer | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2011-06-30 20:33:15 +0000 |
commit | 8ec002763cc11640bdf5c8be0378e179b10da935 (patch) | |
tree | afcca011f073934d3bf0b6e94b9ca2f326b265ad /apps | |
parent | 39c2c3129f909810ea0eb83b84fe513f2d0a87bc (diff) |
Video support for ConfBridge.
Review: https://reviewboard.asterisk.org/r/1288/
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@325931 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_confbridge.c | 148 | ||||
-rw-r--r-- | apps/app_voicemail.c | 24 | ||||
-rw-r--r-- | apps/confbridge/conf_config_parser.c | 24 | ||||
-rw-r--r-- | apps/confbridge/include/confbridge.h | 4 |
4 files changed, 177 insertions, 23 deletions
diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c index 2ed03e120..d046c489f 100644 --- a/apps/app_confbridge.c +++ b/apps/app_confbridge.c @@ -77,6 +77,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") <description> <para>Enters the user into a specified conference bridge. The user can exit the conference by hangup or DTMF menu option.</para> </description> + <see-also> + <ref type="application">ConfBridge</ref> + <ref type="function">CONFBRIDGE</ref> + <ref type="function">CONFBRIDGE_INFO</ref> + </see-also> </application> <function name="CONFBRIDGE" language="en_US"> <synopsis> @@ -233,6 +238,19 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") <description> </description> </manager> + <manager name="ConfbridgeSetSingleVideoSrc" language="en_US"> + <synopsis> + Set a conference user as the single video source distributed to all other participants. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Conference" required="true" /> + <parameter name="Channel" required="true" /> + </syntax> + <description> + </description> + </manager> + ***/ /*! @@ -614,6 +632,68 @@ static int play_prompt_to_channel(struct conference_bridge *conference_bridge, s return res; } +static void handle_video_on_join(struct conference_bridge *conference_bridge, struct conference_bridge_user *conference_bridge_user) +{ + /* only automatically set video source for marked users */ + if (!ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MARKEDUSER)) { + return; + } + + if (ast_test_flag(&conference_bridge->b_profile, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED)) { + int set = 1; + struct conference_bridge_user *tmp_user = NULL; + ao2_lock(conference_bridge); + /* see if anyone is already the video src */ + AST_LIST_TRAVERSE(&conference_bridge->users_list, tmp_user, list) { + if (tmp_user == conference_bridge_user) { + continue; + } + if (ast_bridge_is_video_src(conference_bridge->bridge, tmp_user->chan)) { + set = 0; + break; + } + } + ao2_unlock(conference_bridge); + if (set) { + ast_bridge_set_single_src_video_mode(conference_bridge->bridge, conference_bridge_user->chan); + } + } else if (ast_test_flag(&conference_bridge->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, conference_bridge_user->chan); + } +} + +static void handle_video_on_exit(struct conference_bridge *conference_bridge, struct conference_bridge_user *conference_bridge_user) +{ + struct conference_bridge_user *tmp_user = NULL; + + /* if this isn't a video source, nothing to update */ + if (!ast_bridge_is_video_src(conference_bridge->bridge, conference_bridge_user->chan)) { + return; + } + + ast_bridge_remove_video_src(conference_bridge->bridge, conference_bridge_user->chan); + + /* 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)) { + return; + } + + /* Make the next avaliable marked user the video src. */ + ao2_lock(conference_bridge); + AST_LIST_TRAVERSE(&conference_bridge->users_list, tmp_user, list) { + if (tmp_user == conference_bridge_user) { + 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); + break; + } + } + ao2_unlock(conference_bridge); +} + /*! * \brief Perform post-joining marked specific actions * @@ -627,7 +707,8 @@ static int post_join_marked(struct conference_bridge *conference_bridge, struct if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MARKEDUSER)) { struct conference_bridge_user *other_conference_bridge_user = NULL; - /* If we are not the first marked user to join just bail out now */ + /* If we are not the first user to join, then the users are already + * in the conference so we do not need to update them. */ if (conference_bridge->markedusers >= 2) { return 0; } @@ -664,7 +745,6 @@ static int post_join_marked(struct conference_bridge *conference_bridge, struct other_conference_bridge_user->features.mute = 0; } } - } else { /* If a marked user already exists in the conference bridge we can just bail out now */ if (conference_bridge->markedusers) { @@ -859,6 +939,10 @@ static struct conference_bridge *join_conference_bridge(const char *name, struct /* 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); + } + /* Setup lock for playback channel */ ast_mutex_init(&conference_bridge->playback_lock); @@ -1370,6 +1454,8 @@ static int confbridge_exec(struct ast_channel *chan, const char *data) } } + handle_video_on_join(conference_bridge, &conference_bridge_user); + /* Join our conference bridge for real */ send_join_event(conference_bridge_user.chan, conference_bridge->name); ast_bridge_join(conference_bridge->bridge, @@ -1379,6 +1465,9 @@ static int confbridge_exec(struct ast_channel *chan, const char *data) &conference_bridge_user.tech_args); send_leave_event(conference_bridge_user.chan, conference_bridge->name); + + handle_video_on_exit(conference_bridge, &conference_bridge_user); + /* if this user has a intro, play it when leaving */ if (!quiet && !ast_strlen_zero(conference_bridge_user.name_rec_location)) { ast_autoservice_start(chan); @@ -1681,6 +1770,11 @@ static int execute_menu_entry(struct conference_bridge *conference_bridge, break; case MENU_ACTION_NOOP: break; + case MENU_ACTION_SET_SINGLE_VIDEO_SRC: + ao2_lock(conference_bridge); + ast_bridge_set_single_src_video_mode(conference_bridge->bridge, bridge_channel->chan); + ao2_unlock(conference_bridge); + break; } } return res; @@ -2436,6 +2530,55 @@ static int action_confbridgestoprecord(struct mansession *s, const struct messag return 0; } +static int action_confbridgesetsinglevideosrc(struct mansession *s, const struct message *m) +{ + const char *conference = astman_get_header(m, "Conference"); + const char *channel = astman_get_header(m, "Channel"); + struct conference_bridge_user *participant = NULL; + struct conference_bridge *bridge = NULL; + struct conference_bridge tmp; + + if (ast_strlen_zero(conference)) { + astman_send_error(s, m, "No Conference name provided."); + return 0; + } + if (ast_strlen_zero(channel)) { + astman_send_error(s, m, "No channel name provided."); + return 0; + } + if (!ao2_container_count(conference_bridges)) { + astman_send_error(s, m, "No active conferences."); + return 0; + } + + ast_copy_string(tmp.name, conference, sizeof(tmp.name)); + bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER); + if (!bridge) { + astman_send_error(s, m, "No Conference by that name found."); + return 0; + } + + /* find channel and set as video src. */ + ao2_lock(bridge); + AST_LIST_TRAVERSE(&bridge->users_list, participant, list) { + if (!strncmp(channel, participant->chan->name, strlen(channel))) { + ast_bridge_set_single_src_video_mode(bridge->bridge, participant->chan); + break; + } + } + ao2_unlock(bridge); + ao2_ref(bridge, -1); + + /* do not access participant after bridge unlock. We are just + * using this check to see if it was found or not */ + if (!participant) { + astman_send_error(s, m, "No channel by that name found in conference."); + return 0; + } + astman_send_ack(s, m, "Conference single video source set."); + return 0; +} + static int func_confbridge_info(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { char *parse = NULL; @@ -2567,6 +2710,7 @@ static int load_module(void) res |= ast_manager_register_xml("ConfbridgeLock", EVENT_FLAG_CALL, action_confbridgelock); res |= ast_manager_register_xml("ConfbridgeStartRecord", EVENT_FLAG_CALL, action_confbridgestartrecord); res |= ast_manager_register_xml("ConfbridgeStopRecord", EVENT_FLAG_CALL, action_confbridgestoprecord); + res |= ast_manager_register_xml("ConfbridgeSetSingleVideoSrc", EVENT_FLAG_CALL, action_confbridgesetsinglevideosrc); conf_load_config(0); return res; diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 09e20ad46..5e342bda0 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -903,8 +903,6 @@ static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format, static int is_valid_dtmf(const char *key); static void read_password_from_file(const char *secretfn, char *password, int passwordlen); static int write_password_to_file(const char *secretfn, const char *password); -static const char *substitute_escapes(const char *value); -static void free_user(struct ast_vm_user *vmu); struct ao2_container *inprocess_container; @@ -996,8 +994,7 @@ static char *strip_control_and_high(const char *input, char *buf, size_t buflen) * - the dialcontext * - the exitcontext * - vmmaxsecs, vmmaxmsg, maxdeletedmsg - * - volume gain - * - emailsubject, emailbody set to NULL + * - volume gain. */ static void populate_defaults(struct ast_vm_user *vmu) { @@ -1048,10 +1045,6 @@ static void apply_option(struct ast_vm_user *vmu, const char *var, const char *v ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt)); } else if (!strcasecmp(var, "serveremail")) { ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail)); - } else if (!strcasecmp(var, "emailbody")) { - vmu->emailbody = ast_strdup(substitute_escapes(value)); - } else if (!strcasecmp(var, "emailsubject")) { - vmu->emailsubject = ast_strdup(substitute_escapes(value)); } else if (!strcasecmp(var, "language")) { ast_copy_string(vmu->language, value, sizeof(vmu->language)); } else if (!strcasecmp(var, "tz")) { @@ -1389,7 +1382,7 @@ static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const cha ast_variables_destroy(var); } else { if (!ivm) - free_user(retval); + ast_free(retval); retval = NULL; } } @@ -10644,9 +10637,7 @@ AST_TEST_DEFINE(test_voicemail_vmuser) "envelope=yes|moveheard=yes|sayduration=yes|saydurationm=5|forcename=yes|" "forcegreetings=yes|callback=somecontext|dialout=somecontext2|" "exitcontext=somecontext3|minsecs=10|maxsecs=100|nextaftercmd=yes|" - "backupdeleted=50|volgain=1.3|passwordlocation=spooldir|emailbody=" - "Dear ${VM_NAME}:\n\n\tYou were just left a ${VM_DUR} long message|emailsubject=" - "[PBX]: New message ${VM_MSGNUM} in mailbox ${VM_MAILBOX}"; + "backupdeleted=50|volgain=1.3|passwordlocation=spooldir"; #ifdef IMAP_STORAGE static const char option_string2[] = "imapuser=imapuser|imappassword=imappasswd|" "imapfolder=INBOX|imapvmshareid=6000"; @@ -10668,7 +10659,6 @@ AST_TEST_DEFINE(test_voicemail_vmuser) return AST_TEST_NOT_RUN; } ast_set_flag(vmu, VM_ALLOCED); - populate_defaults(vmu); apply_options(vmu, options_string); @@ -10684,14 +10674,6 @@ AST_TEST_DEFINE(test_voicemail_vmuser) ast_test_status_update(test, "Parse failure for serveremail option\n"); res = 1; } - if (!vmu->emailsubject || strcasecmp(vmu->emailsubject, "[PBX]: New message ${VM_MSGNUM} in mailbox ${VM_MAILBOX}")) { - ast_test_status_update(test, "Parse failure for emailsubject option\n"); - res = 1; - } - if (!vmu->emailbody || strcasecmp(vmu->emailbody, "Dear ${VM_NAME}:\n\n\tYou were just left a ${VM_DUR} long message")) { - ast_test_status_update(test, "Parse failure for emailbody option\n"); - res = 1; - } if (strcasecmp(vmu->zonetag, "central")) { ast_test_status_update(test, "Parse failure for tz option\n"); res = 1; diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c index 3d1f31326..8864f52bc 100644 --- a/apps/confbridge/conf_config_parser.c +++ b/apps/confbridge/conf_config_parser.c @@ -284,6 +284,14 @@ static int set_bridge_option(const char *name, const char *value, struct bridge_ } } else if (!strcasecmp(name, "record_conference")) { ast_set2_flag(b_profile, ast_true(value), BRIDGE_OPT_RECORD_CONFERENCE); + } else if (!strcasecmp(name, "video_mode")) { + if (!strcasecmp(value, "first_marked")) { + ast_set_flag(b_profile, BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED); + } else if (!strcasecmp(value, "last_marked")) { + ast_set_flag(b_profile, BRIDGE_OPT_VIDEO_SRC_LAST_MARKED); + } else if (!strcasecmp(value, "follow_talker")) { + ast_set_flag(b_profile, BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER); + } } else if (!strcasecmp(name, "max_members")) { if (sscanf(value, "%30u", &b_profile->max_members) != 1) { return -1; @@ -534,6 +542,7 @@ static int add_action_to_menu_entry(struct conf_menu_entry *menu_entry, enum con case MENU_ACTION_ADMIN_TOGGLE_LOCK: case MENU_ACTION_ADMIN_KICK_LAST: case MENU_ACTION_LEAVE: + case MENU_ACTION_SET_SINGLE_VIDEO_SRC: break; case MENU_ACTION_PLAYBACK: case MENU_ACTION_PLAYBACK_AND_CONTINUE: @@ -649,6 +658,8 @@ static int add_menu_entry(struct conf_menu *menu, const char *dtmf, const char * res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_KICK_LAST, NULL); } else if (!strcasecmp(action, "leave_conference")) { res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_LEAVE, NULL); + } else if (!strcasecmp(action, "set_as_single_video_src")) { + res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_SET_SINGLE_VIDEO_SRC, NULL); } else if (!strncasecmp(action, "dialplan_exec(", 14)) { ast_copy_string(buf, action, sizeof(buf)); action_args = buf; @@ -983,6 +994,16 @@ static char *handle_cli_confbridge_show_bridge_profile(struct ast_cli_entry *e, ast_cli(a->fd,"Max Members: No Limit\n"); } + if (b_profile.flags & BRIDGE_OPT_VIDEO_SRC_LAST_MARKED) { + ast_cli(a->fd, "Video Mode: last_marked\n"); + } else if (b_profile.flags & BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED) { + ast_cli(a->fd, "Video Mode: first_marked\n"); + } else if (b_profile.flags & BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER) { + ast_cli(a->fd, "Video Mode: follow_talker\n"); + } else { + ast_cli(a->fd, "Video Mode: no video\n"); + } + ast_cli(a->fd,"sound_join: %s\n", conf_get_sound(CONF_SOUND_JOIN, b_profile.sounds)); ast_cli(a->fd,"sound_leave: %s\n", conf_get_sound(CONF_SOUND_LEAVE, b_profile.sounds)); ast_cli(a->fd,"sound_only_person: %s\n", conf_get_sound(CONF_SOUND_ONLY_PERSON, b_profile.sounds)); @@ -1142,6 +1163,9 @@ static char *handle_cli_confbridge_show_menu(struct ast_cli_entry *e, int cmd, s case MENU_ACTION_LEAVE: ast_cli(a->fd, "leave_conference"); break; + case MENU_ACTION_SET_SINGLE_VIDEO_SRC: + ast_cli(a->fd, "set_as_single_video_src"); + break; } action_num++; } diff --git a/apps/confbridge/include/confbridge.h b/apps/confbridge/include/confbridge.h index de467b5f7..7a2f6bb07 100644 --- a/apps/confbridge/include/confbridge.h +++ b/apps/confbridge/include/confbridge.h @@ -61,6 +61,9 @@ enum user_profile_flags { enum bridge_profile_flags { BRIDGE_OPT_RECORD_CONFERENCE = (1 << 0), /*!< Set if the conference should be recorded */ + BRIDGE_OPT_VIDEO_SRC_LAST_MARKED = (1 << 1), /*!< Set if conference should feed video of last marked user to all participants. */ + BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED = (1 << 2), /*!< Set if conference should feed video of first marked user to all participants. */ + BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER = (1 << 3), /*!< Set if conference set the video feed to follow the loudest talker. */ }; enum conf_menu_action_id { @@ -78,6 +81,7 @@ enum conf_menu_action_id { MENU_ACTION_ADMIN_KICK_LAST, MENU_ACTION_LEAVE, MENU_ACTION_NOOP, + MENU_ACTION_SET_SINGLE_VIDEO_SRC, }; /*! The conference menu action contains both |