]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
yes virginia, sip has shortcommings
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 6 Feb 2007 19:15:26 +0000 (19:15 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 6 Feb 2007 19:15:26 +0000 (19:15 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4138 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_utils.h
src/mod/applications/mod_bridgecall/mod_bridgecall.c

index 072b31c5dca926e2d5ec5f21b416a9e671720dd7..9802730137900e3af5679e9d6735ed7d20350246 100644 (file)
@@ -270,7 +270,7 @@ SWITCH_DECLARE(switch_status_t) switch_string_match(const char *string, size_t s
 SWITCH_DECLARE(int) switch_perform_regex(char *field, char *expression, pcre **new_re, int *ovector, uint32_t olen);
 SWITCH_DECLARE(void) switch_perform_substitution(pcre *re, int match_count, char *data, char *field_data, char *substituted, uint32_t len, int *ovector);
 
-#define SWITCH_READ_ACCEPTABLE(status) status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK
+#define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK)
 SWITCH_DECLARE(size_t) switch_url_encode(char *url, char *buf, size_t len);
 SWITCH_DECLARE(char *) switch_url_decode(char *s);
 SWITCH_END_EXTERN_C
index b982fce52cb1697e3dbed7322ece950c9697279c..c90bfd51c2ff63b6c68768d347e12fd02c6230ca 100644 (file)
@@ -81,6 +81,25 @@ static void audio_bridge_function(switch_core_session_t *session, char *data)
                return;
        } else {
                if (no_media_bridge) {
+            switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
+            switch_frame_t *read_frame;
+
+            /* SIP won't let us redir media until the call has been answered #$^#%& so we will proxy any early media until they do */
+            while(switch_channel_ready(caller_channel) && switch_channel_ready(peer_channel) && !switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
+                switch_status_t status = switch_core_session_read_frame(peer_session, &read_frame, -1, 0);
+                uint8_t bad = 1;
+
+                if (SWITCH_READ_ACCEPTABLE(status) && switch_core_session_write_frame(session, read_frame, -1, 0) == SWITCH_STATUS_SUCCESS) {
+                    bad = 0;
+                }
+                
+                if (bad) {
+                    switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+                    switch_channel_hangup(peer_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+                    return;
+                }
+            }
+
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Redirecting media to point-to-point mode.\n");
                        switch_ivr_nomedia(switch_core_session_get_uuid(session), SMF_FORCE);
                        switch_ivr_nomedia(switch_core_session_get_uuid(peer_session), SMF_FORCE);