[Freeswitch-svn] [commit] r4138 - in freeswitch/trunk/src: include mod/applications/mod_bridgecall

Freeswitch SVN anthm at freeswitch.org
Tue Feb 6 14:15:27 EST 2007


Author: anthm
Date: Tue Feb  6 14:15:26 2007
New Revision: 4138

Modified:
   freeswitch/trunk/src/include/switch_utils.h
   freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c

Log:
yes virginia, sip has shortcommings

Modified: freeswitch/trunk/src/include/switch_utils.h
==============================================================================
--- freeswitch/trunk/src/include/switch_utils.h	(original)
+++ freeswitch/trunk/src/include/switch_utils.h	Tue Feb  6 14:15:26 2007
@@ -270,7 +270,7 @@
 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

Modified: freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_bridgecall/mod_bridgecall.c	Tue Feb  6 14:15:26 2007
@@ -81,6 +81,25 @@
 		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);



More information about the Freeswitch-svn mailing list