Index: main/features.c =================================================================== --- main/features.c (revision 230380) +++ main/features.c (working copy) @@ -4833,44 +4833,43 @@ char *limit_str, *warning_str, *warnfreq_str; const char *var; int play_to_caller = 0, play_to_callee = 0; - int delta; limit_str = strsep(&stringp, ":"); warning_str = strsep(&stringp, ":"); warnfreq_str = strsep(&stringp, ":"); config->timelimit = atol(limit_str); - if (warning_str) - config->play_warning = atol(warning_str); - if (warnfreq_str) - config->warning_freq = atol(warnfreq_str); + /* timelimit must be set, warning_freq and play_warning are optional */ if (!config->timelimit) { - ast_log(LOG_WARNING, "Bridge does not accept L(%s), hanging up.\n", limit_str); - config->timelimit = config->play_warning = config->warning_freq = 0; - config->warning_sound = NULL; + ast_log(LOG_ERROR, "Bridge does not accept L(%s), timelimit is missing! Hanging up.\n", limit_str); return -1; /* error */ - } else if ( (delta = config->play_warning - config->timelimit) > 0) { - int w = config->warning_freq; + } - /* If the first warning is requested _after_ the entire call would end, - and no warning frequency is requested, then turn off the warning. If - a warning frequency is requested, reduce the 'first warning' time by - that frequency until it falls within the call's total time limit. - Graphically: - timelim->| delta |<-playwarning - 0__________________|_________________| - | w | | | | + if (warning_str){ + config->play_warning = atol(warning_str); + if (config->play_warning > config->timelimit){ + ast_log(LOG_ERROR, "Bridge does not accept L(%s), play_warning (%ld) is bigger than the timelimit (%ld)! Hanging up.\n", limit_str, config->play_warning, config->timelimit); + return -1; + } + } - so the number of intervals to cut is 1+(delta-1)/w - */ + if (warnfreq_str){ + config->warning_freq = atol(warnfreq_str); + if (config->warning_freq > config->timelimit){ + ast_log(LOG_ERROR, "Bridge does not accept L(%s), warning frequency (%ld) is bigger than the timelimit (%ld)! Hanging up.\n",limit_str, config->warning_freq, config->timelimit); + return -1; + } - if (w == 0) { - config->play_warning = 0; - } else { - config->play_warning -= w * ( 1 + (delta-1)/w ); - if (config->play_warning < 1) - config->play_warning = config->warning_freq = 0; + /* consider: Dial(...,L(60000::10000)) + * Timelimit = 60 sec + * play_warning = 0 + * warning_freq = 10sec + * + * set play_warning to 50sec in order to play warnings every 10seconds */ + if (!config->play_warning){ + ast_log(LOG_NOTICE, "Warning frequency specified but play_warning not set. Setting play_warning to %ld\n", config->timelimit - config->warning_freq); + config->play_warning = config->timelimit - config->warning_freq; } } @@ -4906,25 +4905,16 @@ calldurationlimit->tv_sec = 0; calldurationlimit->tv_usec = 0; - /* more efficient to do it like S(x) does since no advanced opts */ - if (!config->play_warning && !config->start_sound && !config->end_sound && config->timelimit) { - calldurationlimit->tv_sec = config->timelimit / 1000; - calldurationlimit->tv_usec = (config->timelimit % 1000) * 1000; - ast_verb(3, "Setting call duration limit to %.3lf seconds.\n", - calldurationlimit->tv_sec + calldurationlimit->tv_usec / 1000000.0); - config->timelimit = play_to_caller = play_to_callee = - config->play_warning = config->warning_freq = 0; - } else { - ast_verb(3, "Limit Data for this call:\n"); - ast_verb(4, "timelimit = %ld\n", config->timelimit); - ast_verb(4, "play_warning = %ld\n", config->play_warning); - ast_verb(4, "play_to_caller = %s\n", play_to_caller ? "yes" : "no"); - ast_verb(4, "play_to_callee = %s\n", play_to_callee ? "yes" : "no"); - ast_verb(4, "warning_freq = %ld\n", config->warning_freq); - ast_verb(4, "start_sound = %s\n", S_OR(config->start_sound, "")); - ast_verb(4, "warning_sound = %s\n", config->warning_sound); - ast_verb(4, "end_sound = %s\n", S_OR(config->end_sound, "")); - } + ast_verb(4, "Limit Data for this call:\n"); + ast_verb(4, "timelimit = %ld ms (%.2lf s)\n", config->timelimit, (double) config->timelimit / 1000); + ast_verb(4, "play_warning = %ld ms (%.2lf s)\n", config->play_warning, (double) config->play_warning / 1000); + ast_verb(4, "play_to_caller = %s\n", play_to_caller ? "yes" : "no"); + ast_verb(4, "play_to_callee = %s\n", play_to_callee ? "yes" : "no"); + ast_verb(4, "warning_freq = %ld ms (%.2lf s)\n", config->warning_freq, (double) config->warning_freq / 1000); + ast_verb(4, "start_sound = %s\n", S_OR(config->start_sound, "")); + ast_verb(4, "warning_sound = %s\n", config->warning_sound); + ast_verb(4, "end_sound = %s\n", S_OR(config->end_sound, "")); + if (play_to_caller) ast_set_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING); if (play_to_callee)