]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add t38 skeleton
authorBrian West <brian@freeswitch.org>
Tue, 30 Dec 2008 19:50:33 +0000 (19:50 +0000)
committerBrian West <brian@freeswitch.org>
Tue, 30 Dec 2008 19:50:33 +0000 (19:50 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11006 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_core_session.c

index efb3fbf61af3d8ccee41bee386149f8ab1b55b12..fd2b6c37edc4cf1a80e85101f044393fe7a0546e 100644 (file)
@@ -606,9 +606,23 @@ typedef enum {
        SWITCH_MESSAGE_INDICATE_DISPLAY,
        SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY,
        SWITCH_MESSAGE_INDICATE_AUDIO_SYNC,
+       SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA,
        SWITCH_MESSAGE_INVALID
 } switch_core_session_message_types_t;
 
+typedef struct {
+       uint32_t T38MaxBitRate;
+       switch_bool_t T38FaxFillBitRemoval;
+       switch_bool_t T38FaxTranscodingMMR;
+       switch_bool_t T38FaxTranscodingJBIG;
+       const char *T38FaxRateManagement;
+       uint32_t T38FaxMaxBuffer;
+       uint32_t T38FaxMaxDatagram;
+       const char *T38FaxUdpEC;
+       const char *T38VendorInfo;
+       const char *ip;
+       uint32_t port;
+} switch_t38_options_t;
 
 /*!
   \enum switch_stack_t
index 9d1fe5beda7a2fbfe1a03c813b77e5b3b66cd9e1..ef6ab8b0bfc5ae2db9589d11313631c6a86ea3dc 100644 (file)
@@ -1054,13 +1054,30 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
 
        case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
                {
-                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending media re-direct:\n%s\n", msg->string_arg);
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Sending media re-direct:\n%s\n", 
+                                                         switch_channel_get_name(channel), msg->string_arg);
                        tech_pvt->local_sdp_str = switch_core_session_strdup(session, msg->string_arg);
                        switch_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
                        sofia_glue_do_invite(session);
                }
                break;
 
+
+       case SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA:
+               {
+                       switch_t38_options_t *t38_options = (switch_t38_options_t *) msg->pointer_arg;
+
+                       sofia_glue_set_image_sdp(tech_pvt, t38_options);
+
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Sending request for image media. %s\n", 
+                                                         switch_channel_get_name(channel), tech_pvt->local_sdp_str);
+                                                         
+                       
+                       switch_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
+                       sofia_glue_do_invite(session);
+               }
+               break;
+
        case SWITCH_MESSAGE_INDICATE_MEDIA:
                {
                        uint32_t send_invite = 1;
index c9401726a37aa136980a8ffd10879bbb4cdcc29b..98cd6ed1853262fe22a6e2b210135f17c180ae2c 100644 (file)
@@ -761,3 +761,4 @@ void sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly);
 const char * sofia_state_string(int state);
 switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force);
 void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout);
+void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *t38_options);
index a8cf75cfe850efc1468615d53fafdfc7560e7b68..ad300dd9b2d5b7151b3c96ac6c14f1f998c2f8e8 100644 (file)
 #include "mod_sofia.h"
 #include <switch_stun.h>
 
+void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *t38_options)
+{
+       char buf[2048];
+       const char *ip = t38_options->ip;
+       uint32_t port = t38_options->port;
+       const char *family = "IP4";
+
+       if (!ip) {
+               if (!(ip = tech_pvt->adv_sdp_audio_ip)) {
+                       ip = tech_pvt->proxy_sdp_audio_ip;
+               }
+       }
+
+       if (!port) {
+               if (!(port = tech_pvt->adv_sdp_audio_port)) {
+                       port = tech_pvt->proxy_sdp_audio_port;
+               }
+       }
+
+       if (!tech_pvt->owner_id) {
+               tech_pvt->owner_id = (uint32_t) switch_timestamp(NULL) - port;
+       }
+
+       if (!tech_pvt->session_id) {
+               tech_pvt->session_id = tech_pvt->owner_id;
+       }
+
+       tech_pvt->session_id++;
+
+       family = strchr(ip, ':') ? "IP6" : "IP4";
+       switch_snprintf(buf, sizeof(buf),
+                                       "v=0\n"
+                                       "o=FreeSWITCH %010u %010u IN %s %s\n"
+                                       "s=FreeSWITCH\n"
+                                       "c=IN %s %s\n" 
+                                       "t=0 0\n"
+                                       "m=image %d udptl t38\n", 
+                                       "a=T38MaxBitRate:%d\n"
+                                       "%s"
+                                       "%s"
+                                       "%s"
+                                       "a=T38FaxRateManagement:%s\n"
+                                       "a=T38FaxMaxBuffer:%d\n"
+                                       "a=T38FaxMaxDatagram:%d\n"
+                                       "a=T38FaxUdpEC:%s\n"
+                                       "a=T38VendorInfo:%s\n",
+                                       
+                                       tech_pvt->owner_id, 
+                                       tech_pvt->session_id,
+                                       family,
+                                       ip,
+                                       family,
+                                       ip,
+                                       port,
+                                       
+                                       t38_options->T38MaxBitRate,
+                                       t38_options->T38FaxFillBitRemoval ? "a=T38FaxFillBitRemoval\n" : "",
+                                       t38_options->T38FaxTranscodingMMR ? "a=T38FaxTranscodingMMR\n" : "",
+                                       t38_options->T38FaxTranscodingJBIG ? "a=T38FaxTranscodingJBIG\n" : "",
+                                       t38_options->T38FaxRateManagement,
+                                       t38_options->T38FaxMaxBuffer,
+                                       t38_options->T38FaxMaxDatagram,
+                                       t38_options->T38FaxUdpEC,
+                                       t38_options->T38VendorInfo
+                                       );
+       
+       
+       tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, buf);
+}
 
 void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32_t port, const char *sr, int force)
 {
@@ -2189,7 +2258,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
        switch_channel_t *channel = switch_core_session_get_channel(session);
        const char *val;
        const char *crypto = NULL;
-       int got_crypto = 0, got_audio = 0, got_avp = 0, got_savp = 0;
+       int got_crypto = 0, got_audio = 0, got_avp = 0, got_savp = 0, got_udptl = 0;
 
        switch_assert(tech_pvt != NULL);
 
@@ -2250,9 +2319,42 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
                        got_savp++;
                } else if (m->m_proto == sdp_proto_rtp) {
                        got_avp++;
+               } else if (m->m_proto == sdp_proto_udptl) {
+                       got_udptl++;
                }
 
-               if (m->m_type == sdp_media_audio && m->m_port && !got_audio) {
+               if (got_udptl && m->m_type == sdp_media_image && m->m_port) {
+                       switch_t38_options_t *t38_options = switch_core_session_alloc(tech_pvt->session, sizeof(switch_t38_options_t));
+                       
+                       for (attr = m->m_attributes; attr; attr = attr->a_next) {
+                               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_flag(tech_pvt->channel, CF_PROXY_MEDIA);
+                       switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA);
+
+               } else if (m->m_type == sdp_media_audio && m->m_port && !got_audio) {
                        sdp_rtpmap_t *map;
 
                        for (attr = m->m_attributes; attr; attr = attr->a_next) {
index 58f385304114002281789696b1eea4cb1516e945..fa51be2459886e31bc3386e791040adcd3ba52ae 100644 (file)
@@ -421,28 +421,29 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
 }
 
 static const char *message_names[] = {
-       "SWITCH_MESSAGE_REDIRECT_AUDIO",
-       "SWITCH_MESSAGE_TRANSMIT_TEXT",
-       "SWITCH_MESSAGE_INDICATE_ANSWER",
-       "SWITCH_MESSAGE_INDICATE_PROGRESS",
-       "SWITCH_MESSAGE_INDICATE_BRIDGE",
-       "SWITCH_MESSAGE_INDICATE_UNBRIDGE",
-       "SWITCH_MESSAGE_INDICATE_TRANSFER",
-       "SWITCH_MESSAGE_INDICATE_RINGING",
-       "SWITCH_MESSAGE_INDICATE_MEDIA",
-       "SWITCH_MESSAGE_INDICATE_NOMEDIA",
-       "SWITCH_MESSAGE_INDICATE_HOLD",
-       "SWITCH_MESSAGE_INDICATE_UNHOLD",
-       "SWITCH_MESSAGE_INDICATE_REDIRECT",
-       "SWITCH_MESSAGE_INDICATE_RESPOND",
-       "SWITCH_MESSAGE_INDICATE_BROADCAST",
-       "SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT",
-       "SWITCH_MESSAGE_INDICATE_DEFLECT",
-       "SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ",
-       "SWITCH_MESSAGE_INDICATE_DISPLAY",
-       "SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY",
-       "SWITCH_MESSAGE_INDICATE_AUDIO_SYNC",
-       "SWITCH_MESSAGE_INVALID"
+       "REDIRECT_AUDIO",
+       "TRANSMIT_TEXT",
+       "ANSWER",
+       "PROGRESS",
+       "BRIDGE",
+       "UNBRIDGE",
+       "TRANSFER",
+       "RINGING",
+       "MEDIA",
+       "NOMEDIA",
+       "HOLD",
+       "UNHOLD",
+       "REDIRECT",
+       "RESPOND",
+       "BROADCAST",
+       "MEDIA_REDIRECT",
+       "DEFLECT",
+       "VIDEO_REFRESH_REQ",
+       "DISPLAY",
+       "TRANSCODING_NECESSARY",
+       "AUDIO_SYNC",
+       "REQUEST_IMAGE_MEDIA",
+       "INVALID"
 };
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(switch_core_session_t *session,