]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9595 [avmd] Extend avmd show api
authorPiotr Gregor <piotrek.gregor@gmail.com>
Fri, 30 Sep 2016 13:28:34 +0000 (14:28 +0100)
committerPiotr Gregor <piotrek.gregor@gmail.com>
Sat, 1 Oct 2016 20:41:54 +0000 (21:41 +0100)
Add number of sessions currently running to output of avmd show api.

src/mod/applications/mod_avmd/mod_avmd.c
src/mod/applications/mod_avmd/scripts/avmd_originate_multiple.pl
src/mod/applications/mod_avmd/scripts/avmd_originate_multiple_loopback.pl [new file with mode: 0644]
src/mod/applications/mod_avmd/scripts/avmd_test.pl

index 3fbab37730bc21371a713d9ee22d3e1cb3517e33..9ed6676f0967602acdaaead9375cd52aeb4bc829 100644 (file)
@@ -943,6 +943,7 @@ static void avmd_show(switch_stream_handle_t *stream, switch_mutex_t *mutex) {
     stream->write_function(stream, "inbound channel                \t%u\n", avmd_globals.settings.inbound_channnel);
     stream->write_function(stream, "outbound channel               \t%u\n", avmd_globals.settings.outbound_channnel);
     stream->write_function(stream, "detection mode                 \t%u\n", avmd_globals.settings.mode);
+    stream->write_function(stream, "sessions                       \t%"PRId64"\n", avmd_globals.session_n);
     stream->write_function(stream, "\n\n");
 
     if (mutex != NULL) {
index ace73e0570b1fd42fa714f025c94ac0f95b7b86c..bc30477cc0ab9432a499e2093010cf9f3c20d7ac 100644 (file)
@@ -16,7 +16,7 @@ use Time::HiRes;
 my $host = "127.0.0.1";
 my $port = "8021";
 my $pass = "ClueCon";
-my $extension_base = "sofia/internal/1000\@192.168.1.60";
+my $extension_base = "sofia/internal/1000\@192.168.1.1";
 
 my $playback = 'local_stream://moh';
 my $context = 'default'; 
diff --git a/src/mod/applications/mod_avmd/scripts/avmd_originate_multiple_loopback.pl b/src/mod/applications/mod_avmd/scripts/avmd_originate_multiple_loopback.pl
new file mode 100644 (file)
index 0000000..1baf5b2
--- /dev/null
@@ -0,0 +1,78 @@
+#!/usr/bin/perl -w
+
+
+#brief  Call (possibly) multiple voicemails
+#       and print detection result to the console.
+#author Piotr Gregor <piotrgregor@rsyncme.org>
+#date   15 Sept 2016 02:44 PM
+
+
+use strict;
+use warnings;
+require ESL;
+use POSIX;
+use Time::HiRes;
+
+my $host = "127.0.0.1";
+my $port = "8021";
+my $pass = "ClueCon";
+my $extension_base = "sofia/internal/1000\@192.168.1.1";
+
+my $playback = 'local_stream://moh';
+my $context = 'default'; 
+my $gateway;
+my $dest;
+my $callerid;
+my $thread_n;
+my $idx = 0;
+
+
+if ($#ARGV + 1 eq 3) {
+    $dest = $ARGV[0];
+    $callerid = $ARGV[1];
+    $thread_n = $ARGV[2];
+    print "Dialing [" .$thread_n ."] calls simultaneously to [loopback][" .$dest ."] as [" .$callerid ."]\n";
+} else {
+    die "Please specify destination number, caller id and number of calls to make\n";
+}
+
+my $con  = new ESL::ESLconnection($host, $port, $pass);
+if (!$con) {
+    die "Unable to establish connection to $host:$port\n";
+}
+if ($con->connected()) {
+    print "OK, Connected.\n";
+} else {
+    die "Connection failure.\n";
+}
+
+while($con->connected() && ($idx < $thread_n)) {
+    call_once($dest, $callerid, $idx);
+    $idx++;
+    Time::HiRes::sleep(0.11);    # avoid switch_core_session.c:2265 Throttle Error! 33, switch_time.c:1227 Over Session Rate of 30!
+}
+
+print "Disconnected.\n\n";
+
+sub call_once {
+    my ($dest, $callerid, $idx) = @_;
+    my $uuid = 
+    my $originate_string =
+    'originate ' .
+    '{ignore_early_media=true,' .
+    'originator_codec=PCMA,' .
+    'origination_uuid=%s,' . 
+    'originate_timeout=60,' .
+    'origination_caller_id_number=' . $callerid . ',' .
+    'origination_caller_id_name=' . $callerid . '}';
+
+    $originate_string .= 'loopback/' . $dest . '/' . $context;
+    $originate_string .=  ' ' . '&playback(' . $playback . ')';
+
+    my $uuid = $con->api('create_uuid')->getBody();
+    my ($time_epoch, $time_hires) = Time::HiRes::gettimeofday();
+    printf("[%s]\tCalling with uuid [%s] [%s]... [%s]\n", $idx + 1, $uuid, POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime($time_epoch)), $originate_string);
+
+    $con->bgapi(sprintf($originate_string, $uuid));
+    $con->api('uuid_setvar ' . $uuid .' execute_on_answer avmd_start');
+}
index 06b91f4be14e18027c2ef407ceb015b10fdede77..6f6ac0f5fdde9f95f2d847779e72b09a5f3cb3e8 100644 (file)
@@ -169,7 +169,7 @@ $con->events("plain", "CHANNEL_HANGUP");
 print "OK.\n\n";
 printf("\nRunning [" .keys(%numbers) ."] tests.\n\n");
 
-printf("outbound uuid | destination number | timestamp | expectation | test result | freq | f-variance | amplitude | a-variance\n\n");
+printf("outbound uuid | destination number | timestamp | expectation | test result | freq | f-variance | amplitude | a-variance | resolution | offset | idx\n\n");
 foreach $dest (sort keys %numbers) {
     if (!$con->connected()) {
         last;