From 6ece392d46d30456cd1fc20eae670004e1aad44d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 17 Dec 2009 23:08:38 +0000 Subject: [PATCH] add dp apps for setting audio level and muting git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15993 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_core.h | 2 + .../applications/mod_dptools/mod_dptools.c | 51 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 19194f9062..3bd75e0c5f 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -134,6 +134,8 @@ SWITCH_DECLARE(void) switch_core_session_unsched_heartbeat(switch_core_session_t SWITCH_DECLARE(void) switch_core_session_enable_heartbeat(switch_core_session_t *session, uint32_t seconds); SWITCH_DECLARE(void) switch_core_session_disable_heartbeat(switch_core_session_t *session); +#define switch_core_session_get_name(_s) switch_channel_get_name(switch_core_session_get_channel(_s)) + /*! \brief Add a media bug to the session \param session the session to add the bug to diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index de696cd743..d5bb693bb8 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -419,6 +419,54 @@ SWITCH_STANDARD_APP(set_user_function) switch_ivr_set_user(session, data); } +#define SET_AUDIO_LEVEL_SYNTAX "[read|write] " +SWITCH_STANDARD_APP(set_audio_level_function) +{ + char *argv[2] = { 0 }; + int argc = 0; + char *mydata; + int level = 0; + + mydata = switch_core_session_strdup(session, data); + argc = switch_split(mydata, ' ', argv); + + if (argc != 2) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n", + switch_core_session_get_name(session), SET_AUDIO_LEVEL_SYNTAX); + return; + } + + level = atoi(argv[1]); + + switch_ivr_session_audio(session, "level", argv[0], level); + + +} + +#define SET_MUTE_SYNTAX "[read|write] [true|false]" +SWITCH_STANDARD_APP(set_mute_function) +{ + char *argv[2] = { 0 }; + int argc = 0; + char *mydata; + int level = 0; + + mydata = switch_core_session_strdup(session, data); + argc = switch_split(mydata, ' ', argv); + + if (argc != 2) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n", + switch_core_session_get_name(session), SET_MUTE_SYNTAX); + return; + } + + level = switch_true(argv[1]); + + switch_ivr_session_audio(session, "mute", argv[0], level); + +} + + SWITCH_STANDARD_APP(ring_ready_function) { switch_channel_ring_ready(switch_core_session_get_channel(session)); @@ -2945,6 +2993,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "privacy", "Set privacy on calls", "Set caller privacy on calls.", privacy_function, "off|on|name|full|number", SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "set_audio_level", "set volume", "set volume", set_audio_level_function, "", SAF_NONE); + SWITCH_ADD_APP(app_interface, "set_mute", "set mute", "set mute", set_mute_function, "", SAF_NONE); + SWITCH_ADD_APP(app_interface, "flush_dtmf", "flush any queued dtmf", "flush any queued dtmf", flush_dtmf_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "hold", "Send a hold message", "Send a hold message", hold_function, HOLD_SYNTAX, SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "unhold", "Send a un-hold message", "Send a un-hold message", unhold_function, UNHOLD_SYNTAX, SAF_SUPPORT_NOMEDIA);