From b42e38793810cc08c802c05756651ffb0d05161e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 6 Feb 2007 19:15:26 +0000 Subject: [PATCH] yes virginia, sip has shortcommings git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4138 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_utils.h | 2 +- .../mod_bridgecall/mod_bridgecall.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 072b31c5dc..9802730137 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -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 diff --git a/src/mod/applications/mod_bridgecall/mod_bridgecall.c b/src/mod/applications/mod_bridgecall/mod_bridgecall.c index b982fce52c..c90bfd51c2 100644 --- a/src/mod/applications/mod_bridgecall/mod_bridgecall.c +++ b/src/mod/applications/mod_bridgecall/mod_bridgecall.c @@ -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);