fixing rfc2833 issue

This commit is contained in:
Kapil Gupta 2012-08-08 15:21:42 -04:00 committed by root
parent d04606fb09
commit e0a7c69ca0
2 changed files with 34 additions and 14 deletions

View File

@ -705,15 +705,6 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
err_code = MGT_MGCO_RSP_CODE_DUP_TERM_CTXT;
goto error;
}
/********************************************************************/
/* associate physical termination to context */
if(SWITCH_STATUS_FALSE == megaco_context_add_termination(mg_ctxt, term)){
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"megaco_context_add_termination failed \n");
mg_util_set_err_string(&errTxt, " Resource Failure ");
err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
goto error;
}
/********************************************************************/
@ -725,6 +716,17 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
err_code = MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT;
goto error;
}
/********************************************************************/
/* associate physical termination to context */
if(SWITCH_STATUS_FALSE == megaco_context_add_termination(mg_ctxt, term)){
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"megaco_context_add_termination failed \n");
mg_util_set_err_string(&errTxt, " Resource Failure ");
err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
goto error;
}
/* TODO - locally assigned SDP must be the part of termination...which we can use to fill responses*/

View File

@ -74,6 +74,8 @@ typedef struct {
switch_port_t local_port;
switch_port_t remote_port;
switch_payload_t agreed_pt; /*XXX*/
switch_payload_t rfc2833_pt;
sofia_dtmf_t dtmf_type;
enum {
RTP_SENDONLY,
@ -146,7 +148,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
*codec = switch_event_get_header_nil(var_event, kCODEC),
*szptime = switch_event_get_header_nil(var_event, kPTIME),
//*mode = switch_event_get_header_nil(var_event, kMODE),
//*szrfc2833_pt = switch_event_get_header_nil(var_event, kRFC2833PT),
*szrfc2833_pt = switch_event_get_header_nil(var_event, kRFC2833PT),
*szrate = switch_event_get_header_nil(var_event, kRATE),
*szpt = switch_event_get_header_nil(var_event, kPT);
@ -155,7 +157,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
remote_port = !zstr(szremote_port) ? atoi(szremote_port) : 0;
int ptime = !zstr(szptime) ? atoi(szptime) : 0,
//rfc2833_pt = !zstr(szrfc2833_pt) ? atoi(szrfc2833_pt) : 0,
rfc2833_pt = !zstr(szrfc2833_pt) ? atoi(szrfc2833_pt) : 0,
rate = !zstr(szrate) ? atoi(szrate) : 8000,
pt = !zstr(szpt) ? atoi(szpt) : 0;
@ -185,7 +187,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
tech_pvt->remote_port = remote_port;
tech_pvt->ptime = ptime;
tech_pvt->agreed_pt = pt;
tech_pvt->dtmf_type = DTMF_2833; /* XXX */
tech_pvt->rfc2833_pt = rfc2833_pt;
if (rfc2833_pt) {
tech_pvt->dtmf_type = DTMF_2833;
} else {
tech_pvt->dtmf_type = DTMF_NONE;
}
if (zstr(local_addr) || local_port == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "The local address and port must be set\n");
@ -248,6 +255,10 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
goto fail;
}
if (tech_pvt->dtmf_type == DTMF_2833) {
switch_rtp_set_telephony_event(tech_pvt->rtp_session, tech_pvt->rfc2833_pt);
}
if (switch_core_session_thread_launch(*new_session) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't start session thread.\n");
goto fail;
@ -501,10 +512,17 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
const char *szpt = switch_channel_get_variable(channel, kRFC2833PT);
int pt = !zstr(szpt) ? atoi(szpt) : 0;
tech_pvt->rfc2833_pt = pt;
if (pt) {
tech_pvt->dtmf_type = DTMF_2833;
} else {
tech_pvt->dtmf_type = DTMF_NONE;
}
switch_channel_set_variable(channel, kRFC2833PT, szpt);
switch_rtp_set_telephony_event(tech_pvt->rtp_session, pt);
}
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command);
}