Created
July 27, 2015 22:27
-
-
Save seven1240/e57e8e0dfa82e757cb4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use List::Permutor; | |
use XML::Simple; | |
use Data::Dumper; | |
use strict; | |
use warnings; | |
use GD::Barcode::QRcode; | |
use File::Temp qw/ :mktemp /; | |
use Barcode::ZBar; | |
use Image::Magick; | |
require ESL; | |
my $test; | |
my $con = new ESL::ESLconnection("localhost", "8021", "ClueCon"); | |
my $e; | |
my @files; | |
my $i = 1; | |
while ( $i <= 64) { | |
my $image1 = GD::Barcode::QRcode->new("TEST PASS IMAGE $i",{ | |
Ecc => 'L', | |
Version=>2, | |
ModuleSize => 5 | |
})->plot->png; | |
my ($fh1, $file) = mkstemps( "/var/www/html/tmpfileXXXXXX", ".png"); | |
binmode($fh1); | |
print $fh1 $image1; | |
close($fh1); | |
my $filename = $file; | |
push @files,$filename; | |
$i++; | |
} | |
my $image2 = GD::Barcode::QRcode->new('TEST PASS CONF IMAGE',{ | |
Ecc => 'L', | |
Version=>2, | |
ModuleSize => 5 | |
})->plot->png; | |
my ($fh2, $file2) = mkstemps( "/var/www/html/tmpfileXXXXXX", ".png"); | |
binmode($fh2); | |
print $fh2 $image2; | |
close($fh2); | |
# Hangup All Channels | |
$e = $con->api("fsctl", "hupall"); | |
print $e->getBody(); | |
# Get Local IPv4 | |
$e = $con->api("global_getvar", "local_ip_v4"); | |
my $ipv4 = $e->getBody(); | |
# Originate 2 channels. | |
$i = 1; | |
foreach my $file (@files) { | |
$e = $con->api("originate", "{sip_h_X-File=$file,sip_h_X-Test-Role=confimg$i,absolute_codec_string=OPUS\\,VP8}sofia/external/sip:6070\@$ipv4:5090 playimg$i XML public"); | |
print $e->getBody(); | |
sleep(1); | |
$i++; | |
} | |
# Give everything time to come up. | |
sleep(2); | |
# Get channel list. | |
$e = $con->api("show", "channels as xml"); | |
# Draw UUID to role Map. | |
if ($e) { | |
my $ref = XMLin($e->getBody(), KeepRoot => 1, Keyattr => [ 'row_id' ]); | |
foreach my $key (keys %{$ref->{result}->{row}}) { | |
$e = $con->api("uuid_getvar", "$ref->{result}->{row}->{$key}->{uuid} test_role"); | |
# build map of test roles to uuid | |
if ($e) { | |
my $role = $e->getBody(); | |
$test->{$role} = $ref->{result}->{row}->{$key}->{uuid}; | |
} | |
} | |
} | |
# Dump Map. | |
print Dumper $test; | |
$e = $con->api("uuid_write_png", "$test->{confimg1} /var/www/html/confimg1r.png"); | |
print $e->getBody(); | |
sleep(5); | |
my $image3 = Barcode::ZBar::Image->new; | |
{ | |
my $magick = Image::Magick->new; | |
$magick->Read("/var/www/html/confimg1r.png") and die; | |
my $raw = $magick->ImageToBlob(magick => 'GRAY', depth => 8); | |
$image3->set_format('Y800'); | |
$image3->set_size($magick->Get(qw(columns rows))); | |
$image3->set_data($raw); | |
} | |
Barcode::ZBar::ImageScanner->new->scan_image($image3); | |
foreach my $symbol ($image3->get_symbols) { | |
print $symbol->get_data . "\n" if $symbol->get_type eq 'QR-Code'; | |
} | |
$e = $con->api("conference", "6070 play {png_ms=-1}$file2"); | |
print $e->getBody(); | |
$e = $con->api("conference", "6070 vid-layout 8x8"); | |
print $e->getBody(); | |
sleep(2); | |
$e = $con->api("uuid_write_png", "$test->{playimg1} /var/www/html/playimg1w.png"); | |
print $e->getBody(); | |
sleep(5); | |
my $image4 = Barcode::ZBar::Image->new; | |
{ | |
my $magick = Image::Magick->new; | |
$magick->Read("/var/www/html/playimg1w.png") and die; | |
my $raw = $magick->ImageToBlob(magick => 'GRAY', depth => 8); | |
$image4->set_format('Y800'); | |
$image4->set_size($magick->Get(qw(columns rows))); | |
$image4->set_data($raw); | |
} | |
Barcode::ZBar::ImageScanner->new->scan_image($image4); | |
foreach my $symbol ($image4->get_symbols) { | |
print $symbol->get_data . "\n" if $symbol->get_type eq 'QR-Code'; | |
} | |
$e = $con->api("fsctl", "hupall"); | |
__DATA__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment