[Freeswitch-svn] [commit] r7075 - in freeswitch/trunk: conf/autoload_configs conf/dialplan libs/libedit scripts/socket src src/include src/mod/applications/mod_commands src/mod/applications/mod_conference src/mod/applications/mod_fifo src/mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Thu Jan 3 16:34:45 EST 2008


Author: anthm
Date: Thu Jan  3 16:34:44 2008
New Revision: 7075

Modified:
   freeswitch/trunk/conf/autoload_configs/conference.conf.xml
   freeswitch/trunk/conf/dialplan/default.xml
   freeswitch/trunk/libs/libedit/configure
   freeswitch/trunk/scripts/socket/sock.pl
   freeswitch/trunk/src/include/switch_ivr.h
   freeswitch/trunk/src/include/switch_module_interfaces.h
   freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/trunk/src/switch_core_io.c
   freeswitch/trunk/src/switch_event.c
   freeswitch/trunk/src/switch_ivr_async.c
   freeswitch/trunk/src/switch_rtp.c
   freeswitch/trunk/src/switch_time.c

Log:
cross t's and dot i's

Modified: freeswitch/trunk/conf/autoload_configs/conference.conf.xml
==============================================================================
--- freeswitch/trunk/conf/autoload_configs/conference.conf.xml	(original)
+++ freeswitch/trunk/conf/autoload_configs/conference.conf.xml	Thu Jan  3 16:34:44 2008
@@ -68,7 +68,7 @@
       <!-- File to play when you're alone (music on hold)-->
       <param name="moh-sound" value="$${moh_uri}"/>
       <!-- File to play when you join the conference -->
-      <!--<param name="enter-sound" value="welcome.wav"/>-->
+      <param name="enter-sound" value="tone_stream://%(1000,0,500)"/>
       <!-- File to play when you leave the conference -->
       <!--<param name="exit-sound" value="exit.wav"/>-->
       <!-- File to play when you ae ejected from the conference -->

Modified: freeswitch/trunk/conf/dialplan/default.xml
==============================================================================
--- freeswitch/trunk/conf/dialplan/default.xml	(original)
+++ freeswitch/trunk/conf/dialplan/default.xml	Thu Jan  3 16:34:44 2008
@@ -98,6 +98,7 @@
     </extension>
 
     <extension name="extension-intercom">
+      <condition field="${sip_to_params}" expression="intercom\=true" continue="on-true"/>
       <condition field="destination_number" expression="^8(10[01][0-9])$">
 	<action application="set" data="dialed_ext=$1"/>
 	<action application="export" data="sip_h_Call-Info=<sip:$${domain}>;answer-after=0"/>
@@ -166,7 +167,7 @@
     </extension>
 
     <extension name="rtp_multicast_page">
-      <condition field="destination_number" expression="^pagegroup$">
+      <condition field="destination_number" expression="^pagegroup$|^7243">
 	<action application="esf_page_group"/>
       </condition>
     </extension>
@@ -215,6 +216,13 @@
       </condition>
     </extension>
 
+    <extension name="milliwatt">
+      <condition field="destination_number" expression="^9997$">
+	<action application="answer"/>
+	<action application="playback" data="tone_stream://%(10000,0,1004);loops=-1"/>
+      </condition>
+    </extension>
+
     <extension name="tone_stream">
       <condition field="destination_number" expression="^9998$">
 	<action application="answer"/>

Modified: freeswitch/trunk/libs/libedit/configure
==============================================================================
--- freeswitch/trunk/libs/libedit/configure	(original)
+++ freeswitch/trunk/libs/libedit/configure	Thu Jan  3 16:34:44 2008
@@ -420,7 +420,7 @@
 
 # Identity of this package.
 PACKAGE_NAME='libedit'
-PACKAGE_TARNAME='libedit-20071219'
+PACKAGE_TARNAME='libedit-20071230'
 PACKAGE_VERSION='2.10'
 PACKAGE_STRING='libedit 2.10'
 PACKAGE_BUGREPORT=''
@@ -1816,7 +1816,7 @@
 
 
 # Define the identity of the package.
- PACKAGE='libedit-20071219'
+ PACKAGE='libedit-20071230'
  VERSION='2.10'
 
 

Modified: freeswitch/trunk/scripts/socket/sock.pl
==============================================================================
--- freeswitch/trunk/scripts/socket/sock.pl	(original)
+++ freeswitch/trunk/scripts/socket/sock.pl	Thu Jan  3 16:34:44 2008
@@ -22,7 +22,7 @@
 $o = $fs->call_command("answer");
 #to turn on events when in async mode
 $o = $fs->raw_command("myevents");
-$o = $fs->call_command("playback", "/ram/swimp.raw");
+$o = $fs->call_command("echo");
 
 
 #comment exit in async mode
@@ -38,6 +38,7 @@
   }
   if ($r->{event}->{'event-name'} !~ /execute/i) {
     printf "wtf $data->{'unique-id'}\n";
+    print ".";
     $o = $fs->call_command("break");
     $o = $fs->call_command("hangup");
   }

Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h	(original)
+++ freeswitch/trunk/src/include/switch_ivr.h	Thu Jan  3 16:34:44 2008
@@ -205,7 +205,7 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh);
 SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, const char *uuid, switch_eavesdrop_flag_t flags);
-SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, char *file, uint32_t limit, const char *flags);
+SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags);
 SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, const char *file);
 
 /*!

Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h	(original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h	Thu Jan  3 16:34:44 2008
@@ -195,6 +195,8 @@
 	switch_memory_pool_t *memory_pool;
 	/*! private data for loadable modules to store information */
 	void *private_info;
+	/*! remaining time from last call to _check()*/
+	switch_size_t diff;
 };
 
 typedef enum {

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Thu Jan  3 16:34:44 2008
@@ -2028,7 +2028,7 @@
 					}
 					
 					switch_assert(buf);
-					stream->write_function(stream, buf);
+					stream->raw_write_function(stream, (unsigned char *)buf, strlen(buf));
 					switch_event_destroy(&event);
 					free(buf);
 				} else {

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Thu Jan  3 16:34:44 2008
@@ -558,7 +558,7 @@
 				conference_stop_file(conference, FILE_STOP_ASYNC);
 			}
 			if(conference->enter_sound) {
-				conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
+				conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 1);
 			}
 		}
 
@@ -808,7 +808,7 @@
 			/* Lead in time */
 			if (conference->fnode->leadin) {
 				conference->fnode->leadin--;
-			} else {
+			} else if (!conference->fnode->done) {
 				file_sample_len = samples;
 				if (conference->fnode->type == NODE_TYPE_SPEECH) {
 					switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
@@ -837,7 +837,7 @@
 			/* Lead in time */
 			if (conference->async_fnode->leadin) {
 				conference->async_fnode->leadin--;
-			} else {
+			} else if (!conference->async_fnode->done) {
 				file_sample_len = samples;
 				switch_core_file_read(&conference->async_fnode->fh, async_file_frame, &file_sample_len);
 				if (file_sample_len <= 0) {

Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c	Thu Jan  3 16:34:44 2008
@@ -84,6 +84,7 @@
     switch_hash_t *fifo_hash;
     switch_mutex_t *mutex;
     switch_memory_pool_t *pool;
+    int running;
 } globals;
 
 
@@ -105,6 +106,10 @@
 {
     fifo_node_t *node;
 
+    if (!globals.running) {
+        return NULL;
+    }
+
     node = switch_core_alloc(globals.pool, sizeof(*node));
     node->name = switch_core_strdup(globals.pool, name);
 
@@ -122,6 +127,10 @@
 {
     switch_event_t *event;
 
+    if (!globals.running) {
+        return;
+    }
+
 	if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "%s", "park");
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", node->name);
@@ -139,7 +148,6 @@
         switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", node->waiting_count > 0 ? "CS_RING" : "CS_HANGUP");
         switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", node->name);
         switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", node->waiting_count > 0 ? "early" : "terminated");
-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "astate", "%s", node->waiting_count > 0 ? "early" : "terminated");
         switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-direction", "%s", "inbound");
 		switch_event_fire(&event);
 	}
@@ -151,6 +159,10 @@
 	char *to = switch_event_get_header(event, "to");
 	char *dup_to = NULL, *node_name;
     fifo_node_t *node;
+
+    if (!globals.running) {
+        return;
+    }
     
 	if (!to || strncasecmp(to, "park+", 5)) {
 		return;
@@ -192,7 +204,9 @@
     switch_time_t ts = switch_timestamp_now();
     switch_size_t retsize;
 
-
+    if (!globals.running) {
+        return;
+    }
 
 
     if (switch_strlen_zero(data)) {
@@ -577,6 +591,11 @@
     const void *var;
     int x = 0, verbose = 0;
 
+
+    if (!globals.running) {
+        return SWITCH_STATUS_FALSE;
+    }
+
     if (!switch_strlen_zero(cmd)) {
         data = strdup(cmd);
         switch_assert(data);
@@ -672,6 +691,7 @@
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 	SWITCH_ADD_APP(app_interface, "fifo", "Park with FIFO", FIFO_DESC, fifo_function, FIFO_USAGE, SAF_NONE);
     SWITCH_ADD_API(commands_api_interface, "fifo", "Return data about a fifo", fifo_api_function, FIFO_API_SYNTAX);
+    globals.running = 1;
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -684,7 +704,10 @@
     switch_hash_index_t *hi;
     void *val, *pop;
     fifo_node_t *node;
+    switch_memory_pool_t *pool = globals.pool;
     switch_mutex_lock(globals.mutex);
+
+    globals.running = 0;
     /* Cleanup*/
     for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
         switch_hash_this(hi, NULL, NULL, &val);
@@ -695,9 +718,11 @@
         switch_core_hash_destroy(&node->caller_hash);
         switch_core_hash_destroy(&node->consumer_hash);
     }
-    switch_mutex_unlock(globals.mutex);
     switch_core_hash_destroy(&globals.fifo_hash);
-    switch_core_destroy_memory_pool(&globals.pool);
+    memset(&globals, 0, sizeof(globals));
+    switch_mutex_unlock(globals.mutex);
+    
+    switch_core_destroy_memory_pool(&pool);
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Thu Jan  3 16:34:44 2008
@@ -252,30 +252,11 @@
 	cause = switch_channel_get_cause(channel);
 
 	if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) && cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
-		const char *buuid;
-		switch_core_session_t *bsession;
-		switch_channel_t *bchannel;
-		const char *lost_ext;
-		
-		
+
 		if (tech_pvt->max_missed_packets) {
 			switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
 		}
 		switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
-		if ((buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
-			if ((bsession = switch_core_session_locate(buuid))) {
-				bchannel = switch_core_session_get_channel(bsession);
-				if (switch_channel_test_flag(bchannel, CF_BROADCAST)) {
-					if ((lost_ext = switch_channel_get_variable(bchannel, "left_hanging_extension"))) {
-						switch_ivr_session_transfer(bsession, lost_ext, NULL, NULL);
-					}
-					switch_channel_clear_flag(bchannel, CF_BROADCAST);
-					switch_channel_set_flag(bchannel, CF_BREAK);
-				}
-				switch_core_session_rwunlock(bsession);
-			}
-		} 
-		
 		switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 		
 	}

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Thu Jan  3 16:34:44 2008
@@ -1382,25 +1382,38 @@
 	if (sendonly) {
 		if (!switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
 			const char *stream;
+
 			switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 			switch_channel_presence(tech_pvt->channel, "unknown", "hold");
+
 			if (tech_pvt->max_missed_packets) {
 				switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets * 10);
 			}
+
 			if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
 				stream = tech_pvt->profile->hold_music;
 			}
+
 			if (stream) {
-				switch_ivr_broadcast(switch_core_session_get_uuid(tech_pvt->session), stream, SMF_ECHO_BLEG | SMF_LOOP);
+				switch_ivr_displace_session(tech_pvt->session, stream, 0, "rl");
 			}
 		}
 	} else {
 		if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
-			switch_channel_clear_flag_partner(tech_pvt->channel, CF_BROADCAST);
+			const char *stream;
+
 			if (tech_pvt->max_missed_packets) {
 				switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
 			}
-			switch_channel_set_flag_partner(tech_pvt->channel, CF_BREAK);
+
+			if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
+                stream = tech_pvt->profile->hold_music;
+            }
+
+			if (stream) {
+                switch_ivr_stop_displace_session(tech_pvt->session, stream);
+            }
+
 			switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 			switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
 		}

Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c	(original)
+++ freeswitch/trunk/src/switch_core_io.c	Thu Jan  3 16:34:44 2008
@@ -94,7 +94,7 @@
 {
 	switch_io_event_hook_read_frame_t *ptr;
 	switch_status_t status;
-	int need_codec, perfect, do_bugs = 0, do_resample = 0;
+	int need_codec, perfect, do_bugs = 0, do_resample = 0, is_cng = 0;
 	unsigned int flag = 0;
   top:
 
@@ -131,11 +131,14 @@
 	switch_assert(session != NULL);
 	switch_assert(*frame != NULL);
 
-	
 	if (switch_test_flag(*frame, SFF_CNG)) {
 		status = SWITCH_STATUS_SUCCESS;
-		goto done;
-	}
+		if (!session->bugs) {
+			goto done;
+		}
+		is_cng = 1;
+
+	} 
 
 	switch_assert((*frame)->codec != NULL);
 	if ((session->read_codec && (*frame)->codec && session->read_codec->implementation != (*frame)->codec->implementation)) {
@@ -163,16 +166,25 @@
 	if (status == SWITCH_STATUS_SUCCESS && need_codec) {
 		switch_frame_t *enc_frame, *read_frame = *frame;
 
-		if (read_frame->codec) {
+		if (read_frame->codec || is_cng) {
 			session->raw_read_frame.datalen = session->raw_read_frame.buflen;
-			status = switch_core_codec_decode(read_frame->codec,
-											  session->read_codec,
-											  read_frame->data,
-											  read_frame->datalen,
-											  session->read_codec->implementation->actual_samples_per_second,
-											  session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
 
-			if (do_resample && status == SWITCH_STATUS_SUCCESS) {
+			if (is_cng) {
+				memset(session->raw_read_frame.data, 255, read_frame->codec->implementation->bytes_per_frame);
+				session->raw_read_frame.datalen = read_frame->codec->implementation->bytes_per_frame;
+				session->raw_read_frame.samples = session->raw_read_frame.datalen / sizeof(int16_t);
+				read_frame = &session->raw_read_frame;
+				status = SWITCH_STATUS_SUCCESS;
+			} else {
+				status = switch_core_codec_decode(read_frame->codec,
+												  session->read_codec,
+												  read_frame->data,
+												  read_frame->datalen,
+												  session->read_codec->implementation->actual_samples_per_second,
+												  session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
+			}
+
+			if (do_resample && ((status == SWITCH_STATUS_SUCCESS) || is_cng)) {
 				status = SWITCH_STATUS_RESAMPLE;
 			}
 

Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c	(original)
+++ freeswitch/trunk/src/switch_event.c	Thu Jan  3 16:34:44 2008
@@ -506,6 +506,9 @@
 			} else {
 				event->headers = hp->next;
 			}
+			if (hp == event->last_header || !hp->next) {
+				event->last_header = lp;
+			}
 			FREE(hp->name);
 			FREE(hp->value);
 			memset(hp, 0, sizeof(*hp));

Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c	(original)
+++ freeswitch/trunk/src/switch_ivr_async.c	Thu Jan  3 16:34:44 2008
@@ -98,9 +98,10 @@
 typedef struct {
 	switch_file_handle_t fh;
 	int mux;
+	int loop;
 } displace_helper_t;
 
-static switch_bool_t displace_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
+static switch_bool_t write_displace_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
 {
 	displace_helper_t *dh = (displace_helper_t *) user_data;
 	uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
@@ -154,7 +155,12 @@
 			}
 
 			if (st != SWITCH_STATUS_SUCCESS || len == 0) {
-				return SWITCH_FALSE;
+				if (dh->loop) {
+					uint32_t pos = 0;
+					switch_core_file_seek(&dh->fh, &pos, 0, SEEK_SET);
+				} else {
+					return SWITCH_FALSE;
+				}
 			}
 
 			switch_core_media_bug_set_write_replace_frame(bug, rframe);
@@ -168,6 +174,80 @@
 	return SWITCH_TRUE;
 }
 
+
+
+static switch_bool_t read_displace_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
+{
+	displace_helper_t *dh = (displace_helper_t *) user_data;
+	uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
+	switch_frame_t frame = { 0 };
+
+	frame.data = data;
+	frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
+
+	switch (type) {
+	case SWITCH_ABC_TYPE_INIT:
+		break;
+	case SWITCH_ABC_TYPE_CLOSE:
+		if (dh) {
+			switch_core_file_close(&dh->fh);
+		}
+		break;
+	case SWITCH_ABC_TYPE_WRITE_REPLACE:
+		{
+			switch_frame_t *rframe = switch_core_media_bug_get_write_replace_frame(bug);
+			if (dh && !dh->mux) {
+				memset(rframe->data, 255, rframe->datalen);
+			}
+			switch_core_media_bug_set_write_replace_frame(bug, rframe);
+		}
+		break;
+	case SWITCH_ABC_TYPE_READ_REPLACE:
+		if (dh) {
+			switch_frame_t *rframe = NULL;
+			switch_size_t len;
+			switch_status_t st;
+			rframe = switch_core_media_bug_get_read_replace_frame(bug);
+			len = rframe->samples;
+
+			if (dh->mux) {
+				int16_t buf[1024];
+				int16_t *fp = rframe->data;
+				uint32_t x;
+
+				st = switch_core_file_read(&dh->fh, buf, &len);
+				
+				for(x = 0; x < (uint32_t) len; x++) {
+					int32_t mixed = fp[x] + buf[x];
+					switch_normalize_to_16bit(mixed);
+					fp[x] = (int16_t) mixed;
+				}
+			} else {
+				st = switch_core_file_read(&dh->fh, rframe->data, &len);
+				rframe->samples = (uint32_t) len;
+				rframe->datalen = rframe->samples * 2;
+			}
+
+			if (st != SWITCH_STATUS_SUCCESS || len == 0) {
+				if (dh->loop) {
+					uint32_t pos = 0;
+					switch_core_file_seek(&dh->fh, &pos, 0, SEEK_SET);
+				} else {
+					return SWITCH_FALSE;
+				}
+			}
+
+			switch_core_media_bug_set_read_replace_frame(bug, rframe);
+		}
+		break;
+	case SWITCH_ABC_TYPE_WRITE:
+	default:
+		break;
+	}
+
+	return SWITCH_TRUE;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, const char *file)
 {
 	switch_media_bug_t *bug;
@@ -184,7 +264,7 @@
 
 }
 
-SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, char *file, uint32_t limit, const char *flags)
+SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags)
 {
 	switch_channel_t *channel;
 	switch_codec_t *read_codec;
@@ -206,15 +286,13 @@
 		return SWITCH_STATUS_MEMERR;
 	}
 
-
-
+	
 	read_codec = switch_core_session_get_read_codec(session);
 	switch_assert(read_codec != NULL);
 
 	dh->fh.channels = read_codec->implementation->number_of_channels;
 	dh->fh.samplerate = read_codec->implementation->actual_samples_per_second;
-
-
+	
 	if (switch_core_file_open(&dh->fh,
 							  file,
 							  read_codec->implementation->number_of_channels,
@@ -236,7 +314,17 @@
 		dh->mux++;
 	}
 
-	if ((status = switch_core_media_bug_add(session, displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
+	if (flags && strchr(flags, 'l')) {
+		dh->loop++;
+	}
+	
+	if (flags && strchr(flags, 'r')) {
+		status = switch_core_media_bug_add(session, read_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug);
+	} else {
+		status = switch_core_media_bug_add(session, write_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug);
+	}
+	
+	if (status != SWITCH_STATUS_SUCCESS) {
 		switch_core_file_close(&dh->fh);
 		return status;
 	}
@@ -1600,105 +1688,108 @@
 	switch_core_session_t *other_session = NULL;
 	const char *other_uuid = NULL;
 	char *app = "playback";
+	char *cause = NULL;
+	char *mypath;
+	char *p;
 
 	switch_assert(path);
 
-	if ((session = switch_core_session_locate(uuid))) {
-		char *cause = NULL;
-		char *mypath;
-		char *p;
+	if (!(session = switch_core_session_locate(uuid))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "uuid [%s] does not match an existing session.\n", switch_str_nil(uuid));
+		return SWITCH_STATUS_FALSE;
+	}
 
-		master = session;
+	master = session;
 
-		channel = switch_core_session_get_channel(session);
-		switch_assert(channel != NULL);
+	channel = switch_core_session_get_channel(session);
+	switch_assert(channel != NULL);
 
-		if ((switch_channel_test_flag(channel, CF_EVENT_PARSE))) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s] already broadcasting...broadcast aborted\n", 
-							  switch_channel_get_name(channel));
-			switch_core_session_rwunlock(session);
-			return SWITCH_STATUS_FALSE;
-		}
+	if ((switch_channel_test_flag(channel, CF_EVENT_PARSE))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s] already broadcasting...broadcast aborted\n", 
+						  switch_channel_get_name(channel));
+		switch_core_session_rwunlock(session);
+		return SWITCH_STATUS_FALSE;
+	}
 
-		mypath = strdup(path);
+	mypath = strdup(path);
 
 
-		if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
-			switch_ivr_media(uuid, SMF_REBRIDGE);
-		}
+	if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
+		switch_ivr_media(uuid, SMF_REBRIDGE);
+	}
 		
-		if ((p = strchr(mypath, ':')) && *(p+1) == ':') {
-			app = mypath;
-			*p++ = '\0';
-			*p++ = '\0';
-			path = p;
-		}
-
-		if ((cause = strchr(app, '!'))) {
-			*cause++ = '\0';
-			if (!cause) {
-				cause = "normal_clearing";
-			}
+	if ((p = strchr(mypath, ':')) && *(p+1) == ':') {
+		app = mypath;
+		*p++ = '\0';
+		*p++ = '\0';
+		path = p;
+	}
+
+	if ((cause = strchr(app, '!'))) {
+		*cause++ = '\0';
+		if (!cause) {
+			cause = "normal_clearing";
 		}
+	}
 
-		if ((flags & SMF_ECHO_BLEG) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE))
-			&& (other_session = switch_core_session_locate(other_uuid))) {
-			if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
-				if ((flags & SMF_LOOP)) {
-					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
-				}
-				
-				switch_core_session_queue_private_event(other_session, &event);
+	if ((flags & SMF_ECHO_BLEG) && (other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+		&& (other_session = switch_core_session_locate(other_uuid))) {
+		if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+			if ((flags & SMF_LOOP)) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
 			}
-			
-			switch_core_session_rwunlock(other_session);
-			master = other_session;
-			other_session = NULL;
+				
+			switch_core_session_queue_private_event(other_session, &event);
 		}
-
-		if ((flags & SMF_ECHO_ALEG)) {
-			if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
-				if ((flags & SMF_LOOP)) {
-					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
-				}
-				switch_core_session_queue_private_event(session, &event);
+			
+		switch_core_session_rwunlock(other_session);
+		master = other_session;
+		other_session = NULL;
+	}
+
+	if ((flags & SMF_ECHO_ALEG)) {
+		if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+			if ((flags & SMF_LOOP)) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
 			}
-			master = session;
+			switch_core_session_queue_private_event(session, &event);
 		}
+		master = session;
+	}
 
-		if (nomedia) {
-			if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia");
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", "%s", uuid);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
-				switch_core_session_queue_private_event(master, &event);
-			}
+	if (nomedia) {
+		if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", "%s", uuid);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+			switch_core_session_queue_private_event(master, &event);
 		}
+	}
 
-		if (cause) {
-			if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "hangup");
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", cause);
-				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
-				switch_core_session_queue_private_event(session, &event);
-			}
+	if (cause) {
+		if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "hangup");
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", cause);
+			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+			switch_core_session_queue_private_event(session, &event);
 		}
-
-		switch_core_session_rwunlock(session);
-		switch_safe_free(mypath);
 	}
 
+	switch_core_session_rwunlock(session);
+	switch_safe_free(mypath);
+	
+
 
 	return SWITCH_STATUS_SUCCESS;
 

Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c	(original)
+++ freeswitch/trunk/src/switch_rtp.c	Thu Jan  3 16:34:44 2008
@@ -1101,12 +1101,8 @@
 		break;
 
 	do_continue:
-
-		if (rtp_session->ms_per_packet) {
-			switch_yield((rtp_session->ms_per_packet / 1000) * 750);
-		} else {
-			switch_yield(1000);
-		}
+		
+		switch_yield(1000);
 	}
 
 	*payload_type = (switch_payload_t) rtp_session->recv_msg.header.pt;

Modified: freeswitch/trunk/src/switch_time.c
==============================================================================
--- freeswitch/trunk/src/switch_time.c	(original)
+++ freeswitch/trunk/src/switch_time.c	Thu Jan  3 16:34:44 2008
@@ -187,7 +187,7 @@
 {
 	timer_private_t *private_info = timer->private_info;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-	switch_size_t diff;
+
 
 	if (globals.RUNNING != 1 || !private_info->ready) {
 		return SWITCH_STATUS_SUCCESS;
@@ -196,12 +196,12 @@
 	check_roll();
 
 	if (TIMER_MATRIX[timer->interval].tick < private_info->reference) {
-		diff = private_info->reference - TIMER_MATRIX[timer->interval].tick;
+		timer->diff = private_info->reference - TIMER_MATRIX[timer->interval].tick;
 	} else {
-		diff = 0;
+		timer->diff = 0;
 	}
 
-	if (diff) {
+	if (timer->diff) {
 		status = SWITCH_STATUS_FALSE;
 	} else {
 		timer_step(timer);



More information about the Freeswitch-svn mailing list