use Net::SIP;
#use strict;
#use warnings;
my $uae_sip = '10.0.0.2:5060';
my $from = '111';
my $secret = 'abcd12';
my $to = '14168404385';
# create new agent
my $ua = Net::SIP::Simple->new(
outgoing_proxy => $uae_sip,
registrar => $uae_sip,
domain => $uae_sip,
from => $from,
auth => [ $from, $secret ],
);
if($ua->register( expires => 60 )){
print "REGISTER sucessful. \n";
}else {
print "REGISTER Failed";
}
#$ua->register( expires => 60 );
#print $ua->error;
#print $ua_error;
##die();
#if ($ua->error){
# print "Registration Failed " . $ua->error;
#}else {
# print "SIP Registration Sucessful \n";
#}
#my $rtp_done;
my $hangup = 20;
my $stopvar = 20;
my $file = '';
my $to = '0581104414';
my $peer_hangup;
my $call = $ua->invite( $to,
init_media => $ua->rtp( 'recv_echo', $file,0 ),
recv_bye => \$peer_hangup,
);
if($call->error ){
# do nothing.
print "INVITE Failed" . $call->error . "\n";
}else{
print "INVITE sucessful \n";
}
# mainloop until other party hangs up or we hang up after
my $stopvar;
$ua->add_timer( $hangup, \$stopvar ) if $hangup;
$ua->loop( \$stopvar,\$peer_hangup );
# timeout checking block.
if ( $stopvar ) {
$stopvar = undef;
$call->bye( cb_final => \$stopvar );
$ua->loop( \$stopvar );
}
#use strict;
#use warnings;
my $uae_sip = '10.0.0.2:5060';
my $from = '111';
my $secret = 'abcd12';
my $to = '14168404385';
# create new agent
my $ua = Net::SIP::Simple->new(
outgoing_proxy => $uae_sip,
registrar => $uae_sip,
domain => $uae_sip,
from => $from,
auth => [ $from, $secret ],
);
if($ua->register( expires => 60 )){
print "REGISTER sucessful. \n";
}else {
print "REGISTER Failed";
}
#$ua->register( expires => 60 );
#print $ua->error;
#print $ua_error;
##die();
#if ($ua->error){
# print "Registration Failed " . $ua->error;
#}else {
# print "SIP Registration Sucessful \n";
#}
#my $rtp_done;
my $hangup = 20;
my $stopvar = 20;
my $file = '';
my $to = '0581104414';
my $peer_hangup;
my $call = $ua->invite( $to,
init_media => $ua->rtp( 'recv_echo', $file,0 ),
recv_bye => \$peer_hangup,
);
if($call->error ){
# do nothing.
print "INVITE Failed" . $call->error . "\n";
}else{
print "INVITE sucessful \n";
}
# mainloop until other party hangs up or we hang up after
my $stopvar;
$ua->add_timer( $hangup, \$stopvar ) if $hangup;
$ua->loop( \$stopvar,\$peer_hangup );
# timeout checking block.
if ( $stopvar ) {
$stopvar = undef;
$call->bye( cb_final => \$stopvar );
$ua->loop( \$stopvar );
}
No comments:
Post a Comment