added small feature from bug 5682 with one typo fix.
authorMatt O'Gorman <mogorman@digium.com>
Sun, 8 Jan 2006 00:25:31 +0000 (00:25 +0000)
committerMatt O'Gorman <mogorman@digium.com>
Sun, 8 Jan 2006 00:25:31 +0000 (00:25 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7865 65c4cc65-6c06-0410-ace0-fbb531ad65f3

configs/features.conf.sample
res/res_features.c

index 0805c90..f46c7ec 100644 (file)
@@ -12,6 +12,8 @@ context => parkedcalls                ; Which context parked calls are in
 ;courtesytone = beep           ; Sound file to play to the parked caller 
                                ; when someone dials a parked call
                                ; or the Touch Monitor is activated/deactivated.
+;parkedplay = caller           ; Who to play the courtesy tone to when picking up a parked call
+                               ; one of: parked, caller, both  (default is caller)
 ;xfersound = beep              ; to indicate an attended transfer is complete
 ;xferfailsound = beeperr       ; to indicate a failed transfer
 ;adsipark = yes                        ; if you want ADSI parking announcements
index b174799..355d65e 100644 (file)
@@ -94,6 +94,9 @@ static char courtesytone[256];
 static char xfersound[256];
 static char xferfailsound[256];
 
+/* Who to play the courtesy tone to */
+static int parkedplay = 0;
+
 /* First available extension for parking */
 static int parking_start;
 
@@ -1742,19 +1745,45 @@ static int park_exec(struct ast_channel *chan, void *data)
        }
 
        if (peer) {
-               /* Play a courtesy beep in the calling channel to prefix the bridge connecting */       
+               /* Play a courtesy to the source(s) configured to prefix the bridge connecting */
+               
                if (!ast_strlen_zero(courtesytone)) {
-                       if (!ast_streamfile(chan, courtesytone, chan->language)) {
-                               if (ast_waitstream(chan, "") < 0) {
-                                       ast_log(LOG_WARNING, "Failed to play courtesy tone!\n");
-                                       ast_hangup(peer);
-                                       return -1;
+                       if (parkedplay == 0) {
+                               if (!ast_streamfile(chan, courtesytone, chan->language)) {
+                                       if (ast_waitstream(chan, "") < 0) {
+                                               ast_log(LOG_WARNING, "Failed to play courtesy tone!\n");
+                                               ast_hangup(peer);
+                                               return -1;
+                                       }
+                               }
+                               ast_moh_stop(peer);
+                               ast_indicate(peer, AST_CONTROL_UNHOLD);
+                       } else {
+                               ast_moh_stop(peer);
+                               ast_indicate(peer, AST_CONTROL_UNHOLD);
+                               if (parkedplay == 2) {
+                                       if (!ast_streamfile(chan, courtesytone, chan->language) && !ast_streamfile(peer, courtesytone, chan->language)) {
+                                               res = ast_waitstream(chan, "");
+                                               if (res >= 0)
+                                                       res = ast_waitstream(peer, "");
+                                               if (res < 0) {
+                                                       ast_log(LOG_WARNING, "Failed to play courtesy tones!\n");
+                                                       ast_hangup(peer);
+                                                       return -1;
+                                               }
+                                       }
+                               } else if (parkedplay == 1) {
+                                       if (!ast_streamfile(peer, courtesytone, chan->language)) {
+                                               if (ast_waitstream(peer, "") < 0) {
+                                                       ast_log(LOG_WARNING, "Failed to play courtesy tone!\n");
+                                                       ast_hangup(peer);
+                                                       return -1;
+                                               }
+                                       }
                                }
                        }
                }
  
-               ast_moh_stop(peer);
-               ast_indicate(peer, AST_CONTROL_UNHOLD);
                res = ast_channel_make_compatible(chan, peer);
                if (res < 0) {
                        ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for bridge\n", chan->name, peer->name);
@@ -2029,6 +2058,13 @@ static int load_config(void)
                                }
                        } else if (!strcasecmp(var->name, "courtesytone")) {
                                ast_copy_string(courtesytone, var->value, sizeof(courtesytone));
+                       }  else if (!strcasecmp(var->name, "parkedplay")) {
+                               if (!strcasecmp(var->value, "both"))
+                                       parkedplay = 2;
+                               else if (!strcasecmp(var->value, "parked"))
+                                       parkedplay = 1;
+                               else
+                                       parkedplay = 0;
                        } else if (!strcasecmp(var->name, "xfersound")) {
                                ast_copy_string(xfersound, var->value, sizeof(xfersound));
                        } else if (!strcasecmp(var->name, "xferfailsound")) {