Guest User

Untitled

a guest
May 25th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use Getopt::Long qw(:config posix_default bundling);
  7. use Net::SIP;
  8. #Usage
  9.  
  10. sub usage {
  11. print STDERR "ERROR: @_\n" if @_;
  12. print STDERR <<EOS;
  13. usage: $0 [ options ] no de tel
  14.  
  15. EOS
  16. exit( @_ ? 1:0 );
  17. }
  18.  
  19.  
  20. my ($file,$registrar,$username,$password);
  21.  
  22. GetOptions(
  23. 'R|registrar=s' => \$registrar,
  24. 'S|send=s' => \$file,
  25. 'username=s' =>\$username,
  26. 'password=s' =>\$password,
  27. ) || usage( "bad option" );
  28. my( $to )=@ARGV;
  29. $to || usage( "call to destination" );
  30.  
  31. # create new agent
  32.  
  33.  
  34. print "Creating connection\n";
  35. my $ua = Net::SIP::Simple->new(
  36. registrar => $registrar,
  37. domain => $registrar,
  38. from => $username,
  39. auth => [ $username,$password ],
  40.  
  41. );
  42.  
  43. # Register agent
  44.  
  45. $ua->register( expires => 1800 ) # <- Valeur mini chez free
  46.  
  47. || die ( "Pas enregistré " . $ua->error );
  48. print "Enregistré\n";
  49.  
  50. my $rtp_done;
  51. print "Appelle ".$to.'@'.$registrar."\n";
  52. my $call= $ua->invite( $to,
  53. init_media => $ua->rtp( 'send_recv', $file ),
  54. cb_rtp_done => \$rtp_done,
  55. asymetric_rtp => 0,
  56. rtp_param => [ 8, 160, 160/8000, 'PCMA/8000' ],
  57.  
  58. ) ||die "invite failed: ".$ua->error;
  59.  
  60. # Mainloop
  61.  
  62. $ua->loop( \$rtp_done );
  63. $call->bye;
Add Comment
Please, Sign In to add comment