adding code for reporting DTMF to MGC

This commit is contained in:
Kapil Gupta 2012-08-08 13:34:42 -04:00 committed by root
parent 99e04bf1d8
commit e5d140d1e6
1 changed files with 23 additions and 0 deletions

View File

@ -7,6 +7,7 @@
*/
#include "mod_media_gateway.h"
#include "media_gateway_stack.h"
megaco_profile_t *megaco_profile_locate(const char *name)
{
@ -79,6 +80,24 @@ megaco_profile_t* megaco_get_profile_by_suId(SuId suId)
return profile;
}
static switch_status_t mg_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
mg_termination_t *term = switch_channel_get_private(channel, "_mg_term_");
char digit[2] = { dtmf->digit };
if (!term) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find termination structure for session [%s]\n",
switch_core_session_get_uuid(session));
return SWITCH_STATUS_SUCCESS;
}
//switch_status_t mg_send_dtmf_notify(megaco_profile_t* mg_profile, const char* term_name, char* digits, int num_of_collected_digits);
//mg_send_dtmf_notify(term->profile, term->name, digit, 1);
switch_log_printf("NOT Sending notify to MGC for dtmf: %c\n", dtmf->digit);
return SWITCH_STATUS_SUCCESS;
}
/*
* Creates a freeswitch channel for the specified termination.
* The channel will be parked until future actions are taken
@ -136,6 +155,7 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
}
if (zstr(term->uuid)) {
switch_channel_t *channel;
if (switch_ivr_originate(NULL, &session, &cause, dialstring, 0, NULL, NULL, NULL, NULL, var_event, 0, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to instanciate termination [%s]: %s\n", term->name, switch_channel_cause2str(cause));
status = SWITCH_STATUS_FALSE;
@ -144,6 +164,9 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
term->uuid = switch_core_strdup(term->pool, switch_core_session_get_uuid(session));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Termination [%s] successfully instanciated as [%s] [%s]\n", term->name, dialstring, switch_core_session_get_uuid(session));
channel = switch_core_session_get_channel(session);
switch_channel_set_private(channel, "_mg_term_", term);
switch_core_event_hook_add_recv_dtmf(session, mg_on_dtmf);
}
switch_set_flag(term, MGT_ACTIVE);