[commit] r3184 - freeswitch/branches/ptinsley/voicemail/src/mod/endpoints/mod_sofia
Author: ptinsley Date: Tue Oct 24 17:28:26 2006 New Revision: 3184 Modified: freeswitch/branches/ptinsley/voicemail/src/mod/endpoints/mod_sofia/mod_sofia.c Log: DTMF INFO support Modified: freeswitch/branches/ptinsley/voicemail/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/branches/ptinsley/voicemail/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/branches/ptinsley/voicemail/src/mod/endpoints/mod_sofia/mod_sofia.c Tue Oct 24 17:28:26 2006 @@ -368,6 +368,13 @@ sip_t const *sip, tagi_t tags[]); +static void sip_i_info(nua_t *nua, + sofia_profile_t *profile, + nua_handle_t *nh, + switch_core_session_t *session, + sip_t const *sip, + tagi_t tags[]); + static void sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, @@ -3556,7 +3563,70 @@ } +static void sip_i_info(nua_t *nua, + sofia_profile_t *profile, + nua_handle_t *nh, + switch_core_session_t *session, + sip_t const *sip, + tagi_t tags[]) { + //placeholder for string searching + char *signal_ptr; + + //Try and find signal information in the payload + signal_ptr = strstr(sip->sip_payload->pl_data, "Signal="); + + //See if we found a match + if(signal_ptr) { + struct private_object *tech_pvt = NULL; + switch_channel_t *channel = NULL; + + //Get the channel + channel = switch_core_session_get_channel(session); + + //Barf if we didn't get it + assert(channel != NULL); + + //make sure we have our privates + tech_pvt = switch_core_session_get_private(session); + + //Barf if we didn't get it + assert(tech_pvt != NULL); + + //holder for the dtmf digit + char *dtmf_digit = malloc(sizeof(char) * 2); + + //move signal_ptr where we need it (right past Signal=) + signal_ptr = signal_ptr + 7; + + //put the digit somewhere we can muck with + strncpy(dtmf_digit, signal_ptr, 1); + + //End the string + *(dtmf_digit + 1) = '\0'; + + //queue it up + switch_channel_queue_dtmf(channel, dtmf_digit); + + //print debug info + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INFO DTMF(%s)\n", dtmf_digit); + + //Give back the memory I borrowed + free(dtmf_digit); + } else { //unknown info type + sip_from_t const *from; + + from = sip->sip_from; + + //print in the logs if something comes through we don't understand + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown INFO Recieved: %s%s" URL_PRINT_FORMAT "[%s]\n", + from->a_display ? from->a_display : "", from->a_display ? " " : "", + URL_PRINT_ARGS(from->a_url), sip->sip_payload->pl_data); + } + + return; +} + static void sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, @@ -3970,7 +4040,7 @@ break; case nua_i_info: - //sip_i_info(nua, profile, nh, sofia_private, sip, tags); + sip_i_info(nua, profile, nh, session, sip, tags); break; case nua_r_refer: @@ -4120,6 +4190,7 @@ NUTAG_AUTOALERT(0), NUTAG_ALLOW("REGISTER"), NUTAG_ALLOW("REFER"), + NUTAG_ALLOW("INFO"), TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("PUBLISH")), TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("NOTIFY")), TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("SUBSCRIBE")), @@ -4144,6 +4215,7 @@ NUTAG_AUTOALERT(0), NUTAG_ALLOW("REGISTER"), NUTAG_ALLOW("REFER"), + NUTAG_ALLOW("INFO"), TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("PUBLISH")), TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ENABLEMESSAGE(1)), SIPTAG_SUPPORTED_STR("100rel, precondition"),
participants (1)
-
Freeswitch SVN