From c222c585425d23f39c826460c2875ec9dbc99c5a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 1 May 2007 00:37:10 +0000 Subject: [PATCH] add cool web form from mod_alsa to mod_portaudio git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5048 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../endpoints/mod_portaudio/mod_portaudio.c | 86 ++++++++++++++++++- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index feebbef674..d5f3de9990 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -1720,6 +1720,9 @@ static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch switch_status_t status = SWITCH_STATUS_SUCCESS; pa_command_t func = NULL; int lead = 1, devval = 0; + char *wcmd = NULL, *action = NULL; + char cmd_buf[1024] = ""; + const char *usage_string = "USAGE:\n" "--------------------------------------------------------------------------------\n" "pa help\n" @@ -1736,9 +1739,51 @@ static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch "pa outdev [#|\n" "pa ringdev [#|\n" "--------------------------------------------------------------------------------\n"; - if (switch_strlen_zero(cmd)) { - stream->write_function(stream, "%s", usage_string); - goto done; + + if (stream->event) { +#if 0 + switch_event_header_t *hp; + stream->write_function(stream, "
");
+		for (hp = stream->event->headers; hp; hp = hp->next) {
+			stream->write_function(stream, "[%s]=[%s]\n", hp->name, hp->value);
+		}
+		stream->write_function(stream, "
"); +#endif + + wcmd = switch_str_nil(switch_event_get_header(stream->event, "wcmd")); + action = switch_event_get_header(stream->event, "action"); + + if (action) { + if (strlen(action) == 1) { + snprintf(cmd_buf, sizeof(cmd_buf), "dtmf %s", action); + cmd = cmd_buf; + } else if (!strcmp(action, "mute")) { + snprintf(cmd_buf, sizeof(cmd_buf), "flags off mouth"); + cmd = cmd_buf; + } else if (!strcmp(action, "unmute")) { + snprintf(cmd_buf, sizeof(cmd_buf), "flags on mouth"); + cmd = cmd_buf; + } else if (!strcmp(action, "switch")) { + snprintf(cmd_buf, sizeof(cmd_buf), "switch %s", wcmd); + cmd = cmd_buf; + } else if (!strcmp(action, "call")) { + snprintf(cmd_buf, sizeof(cmd_buf), "call %s", wcmd); + cmd = cmd_buf; + } else if (!strcmp(action, "hangup") || !strcmp(action, "list") || !strcmp(action, "answer")) { + cmd = action; + } + } + + if (switch_strlen_zero(cmd)) { + goto done; + } + + } else { + + if (switch_strlen_zero(cmd)) { + stream->write_function(stream, "%s", usage_string); + goto done; + } } if (!(mycmd = strdup(cmd))) { @@ -1821,6 +1866,41 @@ static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch done: + if (stream->event) { + + stream->write_function(stream, + "

\n" + "

\n" + + " " + " " + " " + " " + " " + " " + "

" + "\n" + "" + "" + "\n" + + "" + "" + "\n" + + "" + "" + "\n" + + "" + "" + "\n" + "
" + + "

\n" + ); + } + switch_safe_free(mycmd); return status;