Add option 'randomperiodicannounce' to queues.conf. Setting this will

allow the list of periodic announcments specified to be played in a random
order instead of being played sequentially.

(closes issue #6681)
Reported by: alt_phil
Tested by: putnopvut



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@109621 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.1
Mark Michelson 18 years ago
parent f1181cb04e
commit cd7efcf4e7

@ -339,6 +339,9 @@ Queue changes
* Added a new parameter for member definition, called state_interface. This may be * Added a new parameter for member definition, called state_interface. This may be
used so that a member may be called via one interface but have a different interface's used so that a member may be called via one interface but have a different interface's
device state reported. device state reported.
* New configuration option: randomperiodicannounce. If a list of periodic announcements is
specified by the periodic-announce option, then one will be chosen randomly when it is time
to play a periodic announcment
MeetMe Changes MeetMe Changes
-------------- --------------

@ -466,6 +466,8 @@ struct call_queue {
int announcefrequency; /*!< How often to announce their position */ int announcefrequency; /*!< How often to announce their position */
int minannouncefrequency; /*!< The minimum number of seconds between position announcements (def. 15) */ int minannouncefrequency; /*!< The minimum number of seconds between position announcements (def. 15) */
int periodicannouncefrequency; /*!< How often to play periodic announcement */ int periodicannouncefrequency; /*!< How often to play periodic announcement */
int numperiodicannounce; /*!< The number of periodic announcements configured */
int randomperiodicannounce; /*!< Are periodic announcments randomly chosen */
int roundingseconds; /*!< How many seconds do we round to? */ int roundingseconds; /*!< How many seconds do we round to? */
int holdtime; /*!< Current avg holdtime, based on recursive boxcar filter */ int holdtime; /*!< Current avg holdtime, based on recursive boxcar filter */
int callscompleted; /*!< Number of queue calls completed */ int callscompleted; /*!< Number of queue calls completed */
@ -935,6 +937,8 @@ static void init_queue(struct call_queue *q)
q->weight = 0; q->weight = 0;
q->timeoutrestart = 0; q->timeoutrestart = 0;
q->periodicannouncefrequency = 0; q->periodicannouncefrequency = 0;
q->randomperiodicannounce = 0;
q->numperiodicannounce = 0;
if (!q->members) { if (!q->members) {
if (q->strategy == QUEUE_STRATEGY_LINEAR) if (q->strategy == QUEUE_STRATEGY_LINEAR)
/* linear strategy depends on order, so we have to place all members in a single bucket */ /* linear strategy depends on order, so we have to place all members in a single bucket */
@ -1237,11 +1241,15 @@ static void queue_set_param(struct call_queue *q, const char *param, const char
if (i == MAX_PERIODIC_ANNOUNCEMENTS) if (i == MAX_PERIODIC_ANNOUNCEMENTS)
break; break;
} }
q->numperiodicannounce = i;
} else { } else {
ast_str_set(&q->sound_periodicannounce[0], 0, "%s", val); ast_str_set(&q->sound_periodicannounce[0], 0, "%s", val);
q->numperiodicannounce = 1;
} }
} else if (!strcasecmp(param, "periodic-announce-frequency")) { } else if (!strcasecmp(param, "periodic-announce-frequency")) {
q->periodicannouncefrequency = atoi(val); q->periodicannouncefrequency = atoi(val);
} else if (!strcasecmp(param, "random-periodic-announce")) {
q->randomperiodicannounce = ast_true(val);
} else if (!strcasecmp(param, "retry")) { } else if (!strcasecmp(param, "retry")) {
q->retry = atoi(val); q->retry = atoi(val);
if (q->retry <= 0) if (q->retry <= 0)
@ -2388,10 +2396,10 @@ static int say_periodic_announcement(struct queue_ent *qe, int ringing)
ast_moh_stop(qe->chan); ast_moh_stop(qe->chan);
ast_verb(3, "Playing periodic announcement\n"); ast_verb(3, "Playing periodic announcement\n");
/* Check to make sure we have a sound file. If not, reset to the first sound file */ if (qe->parent->randomperiodicannounce) {
if (qe->last_periodic_announce_sound >= MAX_PERIODIC_ANNOUNCEMENTS || qe->last_periodic_announce_sound = ((unsigned long) ast_random()) % qe->parent->numperiodicannounce;
!qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound] || } else if (qe->last_periodic_announce_sound >= qe->parent->numperiodicannounce ||
ast_strlen_zero(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]->str)) { ast_strlen_zero(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]->str)) {
qe->last_periodic_announce_sound = 0; qe->last_periodic_announce_sound = 0;
} }
@ -2414,7 +2422,9 @@ static int say_periodic_announcement(struct queue_ent *qe, int ringing)
qe->last_periodic_announce_time = now; qe->last_periodic_announce_time = now;
/* Update the current periodic announcement to the next announcement */ /* Update the current periodic announcement to the next announcement */
qe->last_periodic_announce_sound++; if (!qe->parent->randomperiodicannounce) {
qe->last_periodic_announce_sound++;
}
return res; return res;
} }

@ -210,6 +210,10 @@ shared_lastcall=no
; ;
;periodic-announce-frequency=60 ;periodic-announce-frequency=60
; ;
; Should the periodic announcements be played in a random order? Default is no.
;
;random-periodic-announce=no
;
; Should we include estimated hold time in position announcements? ; Should we include estimated hold time in position announcements?
; Either yes, no, or only once. ; Either yes, no, or only once.
; Hold time will be announced as the estimated time. ; Hold time will be announced as the estimated time.

Loading…
Cancel
Save