]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
cross t's and dot i's
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 3 Jan 2008 21:34:44 +0000 (21:34 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 3 Jan 2008 21:34:44 +0000 (21:34 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7075 d0543943-73ff-0310-b7d9-9358b9ac24b2

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

index 19b7e25f375ef6e0213a95dc9464b3bcfa62ecc3..5079b6a7bd356eedc02709f43b2e4fa6f575a444 100644 (file)
@@ -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 -->
index 05c7fb9d32a8cd4fd6bf684dde521072051d988d..a5ba393a526a05bf7313715191fb09244233a805 100644 (file)
@@ -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"/>
     </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>
       </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"/>
index 1ecd349beef9ad366302716030e01c1c3dc90fcd..8e2c8448dcc821a201f64e7b5298869ab2c5a4b1 100755 (executable)
@@ -420,7 +420,7 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 
 # 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 @@ fi
 
 
 # Define the identity of the package.
- PACKAGE='libedit-20071219'
+ PACKAGE='libedit-20071230'
  VERSION='2.10'
 
 
index 2bdb39339ff5e2ebec3c87b7c55f192d207219cb..cf601363c3cd8656c42ccffcf028bcdcee221968 100755 (executable)
@@ -22,7 +22,7 @@ print "Call: $data->{'caller-channel-name'} $data->{'unique-id'}\n";
 $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 @@ while(my $r = $fs->readhash(undef)) {
   }
   if ($r->{event}->{'event-name'} !~ /execute/i) {
     printf "wtf $data->{'unique-id'}\n";
+    print ".";
     $o = $fs->call_command("break");
     $o = $fs->call_command("hangup");
   }
index acdb4ff72c72083c5664f4584d2ce35e03ed4768..be6125ee6e137e0473a1e3773a79ceb0e09bbabb 100644 (file)
@@ -205,7 +205,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_unload_grammar(switch_c
 */
 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);
 
 /*!
index ebdda1abf42990b2df2e29fc72330d7d1ba06248..cc9e5cdf2937914f3b457db458a043c568e3515e 100644 (file)
@@ -195,6 +195,8 @@ struct switch_timer {
        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 {
index 2c64dcee5a09c34c1ca23e607b60d657d349730d..63d1c1db8a39a3e5e18d81516d2847c657423eb6 100644 (file)
@@ -2028,7 +2028,7 @@ SWITCH_STANDARD_API(uuid_dump_function)
                                        }
                                        
                                        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 {
index 4e2e9edbdb1009a3cbab7b6297cb1decdfbe7239..1a5df6a109e9c1a0b33b042ad854ce6fb2ce3ab5 100644 (file)
@@ -558,7 +558,7 @@ static switch_status_t conference_add_member(conference_obj_t * conference, conf
                                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 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread,
                        /* 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 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread,
                        /* 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) {
index 42eb6d8d6a704ef41ef948fc4af0815f9e548da6..4cce5dbf318e686c5698fd5697e59d770524dbee 100644 (file)
@@ -84,6 +84,7 @@ static struct {
     switch_hash_t *fifo_hash;
     switch_mutex_t *mutex;
     switch_memory_pool_t *pool;
+    int running;
 } globals;
 
 
@@ -105,6 +106,10 @@ static fifo_node_t *create_node(const char *name)
 {
     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 @@ static void send_presence(fifo_node_t *node)
 {
     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 @@ static void send_presence(fifo_node_t *node)
         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 @@ static void pres_event_handler(switch_event_t *event)
        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_STANDARD_APP(fifo_function)
     switch_time_t ts = switch_timestamp_now();
     switch_size_t retsize;
 
-
+    if (!globals.running) {
+        return;
+    }
 
 
     if (switch_strlen_zero(data)) {
@@ -577,6 +591,11 @@ SWITCH_STANDARD_API(fifo_api_function)
     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 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_fifo_load)
        *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_MODULE_SHUTDOWN_FUNCTION(mod_fifo_shutdown)
     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_MODULE_SHUTDOWN_FUNCTION(mod_fifo_shutdown)
         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;
 }
 
index 135f0ec74212f9795444e6b2a91dbac33cd9ced2..c562884e83e5f912ac11101e7f601b178fa7f7e4 100644 (file)
@@ -252,30 +252,11 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
        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);
                
        }
index bc77f8203c175c873b64b1c0b729af6ec50143d0..68366dff4866c5856092602522e35c4417e07d90 100644 (file)
@@ -1382,25 +1382,38 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
        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");
                }
index 29a404d02460902081a9cf2c17666f5335e336ce..9813b26ba30a4430ba0125da614b4b02c091c103 100644 (file)
@@ -94,7 +94,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
 {
        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_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
        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 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
        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;
                        }
 
index 2627c57c6125c0c120f0624d6814047757266f42..7156c0cca904bbf81f6bca9f46a0fc184e5953e5 100644 (file)
@@ -506,6 +506,9 @@ SWITCH_DECLARE(switch_status_t) switch_event_del_header(switch_event_t *event, c
                        } 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));
index 9fd5305111883e0f1c386fd0ab831936b2b9689a..459c4e4e5c8fa7cc53618d4e968c5d1bdeef4b46 100644 (file)
@@ -98,9 +98,10 @@ SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session)
 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 @@ static switch_bool_t displace_callback(switch_media_bug_t *bug, void *user_data,
                        }
 
                        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 @@ static switch_bool_t displace_callback(switch_media_bug_t *bug, void *user_data,
        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_stop_displace_session(switch_core_ses
 
 }
 
-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 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_
                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 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_
                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_DECLARE(switch_status_t) switch_ivr_broadcast(const char *uuid, const cha
        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 ((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 ((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);
                }
+                       
+               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);
-                               }
-                               switch_core_session_queue_private_event(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);
                        }
-                       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;
 
index 2792feb3ba51213caa596cc3b1581ca310110807..fe8fe6761e38e6ec99107a0b999db18e14037130 100644 (file)
@@ -1101,12 +1101,8 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
                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;
index a4a4e0dd655ab4b1600ff7236d357904177b00b9..1239084b6849f55bacc6b3654b0818d1b09d8a3d 100644 (file)
@@ -187,7 +187,7 @@ static switch_status_t timer_check(switch_timer_t *timer)
 {
        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 @@ static switch_status_t timer_check(switch_timer_t *timer)
        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);