]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
negotiable t38 passthru
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 27 May 2010 01:12:54 +0000 (20:12 -0500)
committerBrian West <brian@freeswitch.org>
Thu, 27 May 2010 01:13:07 +0000 (20:13 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_rtp.c

index a1d367e5b9f7f91c602234f3a0080aa77e3cf0dc..6478af9b3ae984925ac759c49c41dcee13713acc 100644 (file)
@@ -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);
index 8d165f04ed75154c361471cb833f7bd7d6068676..d16b9e2c7be9ef2d40cb0f4de6e25418d02642f5 100644 (file)
@@ -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);
index 6405a8704cca849f86dbe654fbb36b7d77b5cb64..8315b6116bbc20ca76fde7e819e724296cd5387f 100644 (file)
@@ -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);
index ce2483061a5cef7b0d9d8de017bbea705131cb48..c4bd001e827ec4e6b0516c282ad91b06d33dc95c 100644 (file)
@@ -45,7 +45,6 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
        const char *family = "IP4";
        const char *username = tech_pvt->profile->username;
 
-
        //sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA);
        
        if (!ip) {
@@ -121,7 +120,7 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
                                        t38_options->T38FaxMaxBuffer, 
                                        t38_options->T38FaxMaxDatagram, 
                                        t38_options->T38FaxUdpEC, 
-                                       t38_options->T38VendorInfo);
+                                       t38_options->T38VendorInfo ? t38_options->T38VendorInfo : "0 0 0");
        
 
 
@@ -3225,8 +3224,6 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha
 
 switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, const char *r_sdp)
 {
-       sdp_parser_t *parser = NULL;
-       sdp_session_t *sdp;
        uint8_t match = 0;
 
        switch_assert(tech_pvt != NULL);
@@ -3236,18 +3233,7 @@ switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, const char *r_
                return SWITCH_STATUS_FALSE;
        }
 
-       if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
-
-               if (tech_pvt->num_codecs) {
-                       if ((sdp = sdp_session(parser))) {
-                               match = sofia_glue_negotiate_sdp(tech_pvt->session, sdp);
-                       }
-               }
-
-               sdp_parser_free(parser);
-       }
-
-       if (match) {
+       if ((match = sofia_glue_negotiate_sdp(tech_pvt->session, r_sdp))) {
                if (sofia_glue_tech_choose_port(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
                        return SWITCH_STATUS_FALSE;
                }
@@ -3287,7 +3273,7 @@ void sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly)
                        if (tech_pvt->max_missed_hold_packets) {
                                switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_hold_packets);
                        }
-
+                       
                        if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
                                stream = tech_pvt->profile->hold_music;
                        }
@@ -3344,7 +3330,112 @@ void sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly)
        }
 }
 
-uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
+void sofia_glue_copy_t38_options(switch_t38_options_t *t38_options, switch_core_session_t *session)
+{
+       switch_channel_t *channel = switch_core_session_get_channel(session);
+       switch_t38_options_t *local_t38_options = switch_channel_get_private(channel, "t38_options");
+
+       if (!local_t38_options) {
+               local_t38_options = switch_core_session_alloc(session, sizeof(switch_t38_options_t));
+       }
+
+       local_t38_options->T38MaxBitRate = t38_options->T38MaxBitRate;
+       local_t38_options->T38FaxFillBitRemoval = t38_options->T38FaxFillBitRemoval;
+       local_t38_options->T38FaxTranscodingMMR = t38_options->T38FaxTranscodingMMR;
+       local_t38_options->T38FaxTranscodingJBIG = t38_options->T38FaxTranscodingJBIG;
+       local_t38_options->T38FaxRateManagement = t38_options->T38FaxRateManagement;
+       local_t38_options->T38FaxMaxBuffer = t38_options->T38FaxMaxBuffer;
+       local_t38_options->T38FaxMaxDatagram = t38_options->T38FaxMaxDatagram;
+       local_t38_options->T38FaxUdpEC = t38_options->T38FaxUdpEC;
+       local_t38_options->T38VendorInfo = t38_options->T38VendorInfo;
+       local_t38_options->ip = NULL;
+       local_t38_options->port = 0;
+       
+
+       switch_channel_set_private(channel, "t38_options", local_t38_options);
+       
+}
+static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_session_t *sdp, sdp_media_t *m)
+{
+       switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
+       sdp_attribute_t *attr;
+
+       if (!t38_options) {
+               t38_options = switch_core_session_alloc(tech_pvt->session, sizeof(switch_t38_options_t));
+       }
+                       
+       t38_options->port = m->m_port;
+       
+       if (m->m_connections) {
+               t38_options->ip = switch_core_session_strdup(tech_pvt->session, m->m_connections->c_address);
+       } else if (sdp && sdp->sdp_connection) {
+               t38_options->ip = switch_core_session_strdup(tech_pvt->session, sdp->sdp_connection->c_address);
+       }
+       
+       for (attr = m->m_attributes; attr; attr = attr->a_next) {
+               if (!strcasecmp(attr->a_name, "T38FaxVersion") && attr->a_value) {
+                       t38_options->T38FaxVersion = (uint16_t) atoi(attr->a_value);
+               } else if (!strcasecmp(attr->a_name, "T38MaxBitRate") && attr->a_value) {
+                       t38_options->T38MaxBitRate = (uint32_t) atoi(attr->a_value);
+               } else if (!strcasecmp(attr->a_name, "T38FaxFillBitRemoval")) {
+                       t38_options->T38FaxFillBitRemoval = SWITCH_TRUE;
+               } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingMMR")) {
+                       t38_options->T38FaxTranscodingMMR = SWITCH_TRUE;
+               } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingJBIG")) {
+                       t38_options->T38FaxTranscodingJBIG = SWITCH_TRUE;
+               } else if (!strcasecmp(attr->a_name, "T38FaxRateManagement") && attr->a_value) {
+                       t38_options->T38FaxRateManagement = switch_core_session_strdup(tech_pvt->session, attr->a_value);
+               } else if (!strcasecmp(attr->a_name, "T38FaxMaxBuffer") && attr->a_value) {
+                       t38_options->T38FaxMaxBuffer = (uint32_t) atoi(attr->a_value);
+               } else if (!strcasecmp(attr->a_name, "T38FaxMaxDatagram") && attr->a_value) {
+                       t38_options->T38FaxMaxDatagram = (uint32_t) atoi(attr->a_value);
+               } else if (!strcasecmp(attr->a_name, "T38FaxUdpEC") && attr->a_value) {
+                       t38_options->T38FaxUdpEC = switch_core_session_strdup(tech_pvt->session, attr->a_value);
+               } else if (!strcasecmp(attr->a_name, "T38VendorInfo") && attr->a_value) {
+                       t38_options->T38VendorInfo = switch_core_session_strdup(tech_pvt->session, attr->a_value);
+               }
+       }
+
+       switch_channel_set_variable(tech_pvt->channel, "has_t38", "true");
+       switch_channel_set_private(tech_pvt->channel, "t38_options", t38_options);
+       switch_channel_set_app_flag(tech_pvt->channel, CF_APP_T38);
+       
+       return t38_options;
+}
+
+switch_t38_options_t *sofia_glue_extract_t38_options(switch_core_session_t *session, const char *r_sdp)
+{
+       sdp_media_t *m;
+       sdp_parser_t *parser = NULL;
+       sdp_session_t *sdp;
+       private_object_t *tech_pvt = switch_core_session_get_private(session);
+       switch_t38_options_t *t38_options = NULL;
+
+       if (!(parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
+               return 0;
+       }
+
+       if (!(sdp = sdp_session(parser))) {
+               sdp_parser_free(parser);
+               return 0;
+       }
+
+       switch_assert(tech_pvt != NULL);
+
+       for (m = sdp->sdp_media; m; m = m->m_next) {
+               if (m->m_proto == sdp_proto_udptl && m->m_type == sdp_media_image && m->m_port) {
+                       t38_options = tech_process_udptl(tech_pvt, sdp, m);
+                       break;
+               }
+       }
+       
+       sdp_parser_free(parser);
+
+       return t38_options;
+
+}
+
+uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_sdp)
 {
        uint8_t match = 0;
        switch_payload_t te = 0, cng_pt = 0;
@@ -3361,6 +3452,17 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
        const char *crypto = NULL;
        int got_crypto = 0, got_audio = 0, got_avp = 0, got_savp = 0, got_udptl = 0;
        int scrooge = 0;
+       sdp_parser_t *parser = NULL;
+       sdp_session_t *sdp;
+       
+       if (!(parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
+               return 0;
+       }
+
+       if (!(sdp = sdp_session(parser))) {
+               sdp_parser_free(parser);
+               return 0;
+       }
 
        switch_assert(tech_pvt != NULL);
 
@@ -3432,6 +3534,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
 
        for (m = sdp->sdp_media; m; m = m->m_next) {
                sdp_connection_t *connection;
+               switch_core_session_t *other_session;
 
                ptime = dptime;
                maxptime = dmaxptime;
@@ -3445,47 +3548,42 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
                }
 
                if (got_udptl && m->m_type == sdp_media_image && m->m_port) {
-                       switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
-
-                       if (!t38_options) {
-                               t38_options = switch_core_session_alloc(tech_pvt->session, sizeof(switch_t38_options_t));
-                       }
-                       
-                       t38_options->port = m->m_port;
+                       switch_t38_options_t *t38_options = tech_process_udptl(tech_pvt, sdp, m);
+                                               
+                       if (switch_true(switch_channel_get_variable(channel, "refuse_t38"))) {
+                               match = 0;
+                               goto done;
+                       } else {
+                               const char *var = switch_channel_get_variable(channel, "t38_passthru");
+                               int pass = sofia_test_pflag(tech_pvt->profile, PFLAG_T38_PASSTHRU);
 
-                       if (m->m_connections) {
-                               t38_options->ip = switch_core_session_strdup(tech_pvt->session, m->m_connections->c_address);
-                       } else if (sdp && sdp->sdp_connection) {
-                               t38_options->ip = switch_core_session_strdup(tech_pvt->session, sdp->sdp_connection->c_address);
-                       }
+                               if (var) {
+                                       pass = switch_true(var);
+                               }
+                               
+                               if (sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
+                                       pass = 0;
+                               }
 
-                       for (attr = m->m_attributes; attr; attr = attr->a_next) {
-                                if (!strcasecmp(attr->a_name, "T38FaxVersion") && attr->a_value) {
-                                        t38_options->T38FaxVersion = (uint16_t) atoi(attr->a_value);
-                               } else if (!strcasecmp(attr->a_name, "T38MaxBitRate") && attr->a_value) {
-                                       t38_options->T38MaxBitRate = (uint32_t) atoi(attr->a_value);
-                               } else if (!strcasecmp(attr->a_name, "T38FaxFillBitRemoval")) {
-                                       t38_options->T38FaxFillBitRemoval = SWITCH_TRUE;
-                               } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingMMR")) {
-                                       t38_options->T38FaxTranscodingMMR = SWITCH_TRUE;
-                               } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingJBIG")) {
-                                       t38_options->T38FaxTranscodingJBIG = SWITCH_TRUE;
-                               } else if (!strcasecmp(attr->a_name, "T38FaxRateManagement") && attr->a_value) {
-                                       t38_options->T38FaxRateManagement = switch_core_session_strdup(tech_pvt->session, attr->a_value);
-                               } else if (!strcasecmp(attr->a_name, "T38FaxMaxBuffer") && attr->a_value) {
-                                       t38_options->T38FaxMaxBuffer = (uint32_t) atoi(attr->a_value);
-                               } else if (!strcasecmp(attr->a_name, "T38FaxMaxDatagram") && attr->a_value) {
-                                       t38_options->T38FaxMaxDatagram = (uint32_t) atoi(attr->a_value);
-                               } else if (!strcasecmp(attr->a_name, "T38FaxUdpEC") && attr->a_value) {
-                                       t38_options->T38FaxUdpEC = switch_core_session_strdup(tech_pvt->session, attr->a_value);
-                               } else if (!strcasecmp(attr->a_name, "T38VendorInfo") && attr->a_value) {
-                                       t38_options->T38VendorInfo = switch_core_session_strdup(tech_pvt->session, attr->a_value);
+                               if (pass && switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
+                                       private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
+                                       switch_core_session_message_t *msg;
+                                       sofia_glue_copy_t38_options(t38_options, other_session);
+                                       
+                                       sofia_set_flag(tech_pvt, TFLAG_T38_PASSTHRU);
+                                       sofia_set_flag(other_tech_pvt, TFLAG_T38_PASSTHRU);
+                               
+                                       msg = switch_core_session_alloc(other_session, sizeof(*msg));
+                                       msg->message_id = SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA;
+                                       msg->from = __FILE__;
+                                       msg->string_arg = switch_core_session_strdup(other_session, r_sdp);
+                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing T38 req to other leg.\n%s\n", r_sdp);
+                                       switch_core_session_queue_message(other_session, msg);
+                                       switch_core_session_rwunlock(other_session);
                                }
                        }
                        
-                       switch_channel_set_variable(tech_pvt->channel, "has_t38", "true");
-                       switch_channel_set_private(tech_pvt->channel, "t38_options", t38_options);
-                       switch_channel_set_app_flag(tech_pvt->channel, CF_APP_T38);
+
                        /* do nothing here, mod_fax will trigger a response (if it's listening =/)*/
                        match = 1;
                        goto done;
@@ -3887,6 +3985,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
        }
 
   done:
+
+       if (parser) sdp_parser_free(parser);
+
        tech_pvt->cng_pt = cng_pt;
        sofia_set_flag_locked(tech_pvt, TFLAG_SDP);
 
index 623b7e56b2012618606104662b1bb4a0bc505a67..42c3f51e9d08cb16b0f7b3c39dfffb25eaad6e28 100644 (file)
@@ -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();
                        }