]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
set rtp stack into optimal mode for transferring data during fax situations (that...
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 8 Dec 2011 18:26:31 +0000 (12:26 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 8 Dec 2011 18:26:36 +0000 (12:26 -0600)
src/include/switch_types.h
src/mod/applications/mod_spandsp/mod_spandsp.c
src/mod/applications/mod_spandsp/mod_spandsp.h
src/mod/applications/mod_spandsp/mod_spandsp_modem.c
src/mod/endpoints/mod_sofia/mod_sofia.c

index b35c73c5678c2c6d986d3e7bb84bbb8a311edd9c..d88d0539f79020f994737116e68d6b27fda67723 100644 (file)
@@ -872,6 +872,7 @@ typedef enum {
        SWITCH_MESSAGE_INDICATE_RECOVERY_REFRESH,
        SWITCH_MESSAGE_INDICATE_SIGNAL_DATA,
        SWITCH_MESSAGE_INDICATE_INFO,
+       SWITCH_MESSAGE_INDICATE_AUDIO_DATA,
        SWITCH_MESSAGE_INVALID
 } switch_core_session_message_types_t;
 
index a5730a73f70405939af4fa08e373998fbc4861be..aa9d434868070ec1d63363f99ca22b532630dba1 100644 (file)
@@ -264,6 +264,40 @@ SWITCH_STANDARD_API(stop_tone_detect_api)
 }
 
 
+void mod_spandsp_indicate_data(switch_core_session_t *session, switch_bool_t self, switch_bool_t on)
+{
+    switch_core_session_t *target_session = NULL;
+    int locked = 0;
+
+    if (self) {
+        target_session = session;
+    } else {
+        if (switch_core_session_get_partner(session, &target_session) == SWITCH_STATUS_SUCCESS) {
+            locked = 1;
+        } else {
+            target_session = NULL;
+        }
+    }
+
+    if (target_session) {
+        switch_core_session_message_t *msg;
+        
+        msg = switch_core_session_alloc(target_session, sizeof(*msg));
+        MESSAGE_STAMP_FFL(msg);
+        msg->message_id = SWITCH_MESSAGE_INDICATE_AUDIO_DATA;
+        msg->from = __FILE__;
+        msg->numeric_arg = on;
+               
+        switch_core_session_queue_message(target_session, msg);
+
+        if (locked) {
+            switch_core_session_rwunlock(target_session);
+            locked = 0;
+        }
+    }
+}
+
+
 /* **************************************************************************
    CONFIGURATION
    ************************************************************************* */
index d803f6bf7f0ff0b5921a89f755154cf5315b15e8..8c907c75ac827ae4b2baa664354a1d34cdf5d213 100644 (file)
@@ -138,3 +138,4 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session,
 switch_status_t spandsp_fax_stop_detect_session(switch_core_session_t *session);
 void spanfax_log_message(int level, const char *msg);
 switch_status_t load_configuration(switch_bool_t reload);
+void mod_spandsp_indicate_data(switch_core_session_t *session, switch_bool_t self, switch_bool_t on);
index 01f92e272b1270f9eb7e9f94ab6060a3663b326f..a419b3cd1acbe81b39e2e0c77a9d09c0949a6e43 100644 (file)
@@ -650,7 +650,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
 {
        switch_channel_t *channel;
        private_t *tech_pvt;
-       
+
        channel = switch_core_session_get_channel(session);
        switch_assert(channel != NULL);
 
@@ -661,16 +661,23 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
        case SWITCH_MESSAGE_INDICATE_ANSWER:
                t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_CONNECTED);
                modem_set_state(tech_pvt->modem, MODEM_STATE_CONNECTED);
+               mod_spandsp_indicate_data(session, SWITCH_FALSE, SWITCH_TRUE);
                break;
        case SWITCH_MESSAGE_INDICATE_PROGRESS:
                t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_CONNECTED);
                modem_set_state(tech_pvt->modem, MODEM_STATE_CONNECTED);
+               mod_spandsp_indicate_data(session, SWITCH_FALSE, SWITCH_TRUE);
                break;
        case SWITCH_MESSAGE_INDICATE_RINGING:
                break;
        case SWITCH_MESSAGE_INDICATE_BRIDGE:
+               mod_spandsp_indicate_data(session, SWITCH_FALSE, SWITCH_TRUE);
+                               
                break;
        case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
+
+               mod_spandsp_indicate_data(session, SWITCH_FALSE, SWITCH_TRUE);
+
                break;
        default:
                break;
@@ -743,6 +750,7 @@ static void tech_attach(private_t *tech_pvt, modem_t *modem)
        switch_channel_set_variable_printf(tech_pvt->channel, "modem_slot", "%d", modem->slot);
        switch_channel_set_variable(tech_pvt->channel, "modem_devlink", modem->devlink);
        switch_channel_set_variable(tech_pvt->channel, "modem_digits", modem->digits);
+       switch_channel_export_variable(tech_pvt->channel, "rtp_autoflush_during_bridge", "false", SWITCH_EXPORT_VARS_VARIABLE);
 }
 
 
index 31ef7884d947eea14a2a67bd63f87d86887c647d..e6d68edf2441d02116e0f58150f3a4105453034d 100644 (file)
@@ -1785,6 +1785,28 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                }
                break;
 
+       case SWITCH_MESSAGE_INDICATE_AUDIO_DATA:
+               {
+                       if (switch_rtp_ready(tech_pvt->rtp_session)) {
+                               if (msg->numeric_arg) {
+                                       if (switch_channel_test_flag(tech_pvt->channel, CF_JITTERBUFFER)) {
+                                               switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_TRUE);
+                                               sofia_set_flag(tech_pvt, TFLAG_JB_PAUSED);
+                                       }
+
+                                       rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_UNSTICK);
+                                       
+                               } else {
+                                       if (sofia_test_flag(tech_pvt, TFLAG_JB_PAUSED)) {
+                                               sofia_clear_flag(tech_pvt, TFLAG_JB_PAUSED);
+                                               if (switch_channel_test_flag(tech_pvt->channel, CF_JITTERBUFFER)) {
+                                                       switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_FALSE);
+                                               }
+                                       }
+                               }
+                       }
+               }
+               break;
        case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
                {
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Sending media re-direct:\n%s\n",