diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c index 8a4fdc3291743ba07190caf77dca47ab1603797c..65498bd90bdeb54c19666c8f72a9218f73848581 100644 --- a/apps/app_confbridge.c +++ b/apps/app_confbridge.c @@ -748,9 +748,8 @@ static int announce_user_count(struct conference_bridge *conference_bridge, stru /*! * \brief Play back an audio file to a channel * - * \param conference_bridge Conference bridge they are in - * \param chan Channel to play audio prompt to - * \param file Prompt to play + * \param cbu User to play audio prompt to + * \param filename Prompt to play * * \return Returns 0 on success, -1 if the user hung up * \note Generally this should be called when the conference is unlocked to avoid blocking @@ -1216,6 +1215,15 @@ static struct conference_bridge *join_conference_bridge(const char *name, struct ao2_unlock(conference_bridge); + /* If an announcement is to be played play it */ + if (!ast_strlen_zero(conference_bridge_user->u_profile.announcement)) { + if (play_prompt_to_user(conference_bridge_user, + conference_bridge_user->u_profile.announcement)) { + leave_conference(conference_bridge_user); + return NULL; + } + } + /* Announce number of users if need be */ if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ANNOUNCEUSERCOUNT)) { if (announce_user_count(conference_bridge, conference_bridge_user)) { @@ -1535,7 +1543,6 @@ static int confbridge_exec(struct ast_channel *chan, const char *data) if (args.argc > 2 && !ast_strlen_zero(args.u_profile_name)) { u_profile_name = args.u_profile_name; } - if (!conf_find_user_profile(chan, u_profile_name, &conference_bridge_user.u_profile)) { ast_log(LOG_WARNING, "Conference user profile %s does not exist\n", u_profile_name); res = -1; diff --git a/apps/app_page.c b/apps/app_page.c index 95069d7d6193db657085b9ba398ac0c3b1006ded..8e7d1d2bda70fd8ab8d2e56df31d147b4e8587c8 100644 --- a/apps/app_page.c +++ b/apps/app_page.c @@ -141,35 +141,85 @@ struct page_options { struct ast_flags flags; }; -static void page_state_callback(struct ast_dial *dial) +/*! + * \internal + * \brief Setup the page bridge profile. + * + * \param chan Setup bridge profile on this channel. + * \param options Options to setup bridge profile. + * + * \return Nothing + */ +static void setup_profile_bridge(struct ast_channel *chan, struct page_options *options) { - struct ast_channel *chan; - struct page_options *options; - - if (ast_dial_state(dial) != AST_DIAL_RESULT_ANSWERED || - !(chan = ast_dial_answered(dial)) || - !(options = ast_dial_get_user_data(dial))) { - return; - } - - ast_func_write(chan, "CONFBRIDGE(bridge,template)", "default_bridge"); - + /* Use default_bridge as a starting point */ + ast_func_write(chan, "CONFBRIDGE(bridge,template)", ""); if (ast_test_flag(&options->flags, PAGE_RECORD)) { ast_func_write(chan, "CONFBRIDGE(bridge,record_conference)", "yes"); } +} +/*! + * \internal + * \brief Setup the paged user profile. + * + * \param chan Setup user profile on this channel. + * \param options Options to setup paged user profile. + * + * \return Nothing + */ +static void setup_profile_paged(struct ast_channel *chan, struct page_options *options) +{ + /* Use default_user as a starting point */ + ast_func_write(chan, "CONFBRIDGE(user,template)", ""); ast_func_write(chan, "CONFBRIDGE(user,quiet)", "yes"); ast_func_write(chan, "CONFBRIDGE(user,end_marked)", "yes"); - if (!ast_test_flag(&options->flags, PAGE_DUPLEX)) { ast_func_write(chan, "CONFBRIDGE(user,startmuted)", "yes"); } + if (ast_test_flag(&options->flags, PAGE_ANNOUNCE) + && !ast_strlen_zero(options->opts[OPT_ARG_ANNOUNCE])) { + ast_func_write(chan, "CONFBRIDGE(user,announcement)", options->opts[OPT_ARG_ANNOUNCE]); + } +} - if (ast_test_flag(&options->flags, PAGE_ANNOUNCE) && !ast_strlen_zero(options->opts[OPT_ARG_ANNOUNCE])) { +/*! + * \internal + * \brief Setup the caller user profile. + * + * \param chan Setup user profile on this channel. + * \param options Options to setup caller user profile. + * + * \return Nothing + */ +static void setup_profile_caller(struct ast_channel *chan, struct page_options *options) +{ + /* Use default_user as a starting point if not already setup. */ + ast_func_write(chan, "CONFBRIDGE(user,template)", ""); + ast_func_write(chan, "CONFBRIDGE(user,quiet)", "yes"); + ast_func_write(chan, "CONFBRIDGE(user,marked)", "yes"); + if (!ast_test_flag(&options->flags, PAGE_NOCALLERANNOUNCE) + && ast_test_flag(&options->flags, PAGE_ANNOUNCE) + && !ast_strlen_zero(options->opts[OPT_ARG_ANNOUNCE])) { ast_func_write(chan, "CONFBRIDGE(user,announcement)", options->opts[OPT_ARG_ANNOUNCE]); } } +static void page_state_callback(struct ast_dial *dial) +{ + struct ast_channel *chan; + struct page_options *options; + + if (ast_dial_state(dial) != AST_DIAL_RESULT_ANSWERED || + !(chan = ast_dial_answered(dial)) || + !(options = ast_dial_get_user_data(dial))) { + return; + } + + setup_profile_bridge(chan, options); + setup_profile_paged(chan, options); +} + static int page_exec(struct ast_channel *chan, const char *data) { char *tech, *resource, *tmp; @@ -302,17 +352,10 @@ static int page_exec(struct ast_channel *chan, const char *data) } if (!res) { - ast_func_write(chan, "CONFBRIDGE(bridge,template)", "default_bridge"); - - if (ast_test_flag(&options.flags, PAGE_RECORD)) { - ast_func_write(chan, "CONFBRIDGE(bridge,record_conference)", "yes"); - } - - ast_func_write(chan, "CONFBRIDGE(user,quiet)", "yes"); - ast_func_write(chan, "CONFBRIDGE(user,marked)", "yes"); + setup_profile_bridge(chan, &options); + setup_profile_caller(chan, &options); snprintf(confbridgeopts, sizeof(confbridgeopts), "%u", confid); - pbx_exec(chan, app, confbridgeopts); }