提交 ccf74d5b authored 作者: Anthony Minessale's avatar Anthony Minessale 提交者: Brian West

negotiable t38 passthru

上级 041b8da5
......@@ -1965,9 +1965,19 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
} else {
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
char *sdp = (char *) msg->pointer_arg;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Responding with %d [%s]\n", code, reason);
if (!zstr(((char *) msg->pointer_arg))) {
sofia_glue_tech_set_local_sdp(tech_pvt, (char *) msg->pointer_arg, SWITCH_TRUE);
if (!zstr((sdp))) {
if (!strcasecmp(sdp, "t38")) {
switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
if (t38_options) {
sofia_glue_set_image_sdp(tech_pvt, t38_options, 0);
}
} else {
sofia_glue_tech_set_local_sdp(tech_pvt, sdp, SWITCH_TRUE);
}
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
sofia_glue_tech_patch_sdp(tech_pvt);
......
......@@ -209,6 +209,7 @@ typedef enum {
PFLAG_TRACK_CALLS,
PFLAG_DESTROY,
PFLAG_EXTENDED_INFO_PARSING,
PFLAG_T38_PASSTHRU,
/* No new flags below this line */
PFLAG_MAX
} PFLAGS;
......@@ -265,6 +266,7 @@ typedef enum {
TFLAG_TRACKED,
TFLAG_RECOVERING,
TFLAG_RECOVERING_BRIDGE,
TFLAG_T38_PASSTHRU,
/* No new flags below this line */
TFLAG_MAX
} TFLAGS;
......@@ -741,7 +743,7 @@ switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt, int forc
switch_status_t sofia_glue_do_invite(switch_core_session_t *session);
uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp);
uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_sdp);
void sofia_presence_establish_presence(sofia_profile_t *profile);
......@@ -985,5 +987,5 @@ void sofia_profile_destroy(sofia_profile_t *profile);
switch_status_t sip_dig_function(_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream);
const char *sofia_gateway_status_name(sofia_gateway_status_t status);
void sofia_reg_fire_custom_gateway_state_event(sofia_gateway_t *gateway, int status, const char *phrase);
void sofia_glue_copy_t38_options(switch_t38_options_t *t38_options, switch_core_session_t *session);
switch_t38_options_t *sofia_glue_extract_t38_options(switch_core_session_t *session, const char *r_sdp);
......@@ -2191,6 +2191,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
} else {
sofia_clear_pflag(profile, PFLAG_LOG_AUTH_FAIL);
}
} else if (!strcasecmp(var, "t38-passthru")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_T38_PASSTHRU);
} else {
sofia_clear_pflag(profile, PFLAG_T38_PASSTHRU);
}
} else if (!strcasecmp(var, "dtmf-type")) {
if (!strcasecmp(val, "rfc2833")) {
profile->dtmf_type = DTMF_2833;
......@@ -2797,6 +2803,12 @@ switch_status_t config_sofia(int reload, char *profile_name)
} else {
sofia_clear_pflag(profile, PFLAG_LOG_AUTH_FAIL);
}
} else if (!strcasecmp(var, "t38-passthru")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_T38_PASSTHRU);
} else {
sofia_clear_pflag(profile, PFLAG_T38_PASSTHRU);
}
} else if (!strcasecmp(var, "disable-hold")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_DISABLE_HOLD);
......@@ -3922,7 +3934,9 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
}
}
if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
if (switch_channel_test_flag(channel, CF_PROXY_MODE) ||
switch_channel_test_flag(channel, CF_PROXY_MEDIA) ||
sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
if (sofia_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) {
sofia_clear_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
......@@ -3930,6 +3944,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
const char *r_sdp = NULL;
switch_core_session_message_t *msg;
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
if (sip->sip_payload && sip->sip_payload->pl_data &&
sip->sip_content_type && sip->sip_content_type->c_subtype && switch_stristr("sdp", sip->sip_content_type->c_subtype)) {
......@@ -3939,18 +3954,40 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing %d %s to other leg\n", status, phrase);
if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
if (sip->sip_payload && sip->sip_payload->pl_data) {
switch_t38_options_t *t38_options = sofia_glue_extract_t38_options(session, sip->sip_payload->pl_data);
sofia_glue_copy_t38_options(t38_options, other_session);
}
}
msg = switch_core_session_alloc(other_session, sizeof(*msg));
msg->message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
msg->from = __FILE__;
msg->numeric_arg = status;
msg->string_arg = switch_core_session_strdup(other_session, phrase);
if (r_sdp) {
if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
msg->pointer_arg = switch_core_session_strdup(other_session, "t38");
} else if (r_sdp) {
msg->pointer_arg = switch_core_session_strdup(other_session, r_sdp);
msg->pointer_arg_size = strlen(r_sdp);
}
if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
switch_core_session_receive_message(other_session, msg);
if (switch_rtp_ready(tech_pvt->rtp_session) && switch_rtp_ready(other_tech_pvt->rtp_session)) {
switch_rtp_udptl_mode(tech_pvt->rtp_session);
switch_rtp_udptl_mode(other_tech_pvt->rtp_session);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating T38 Passthru\n");
}
} else {
switch_core_session_queue_message(other_session, msg);
}
switch_core_session_queue_message(other_session, msg);
switch_core_session_rwunlock(other_session);
}
goto end;
......@@ -4334,17 +4371,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_channel_set_state(channel, CS_INIT);
}
} else {
sdp_parser_t *parser;
sdp_session_t *sdp;
uint8_t match = 0;
if (tech_pvt->num_codecs) {
if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
if ((sdp = sdp_session(parser))) {
match = sofia_glue_negotiate_sdp(session, sdp);
}
sdp_parser_free(parser);
}
match = sofia_glue_negotiate_sdp(session, r_sdp);
}
if (match) {
......@@ -4455,8 +4485,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
break;
case nua_callstate_completed:
if (r_sdp) {
sdp_parser_t *parser;
sdp_session_t *sdp;
uint8_t match = 0, is_ok = 1, is_t38 = 0;
tech_pvt->hold_laps = 0;
......@@ -4571,12 +4599,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
if (tech_pvt->num_codecs) {
if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
if ((sdp = sdp_session(parser))) {
match = sofia_glue_negotiate_sdp(session, sdp);
}
sdp_parser_free(parser);
}
match = sofia_glue_negotiate_sdp(session, r_sdp);
}
if (match && switch_channel_test_app_flag(tech_pvt->channel, CF_APP_T38)) {
......@@ -4633,19 +4656,12 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
case nua_callstate_ready:
if (r_sdp && !is_dup_sdp && switch_rtp_ready(tech_pvt->rtp_session)) {
/* sdp changed since 18X w sdp, we're supposed to ignore it but we, of course, were pressured into supporting it */
sdp_parser_t *parser;
sdp_session_t *sdp;
uint8_t match = 0;
sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
if (tech_pvt->num_codecs) {
if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
if ((sdp = sdp_session(parser))) {
match = sofia_glue_negotiate_sdp(session, sdp);
}
sdp_parser_free(parser);
}
match = sofia_glue_negotiate_sdp(session, r_sdp);
}
if (match) {
if (sofia_glue_tech_choose_port(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
......@@ -4668,20 +4684,13 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
if (r_sdp && sofia_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) {
sdp_parser_t *parser;
sdp_session_t *sdp;
uint8_t match = 0;
int is_ok = 1;
sofia_clear_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
if (tech_pvt->num_codecs) {
if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
if ((sdp = sdp_session(parser))) {
match = sofia_glue_negotiate_sdp(session, sdp);
}
sdp_parser_free(parser);
}
match = sofia_glue_negotiate_sdp(session, r_sdp);
}
if (match) {
......@@ -4764,17 +4773,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
goto done;
} else {
sdp_parser_t *parser;
sdp_session_t *sdp;
uint8_t match = 0;
if (tech_pvt->num_codecs) {
if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
if ((sdp = sdp_session(parser))) {
match = sofia_glue_negotiate_sdp(session, sdp);
}
sdp_parser_free(parser);
}
match = sofia_glue_negotiate_sdp(session, r_sdp);
}
sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
......
......@@ -1045,8 +1045,11 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_udptl_mode(switch_rtp_t *rtp_session)
WRITE_DEC(rtp_session);
READ_DEC(rtp_session);
switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH);
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_STICKY_FLUSH);
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH);
switch_rtp_break(rtp_session);
return SWITCH_STATUS_SUCCESS;
}
......@@ -2250,6 +2253,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
if (rtp_session->dtmf_data.out_digit_dur > 0) {
pt = 20000;
}
poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, pt);
if (rtp_session->dtmf_data.out_digit_dur > 0) {
do_2833(rtp_session);
......@@ -2274,7 +2278,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
goto end;
}
}
if (rtp_session->dtmf_data.out_digit_dur == 0 || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) {
return_cng_frame();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论