Fri Feb 14 07:00:01 CET 2003

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@614 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.0
Matteo Brancaleoni 23 years ago
parent 52a7b81e24
commit 06fde4bfaf

@ -0,0 +1,82 @@
#!/usr/bin/perl
#
# Simple AGI application to play mp3's selected by a user both using
# xmms and over the phone itself.
#
$|=1;
while(<STDIN>) {
chomp;
last unless length($_);
if (/^agi_(\w+)\:\s+(.*)$/) {
$AGI{$1} = $2;
}
}
print STDERR "AGI Environment Dump:\n";
foreach $i (sort keys %AGI) {
print STDERR " -- $i = $AGI{$i}\n";
}
dbmopen(%DIGITS, "/var/lib/asterisk/mp3list", 0644) || die("Unable to open mp3list");;
sub checkresult {
my ($res) = @_;
my $retval;
$tests++;
chomp $res;
if ($res =~ /^200/) {
$res =~ /result=(-?[\w\*\#]+)/;
return $1;
} else {
return -1;
}
}
#print STDERR "1. Playing beep...\n";
#print "STREAM FILE beep \"\"\n";
#$result = <STDIN>;
#checkresult($result);
print STDERR "2. Getting song name...\n";
print "GET DATA demo-enterkeywords\n";
$result = <STDIN>;
$digitstr = checkresult($result);
if ($digitstr < 0) {
exit(1);
}
$digitstr =~ s/\*/ /g;
print STDERR "Resulting songname is $digitstr\n";
@searchwords = split (/\s+/, $digitstr);
print STDERR "Searchwords: " . join(':', @searchwords) . "\n";
foreach $key (sort keys %DIGITS) {
@words = split(/\s+/, $DIGITS{$key});
$match = 1;
foreach $search (@searchwords) {
$match = 0 unless grep(/$search/, @words);
}
if ($match > 0) {
print STDERR "File $key matches\n";
# Play a beep
print "STREAM FILE beep \"\"\n";
system("xmms", $key);
$result = <STDIN>;
if (&checkresult($result) < 0) {
exit 0;
}
print "EXEC MP3Player \"$key\"\n";
# print "WAIT FOR DIGIT 60000\n";
$result = <STDIN>;
if (&checkresult($result) < 0) {
exit 0;
}
print STDERR "Got here...\n";
}
}
print STDERR "4. Testing 'saynumber' of $digitstr...\n";
print "STREAM FILE demo-nomatch\"\"\n";
$result = <STDIN>;
checkresult($result);

@ -0,0 +1,44 @@
#!/usr/bin/perl
#
# Build a database linking filenames to their numerical representations
# using a keypad for the DialAnMp3 application
#
$mp3dir="/usr/media/mpeg3";
dbmopen(%DIGITS, "/var/lib/asterisk/mp3list", 0644) || die("Unable to open mp3list");;
sub process_dir {
my ($dir) = @_;
my $file;
my $digits;
my @entries;
opendir(DIR, $dir);
@entries = readdir(DIR);
closedir(DIR);
foreach $_ (@entries) {
if (!/^\./) {
$file = "$dir/$_";
if (-d "$file") {
process_dir("$file");
} else {
$digits = $_;
$digits =~ s/[^ \w]+//g;
$digits =~ s/\_/ /g;
$digits =~ tr/[a-z]/[A-Z]/;
$digits =~ tr/[A-C]/2/;
$digits =~ tr/[D-F]/3/;
$digits =~ tr/[G-I]/4/;
$digits =~ tr/[J-L]/5/;
$digits =~ tr/[M-O]/6/;
$digits =~ tr/[P-S]/7/;
$digits =~ tr/[T-V]/8/;
$digits =~ tr/[W-Z]/9/;
$digits =~ s/\s+/ /;
print "File: $file, digits: $digits\n";
$DIGITS{$file} = $digits;
}
}
}
}
process_dir($mp3dir);

@ -352,14 +352,14 @@ int ast_app_getdata(struct ast_channel *c, char *prompt, char *s, int maxlen, in
static int handle_getdata(struct ast_channel *chan, int fd, int argc, char *argv[])
{
int res;
char data[50];
char data[1024];
int max;
int timeout;
if (argc < 3)
return RESULT_SHOWUSAGE;
if (argc >= 4) timeout = atoi(argv[3]); else timeout = 0;
if (argc >= 5) max = atoi(argv[4]); else max = 50;
if (argc >= 5) max = atoi(argv[4]); else max = 1024;
res = ast_app_getdata(chan, argv[2], data, max, timeout);
if (res == 1)
fdprintf(fd, "200 result=%s (timeout)\n", data);

@ -967,7 +967,8 @@ struct ast_frame *ast_read(struct ast_channel *chan)
if (!(f->subclass & chan->nativeformats)) {
/* This frame can't be from the current native formats -- drop it on the
floor */
ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s since our native format has changed\n", chan->name);
ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %d since our native format has changed to %d\n", chan->name, f->subclass, chan->nativeformats);
ast_frfree(f);
f = &null_frame;
} else if (chan->pvt->readtrans) {
f = ast_translate(chan->pvt->readtrans, f, 1);

@ -1758,6 +1758,10 @@ static int iax_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
ast_verbose(VERBOSE_PREFIX_3 "Can't masquerade, we're different...\n");
return -2;
}
if (c0->nativeformats != c1->nativeformats) {
ast_verbose(VERBOSE_PREFIX_3 "Operating with different codecs, can't native bridge...\n");
return -2;
}
if (!transferstarted) {
/* Try the transfer */
if (iax_start_transfer(c0, c1))
@ -2240,12 +2244,13 @@ static int iax_show_channels(int fd, int argc, char *argv[])
#define FORMAT2 "%-15.15s %-10.10s %-11.11s %-11.11s %-7.7s %-6.6s %s\n"
#define FORMAT "%-15.15s %-10.10s %5.5d/%5.5d %5.5d/%5.5d %-5.5dms %-4.4dms %d\n"
int x;
int numchans = 0;
if (argc != 3)
return RESULT_SHOWUSAGE;
ast_cli(fd, FORMAT2, "Peer", "Username", "ID (Lo/Rem)", "Seq (Tx/Rx)", "Lag", "Jitter", "Format");
for (x=0;x<AST_IAX_MAX_CALLS;x++) {
ast_pthread_mutex_lock(&iaxsl[x]);
if (iaxs[x])
if (iaxs[x]) {
ast_cli(fd, FORMAT, inet_ntoa(iaxs[x]->addr.sin_addr),
strlen(iaxs[x]->username) ? iaxs[x]->username : "(None)",
iaxs[x]->callno, iaxs[x]->peercallno,
@ -2253,8 +2258,11 @@ static int iax_show_channels(int fd, int argc, char *argv[])
iaxs[x]->lag,
iaxs[x]->jitter,
iaxs[x]->voiceformat);
numchans++;
}
ast_pthread_mutex_unlock(&iaxsl[x]);
}
ast_cli(fd, "%d active IAX channel(s)\n", numchans);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2

@ -2413,6 +2413,7 @@ static int sip_show_channels(int fd, int argc, char *argv[])
#define FORMAT2 "%-15.15s %-10.10s %-11.11s %-11.11s %-7.7s %-6.6s %s\n"
#define FORMAT "%-15.15s %-10.10s %-11.11s %5.5d/%5.5d %-5.5dms %-4.4dms %d\n"
struct sip_pvt *cur;
int numchans = 0;
if (argc != 3)
return RESULT_SHOWUSAGE;
ast_pthread_mutex_lock(&iflock);
@ -2427,8 +2428,10 @@ static int sip_show_channels(int fd, int argc, char *argv[])
0,
cur->owner ? cur->owner->nativeformats : 0);
cur = cur->next;
numchans++;
}
ast_pthread_mutex_unlock(&iflock);
ast_cli(fd, "%d active SIP channel(s)\n", numchans);
return RESULT_SUCCESS;
#undef FORMAT
#undef FORMAT2
@ -3048,9 +3051,12 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
else
transmit_response(p, "202 Accepted", req);
ast_log(LOG_DEBUG,"202 Accepted\n");
c = p->owner;
if (c) {
transfer_to = c->bridge;
if (transfer_to)
ast_async_goto(transfer_to,"", p->refer_to,1, 1);
}
} else if (!strcasecmp(cmd, "CANCEL") || !strcasecmp(cmd, "BYE")) {
copy_request(&p->initreq, req);

@ -5361,11 +5361,11 @@ static void *pri_dchannel(void *vpri)
ast_log(LOG_WARNING, "Ringing requested on channel %d not in use on span %d\n", e->ringing.channel, pri->span);
chan = 0;
} else if (!strlen(pri->pvt[chan]->dop.dialstr)) {
zt_enable_ec(pri->pvt[chan]);
pri->pvt[chan]->subs[SUB_REAL].needringing =1;
} else
ast_log(LOG_DEBUG, "Deferring ringing notification because of extra digits to dial...\n");
}
zt_enable_ec(pri->pvt[chan]);
break;
case PRI_EVENT_FACNAME:
chan = e->facname.channel;

@ -6,4 +6,4 @@
parkext => 700 ; What ext. to dial to park
parkpos => 701-720 ; What extensions to park calls on
context => parkedcalls ; Which context parked calls are in
;parkingtime => 45 ; Number of seconds a call can be parked for (default is 45 seconds)

@ -1139,7 +1139,7 @@ int ast_pbx_run(struct ast_channel *c)
/* Something bad happened, or a hangup has been requested. */
if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F'))) {
ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
exten[pos++] = res;
exten[pos++] = digit = res;
break;
}
switch(res) {

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save