]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
When MOH is playing on the channel, announcements sent through the conference are...
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 8 Sep 2009 20:01:45 +0000 (20:01 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 8 Sep 2009 20:01:45 +0000 (20:01 +0000)
(closes issue #14588)
 Reported by: voipas
 Patches:
       20090716__issue14588__2.diff.txt uploaded by tilghman (license 14)
 Tested by: lmadsen, twisted, tilghman

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@217156 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_meetme.c

index 0e82f33f27972ef7e8e8806d9e4d04b5adb21c05..6b12ecdb00fa9f6be45090f927693325b5cc3b69 100644 (file)
@@ -1504,7 +1504,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
        int res;
        int retryzap;
        int origfd;
-       int musiconhold = 0;
+       int musiconhold = 0, mohtempstopped = 0;
        int firstpass = 0;
        int lastmarked = 0;
        int currentmarked = 0;
@@ -1530,6 +1530,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
        char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
        char *buf = __buf + AST_FRIENDLY_OFFSET;
        int setusercount = 0;
+       int confsilence = 0, totalsilence = 0;
 
        if (!(user = ast_calloc(1, sizeof(*user))))
                return ret;
@@ -1835,6 +1836,11 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
 
        conf_flush(fd, chan);
 
+       if (!(dsp = ast_dsp_new())) {
+               ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
+               res = -1;
+       }
+
        if (confflags & CONFFLAG_AGI) {
                /* Get name of AGI file to run from $(MEETME_AGI_BACKGROUND)
                   or use default filename of conf-background.agi */
@@ -1868,10 +1874,6 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                        x = 1;
                        ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0);
                }       
-               if (confflags & (CONFFLAG_MONITORTALKER | CONFFLAG_OPTIMIZETALKER) && !(dsp = ast_dsp_new())) {
-                       ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
-                       res = -1;
-               }
                for(;;) {
                        int menu_was_active = 0;
 
@@ -2065,8 +2067,6 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                                                ast_frame_adjust_volume(f, user->talk.actual);
 
                                        if (confflags & (CONFFLAG_MONITORTALKER | CONFFLAG_OPTIMIZETALKER)) {
-                                               int totalsilence;
-
                                                if (user->talking == -1)
                                                        user->talking = 0;
 
@@ -2262,8 +2262,9 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                                                        }
                                                }
                                        }
-                                       if (musiconhold)
+                                       if (musiconhold) {
                                                ast_moh_start(chan, NULL, NULL);
+                                       }
 
                                        if (ioctl(fd, DAHDI_SETCONF, &ztc)) {
                                                ast_log(LOG_WARNING, "Error setting conference\n");
@@ -2338,10 +2339,14 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                                                        }
                                                }
                                                if (conf->transframe[index]) {
-                                                       if ((conf->transframe[index]->frametype != AST_FRAME_NULL) &&
+                                                       if ((conf->transframe[index]->frametype != AST_FRAME_NULL) &&
                                                            can_write(chan, confflags)) {
                                                                struct ast_frame *cur;
-                                                               
+                                                               if (musiconhold && !ast_dsp_silence(dsp, conf->transframe[index], &confsilence) && confsilence < MEETME_DELAYDETECTTALK) {
+                                                                       ast_moh_stop(chan);
+                                                                       mohtempstopped = 1;
+                                                               }
+
                                                                /* the translator may have returned a list of frames, so
                                                                   write each one onto the channel
                                                                */
@@ -2351,6 +2356,10 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                                                                                break;
                                                                        }
                                                                }
+                                                               if (musiconhold && mohtempstopped && confsilence > MEETME_DELAYDETECTENDTALK) {
+                                                                       mohtempstopped = 0;
+                                                                       ast_moh_start(chan, NULL, NULL);
+                                                               }
                                                        }
                                                } else {
                                                        ast_mutex_unlock(&conf->listenlock);
@@ -2358,12 +2367,20 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                                                }
                                                ast_mutex_unlock(&conf->listenlock);
                                        } else {
-bailoutandtrynormal:                                   
+bailoutandtrynormal:
+                                               if (musiconhold && !ast_dsp_silence(dsp, &fr, &confsilence) && confsilence < MEETME_DELAYDETECTTALK) {
+                                                       ast_moh_stop(chan);
+                                                       mohtempstopped = 1;
+                                               }
                                                if (user->listen.actual)
                                                        ast_frame_adjust_volume(&fr, user->listen.actual);
                                                if (can_write(chan, confflags) && ast_write(chan, &fr) < 0) {
                                                        ast_log(LOG_WARNING, "Unable to write frame to channel %s\n", chan->name);
                                                }
+                                               if (musiconhold && mohtempstopped && confsilence > MEETME_DELAYDETECTENDTALK) {
+                                                       mohtempstopped = 0;
+                                                       ast_moh_start(chan, NULL, NULL);
+                                               }
                                        }
                                } else 
                                        ast_log(LOG_WARNING, "Failed to read frame: %s\n", strerror(errno));
@@ -2372,8 +2389,9 @@ bailoutandtrynormal:
                }
        }
 
-       if (musiconhold)
+       if (musiconhold) {
                ast_moh_stop(chan);
+       }
        
        if (using_pseudo)
                close(fd);