]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix some media issues (shoud go into the 1.0 branch)
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 6 Jan 2009 21:07:58 +0000 (21:07 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 6 Jan 2009 21:07:58 +0000 (21:07 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11079 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_conference/mod_conference.c
src/mod/endpoints/mod_sofia/sofia.c
src/switch_core_io.c
src/switch_ivr.c
src/switch_ivr_async.c

index 3bb967ceb650bc0d333b222a7284407af756b56e..ccff794d08ac1447e90783f37bcfb57c1d660885 100644 (file)
@@ -1552,6 +1552,13 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
           and mux it with any audio from other channels. */
 
        while (switch_test_flag(member, MFLAG_RUNNING) && switch_channel_ready(channel)) {
+
+               if (switch_channel_test_flag(channel, CF_SERVICE)) {
+                       switch_yield(100000);
+                       continue;
+               }
+
+
                /* Read a frame. */
                status = switch_core_session_read_frame(member->session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 
@@ -2037,9 +2044,18 @@ static void conference_loop_output(conference_member_t *member)
                        }
                        switch_clear_flag_locked(member, MFLAG_FLUSH_BUFFER);
                }
-
+               
                switch_mutex_unlock(member->flag_mutex);
 
+
+               if (switch_core_session_private_event_count(member->session)) {
+                       switch_channel_set_flag(channel, CF_SERVICE);
+                       switch_ivr_parse_all_events(member->session);
+                       switch_channel_clear_flag(channel, CF_SERVICE);
+                       switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
+                       switch_core_session_set_read_codec(member->session, &member->read_codec);
+               }
+               
                if (use_timer) {
                        switch_core_timer_next(&timer);
                } else {
index 580e92df57eebf54ba8635e833797ab2ad465aea..a44da3a33109c6bad57bba17f6564f2fc11182d9 100644 (file)
@@ -3562,6 +3562,22 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
 
                                /* print debug info */
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INFO DTMF(%c)\n", dtmf.digit);
+                               
+                               if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
+                                       const char *uuid;
+                                       switch_core_session_t *session_b;
+                                       
+                                       if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (session_b = switch_core_session_locate(uuid))) {
+                                               while (switch_channel_has_dtmf(channel)) {
+                                                       switch_dtmf_t idtmf = { 0, 0 };
+                                                       if (switch_channel_dequeue_dtmf(channel, &idtmf) == SWITCH_STATUS_SUCCESS) {
+                                                               switch_core_session_send_dtmf(session_b, &idtmf);
+                                                       }
+                                               }
+
+                                               switch_core_session_rwunlock(session_b);
+                                       }
+                               }
 
                                /* Send 200 OK response */
                                nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
index b364ea1b947e44fbf82f5478e5f4dd86898139f6..968aaed540038ac9fa411deccd221acad696a229 100644 (file)
@@ -539,10 +539,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
        switch_mutex_unlock(session->read_codec->mutex);
        switch_mutex_unlock(session->codec_read_mutex);
 
-       if (switch_core_session_private_event_count(session)) {
-               switch_ivr_parse_all_events(session);
-       }
-
        return status;
 }
 
index d3bd1bc9d550aff05973aea709ef9d7eac00be53..f934ba1f6e28109cdc19932625bccf24b9d73de7 100644 (file)
@@ -54,9 +54,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session,
        int sval = 0;
        const char *var;
        
-       if ((var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) && (sval = atoi(var))) {
+       if (switch_channel_media_ready(channel) && (var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) && (sval = atoi(var))) {
+               switch_channel_pre_answer(channel);
                switch_core_session_get_read_impl(session, &imp);
-       
+               
                if (switch_core_codec_init(&codec,
                                                                   "L16",
                                                                   NULL,
index afcf51b421679ce0a66cdb5ae720db15a6577bfc..83519925cedfd51ef63266dfb2a6b9ba9d5a5840 100644 (file)
@@ -1445,6 +1445,44 @@ typedef struct {
 
 #define SWITCH_META_VAR_KEY "__dtmf_meta"
 
+typedef struct {
+       switch_core_session_t *session;
+       const char *app;
+       int flags;
+} bch_t;
+
+static void *SWITCH_THREAD_FUNC bcast_thread(switch_thread_t *thread, void *obj)
+{
+       bch_t *bch = (bch_t *) obj;
+
+       switch_ivr_broadcast(switch_core_session_get_uuid(bch->session), bch->app, bch->flags);
+
+       return NULL;
+
+}
+static void broadcast_in_thread(switch_core_session_t *session, const char *app, int flags)
+{
+       switch_thread_t *thread;
+       switch_threadattr_t *thd_attr = NULL;
+       switch_memory_pool_t *pool;
+       bch_t *bch;
+       
+       switch_assert(session);
+
+       pool = switch_core_session_get_pool(session);
+       
+       bch = switch_core_session_alloc(session, sizeof(*bch));
+       bch->session = session;
+       bch->app = app;
+       bch->flags = flags;
+       
+       
+       switch_threadattr_create(&thd_attr, pool);
+       switch_threadattr_detach_set(thd_attr, 1);
+       switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+       switch_thread_create(&thread, thd_attr, bcast_thread, bch, pool);
+}
+
 static switch_status_t meta_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
 {
        switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -1497,7 +1535,7 @@ static switch_status_t meta_on_dtmf(switch_core_session_t *session, const switch
 
                        if (ok && md->sr[direction].map[dval].app) {
                                uint32_t flags = md->sr[direction].map[dval].flags;
-
+                               
                                if ((md->sr[direction].map[dval].bind_flags & SBF_EXEC_OPPOSITE)) {
                                        if (direction == SWITCH_DTMF_SEND) {
                                                flags |= SMF_ECHO_ALEG;
@@ -1520,7 +1558,12 @@ static switch_status_t meta_on_dtmf(switch_core_session_t *session, const switch
 
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Processing meta digit '%c' [%s]\n",
                                                                  switch_channel_get_name(channel), dtmf->digit, md->sr[direction].map[dval].app);
-                               switch_ivr_broadcast(switch_core_session_get_uuid(session), md->sr[direction].map[dval].app, flags);
+
+                               if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
+                                       broadcast_in_thread(session, md->sr[direction].map[dval].app, flags | SMF_REBRIDGE);
+                               } else {
+                                       switch_ivr_broadcast(switch_core_session_get_uuid(session), md->sr[direction].map[dval].app, flags);
+                               }
 
                                if ((md->sr[direction].map[dval].bind_flags & SBF_ONCE)) {
                                        memset(&md->sr[direction].map[dval], 0, sizeof(md->sr[direction].map[dval]));
@@ -1589,7 +1632,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_se
                        md->sr[SWITCH_DTMF_RECV].map[key].app = switch_core_session_strdup(session, app);
                        md->sr[SWITCH_DTMF_RECV].map[key].flags |= SMF_HOLD_BLEG;
                        md->sr[SWITCH_DTMF_RECV].map[key].bind_flags = bind_flags;
-
+                       
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Bound A-Leg: %d %s\n", key, app);
                }
                if ((bind_flags & SBF_DIAL_BLEG)) {
@@ -2157,6 +2200,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(const char *uuid, const cha
                other_session = NULL;
        }
 
+       if (switch_stristr("record", app)) {
+               nomedia = 0;
+       }
+
        if ((flags & SMF_ECHO_ALEG)) {
                if (switch_event_create(&event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "execute");