fix perl namespaces - move into NGCP::

Change-Id: I5c21abf195b766bfda3d9d371b4d0577007c1f5e
changes/34/5834/1
Richard Fuchs 9 years ago
parent b6b0b901b3
commit f83f674c4c

@ -1,8 +1,8 @@
package DTLS;
package NGCP::Rtpclient::DTLS;
use strict;
use warnings;
use SRTP;
use NGCP::Rtpclient::SRTP;
use File::Temp;
use Crypt::OpenSSL::RSA;
use IO::Socket::INET;
@ -279,7 +279,7 @@ sub encode {
return @ret;
}
package DTLS::Group;
package NGCP::Rtpclient::DTLS::Group;
sub new {
my ($class, $mux, $output_func, $socket_components, $cert) = @_;
@ -291,7 +291,7 @@ sub new {
for my $idx (0 .. $max_component) {
my $local_sockets = $socket_components->[$idx];
my $cl = DTLS->new($mux, $local_sockets, $output_func, $idx, $cert);
my $cl = NGCP::Rtpclient::DTLS->new($mux, $local_sockets, $output_func, $idx, $cert);
push(@$self, $cl);
$cert = $cl->get_cert();
}

@ -1,4 +1,4 @@
package ICE;
package NGCP::Rtpclient::ICE;
use strict;
use warnings;
@ -88,7 +88,7 @@ sub add_candidate {
foundation => $foundation,
protocol => 'UDP', af => $c->sockdomain(),
address => $c->sockhost(), port => $c->sockport(),
agent => $self }, 'ICE::Component';
agent => $self }, 'NGCP::Rtpclient::ICE::Component';
push(@$comps, $comp);
$comp->debug("is $comp->{address}/$comp->{port}\n");
@ -99,7 +99,7 @@ sub add_candidate {
base_priority => calc_priority($type, $local_pref, 0),
type => $type, components => $comps, protocol => 'UDP',
af => $comps->[0]->{af}, address => $comps->[0]->{address},
agent => $self }, 'ICE::Candidate';
agent => $self }, 'NGCP::Rtpclient::ICE::Candidate';
$self->pair_candidates();
}
@ -290,7 +290,7 @@ sub pair_candidates {
my $foundation = $loc->{foundation} . $rem->{foundation};
my $pair = $pairs->{$foundation} || ($pairs->{$foundation} =
bless { foundation => $foundation, local => $loc, remote => $rem,
components => [], agent => $self}, 'ICE::Candidate::Pair'
components => [], agent => $self}, 'NGCP::Rtpclient::ICE::Candidate::Pair'
);
my $comps = $pair->{components};
@ -303,7 +303,7 @@ sub pair_candidates {
local => $loc->{components}->[$idx],
remote => $rem->{components}->[$idx],
agent => $self},
'ICE::Component::Pair');
'NGCP::Rtpclient::ICE::Component::Pair');
$c->{state} = $c->{state} || ($idx == 0 ? 'waiting' : 'frozen');
}
}
@ -813,21 +813,21 @@ sub get_send_component {
$pair->{components}->[$component]->{remote}->{packed_peer});
}
package ICE::Candidate;
package NGCP::Rtpclient::ICE::Candidate;
sub debug {
my ($self, @rest) = @_;
$self->{agent}->debug("candidate", $self->{foundation}, ' - ', @rest);
}
package ICE::Component;
package NGCP::Rtpclient::ICE::Component;
sub debug {
my ($self, @rest) = @_;
$self->{agent}->debug("component $self->{foundation}/$self->{component}", ' - ', @rest);
}
package ICE::Candidate::Pair;
package NGCP::Rtpclient::ICE::Candidate::Pair;
sub priority {
my ($self) = @_;
@ -849,7 +849,7 @@ sub nominate {
}
}
package ICE::Component::Pair;
package NGCP::Rtpclient::ICE::Component::Pair;
sub debug {
my ($self, @rest) = @_;
@ -888,7 +888,7 @@ sub run_check {
$self->debug("running check\n");
$self->{state} = 'in progress';
$self->{transaction} = ICE::random_string(12);
$self->{transaction} = NGCP::Rtpclient::ICE::random_string(12);
$self->send_check();
# XXX handle retransmits
}
@ -913,16 +913,16 @@ sub send_check {
my $local_cand = $self->{agent}->{candidates}->{$local_comp->{foundation}};
my $attrs = [];
unshift(@$attrs, ICE::attr(0x8022, 'perl:ICE.pm'));
unshift(@$attrs, NGCP::Rtpclient::ICE::attr(0x8022, 'perl:ICE.pm'));
my $hexbrk = $self->{agent}->{tie_breaker}->as_hex();
$hexbrk =~ s/^0x// or die;
$hexbrk = ('0' x (16 - length($hexbrk))) . $hexbrk;
unshift(@$attrs, ICE::attr($self->{agent}->{controlling} ? 0x802a : 0x8029, pack('H*', $hexbrk)));
unshift(@$attrs, ICE::attr(0x0024, pack('N', ICE::calc_priority('prflx',
unshift(@$attrs, NGCP::Rtpclient::ICE::attr($self->{agent}->{controlling} ? 0x802a : 0x8029, pack('H*', $hexbrk)));
unshift(@$attrs, NGCP::Rtpclient::ICE::attr(0x0024, pack('N', NGCP::Rtpclient::ICE::calc_priority('prflx',
$local_cand->{preference}, $local_comp->{component}))));
unshift(@$attrs, ICE::attr(0x0006, "$self->{agent}->{other_ufrag}:$self->{agent}->{my_ufrag}"));
unshift(@$attrs, NGCP::Rtpclient::ICE::attr(0x0006, "$self->{agent}->{other_ufrag}:$self->{agent}->{my_ufrag}"));
$self->{nominate} and
unshift(@$attrs, ICE::attr(0x0025, ''));
unshift(@$attrs, NGCP::Rtpclient::ICE::attr(0x0025, ''));
$self->{agent}->integrity($attrs, 1, $self->{transaction}, $self->{agent}->{other_pwd});
$self->{agent}->fingerprint($attrs, 1, $self->{transaction});

@ -1,4 +1,4 @@
package RTP;
package NGCP::Rtpclient::RTP;
use strict;
use warnings;

@ -1,4 +1,4 @@
package SDP;
package NGCP::Rtpclient::SDP;
use strict;
use warnings;
@ -41,7 +41,7 @@ sub decode {
next;
}
if ($line =~ /^m=(\S+) (\d+) (\S+) (\d+(?: \d+)*)$/s) {
$media = $self->add_media(SDP::Media->new_remote($1, $2, $3, $4));
$media = $self->add_media(NGCP::Rtpclient::SDP::Media->new_remote($1, $2, $3, $4));
next;
}
if ($line =~ /^c=(.*)$/) {
@ -117,7 +117,7 @@ sub decode_address {
}
package SDP::Media;
package NGCP::Rtpclient::SDP::Media;
use Socket;
use Socket6;
@ -162,21 +162,21 @@ sub add_attrs {
sub encode {
my ($self, $parent_connection) = @_;
my $pconn = $parent_connection ? SDP::encode_address($parent_connection) : '';
my $pconn = $parent_connection ? NGCP::Rtpclient::SDP::encode_address($parent_connection) : '';
my @out;
push(@out, "m=$self->{type} " . $self->{rtp}->sockport() . ' ' . $self->{protocol} . ' '
. join(' ', @{$self->{payload_types}}));
my $rtpconn = SDP::encode_address($self->{rtp});
my $rtpconn = NGCP::Rtpclient::SDP::encode_address($self->{rtp});
$rtpconn eq $pconn or push(@out, "c=$rtpconn");
push(@out, 'a=sendrecv');
if ($self->{rtcp}) {
my $rtcpconn = SDP::encode_address($self->{rtcp});
my $rtcpconn = NGCP::Rtpclient::SDP::encode_address($self->{rtcp});
push(@out, 'a=rtcp:' . $self->{rtcp}->sockport()
. ($rtcpconn eq $rtpconn ? '' : (' ' . SDP::encode_address($self->{rtcp}))));
. ($rtcpconn eq $rtpconn ? '' : (' ' . NGCP::Rtpclient::SDP::encode_address($self->{rtcp}))));
}
push(@out, @{$self->{additional_attributes}});

@ -1,4 +1,4 @@
package SRTP;
package NGCP::Rtpclient::SRTP;
use strict;
use warnings;

@ -1,4 +1,4 @@
package Rtpengine;
package NGCP::Rtpengine;
use strict;
use warnings;

@ -1,4 +1,4 @@
package Rtpengine::Test;
package NGCP::Rtpengine::Test;
use strict;
use warnings;
@ -12,11 +12,11 @@ use Net::Interface;
use List::Util;
use IO::Multiplex;
use Time::HiRes qw(time);
use SDP;
use ICE;
use DTLS;
use RTP;
use Rtpengine;
use NGCP::Rtpclient::SDP;
use NGCP::Rtpclient::ICE;
use NGCP::Rtpclient::DTLS;
use NGCP::Rtpclient::RTP;
use NGCP::Rtpengine;
sub new {
my ($class, %args) = @_;
@ -53,7 +53,7 @@ sub new {
$self->{timers} = [];
$self->{clients} = [];
$self->{control} = Rtpengine->new($args{host} // 'localhost', $args{port} // 2223);
$self->{control} = NGCP::Rtpengine->new($args{host} // 'localhost', $args{port} // 2223);
$self->{callid} = rand();
return $self;
@ -61,7 +61,7 @@ sub new {
sub client {
my ($self, %args) = @_;
my $cl = Rtpengine::Test::Client->_new($self, %args);
my $cl = NGCP::Rtpengine::Test::Client->_new($self, %args);
push(@{$self->{clients}}, $cl);
return $cl;
}
@ -124,7 +124,7 @@ sub mux_timeout {
}
package Rtpengine::Test::Client;
package NGCP::Rtpengine::Test::Client;
use Socket;
@ -168,7 +168,7 @@ sub _new {
$self->{rtcp_sockets} = \@rtcp;
$self->{main_sockets} = $sockets[0]; # for m= and o=
$self->{local_sdp} = SDP->new($self->{main_sockets}->[0]); # no global c=
$self->{local_sdp} = NGCP::Rtpclient::SDP->new($self->{main_sockets}->[0]); # no global c=
$self->{component_peers} = []; # keep track of peer source addresses
# default protocol
@ -176,17 +176,17 @@ sub _new {
$args{dtls} and $proto = 'UDP/TLS/RTP/SAVP';
$args{protocol} and $proto = $args{protocol};
$self->{local_media} = $self->{local_sdp}->add_media(SDP::Media->new(
$self->{local_media} = $self->{local_sdp}->add_media(NGCP::Rtpclient::SDP::Media->new(
$self->{main_sockets}->[0], $self->{main_sockets}->[1], $proto)); # main rtp and rtcp
# XXX support multiple medias
if ($args{dtls}) {
$self->{dtls} = DTLS::Group->new($parent->{mux}, $self, [ \@rtp, \@rtcp ]);
$self->{dtls} = NGCP::Rtpclient::DTLS::Group->new($parent->{mux}, $self, [ \@rtp, \@rtcp ]);
$self->{local_media}->add_attrs($self->{dtls}->encode());
$self->{dtls}->accept(); # XXX support other modes
}
if ($args{ice}) {
$self->{ice} = ICE->new(2, 1); # 2 components, controlling XXX
$self->{ice} = NGCP::Rtpclient::ICE->new(2, 1); # 2 components, controlling XXX
my $pref = 65535;
for my $s (@sockets) {
$self->{ice}->add_candidate($pref--, 'host', @$s); # 2 components
@ -286,7 +286,7 @@ sub _offered {
my ($self, $req) = @_;
my $sdp_body = $req->{sdp} or die;
$self->{remote_sdp} = SDP->decode($sdp_body);
$self->{remote_sdp} = NGCP::Rtpclient::SDP->decode($sdp_body);
# XXX validate SDP
@{$self->{remote_sdp}->{medias}} == 1 or die;
$self->{remote_media} = $self->{remote_sdp}->{medias}->[0];
@ -311,7 +311,7 @@ sub _answered {
my ($self, $req) = @_;
my $sdp_body = $req->{sdp} or die;
$self->{remote_sdp} = SDP->decode($sdp_body);
$self->{remote_sdp} = NGCP::Rtpclient::SDP->decode($sdp_body);
# XXX validate SDP
@{$self->{remote_sdp}->{medias}} == 1 or die;
$self->{remote_media} = $self->{remote_sdp}->{medias}->[0];
@ -370,7 +370,7 @@ sub start_rtp {
my ($self) = @_;
$self->{rtp} and die;
my $dest = $self->{remote_media}->endpoint();
$self->{rtp} = RTP->new($self) or die;
$self->{rtp} = NGCP::Rtpclient::RTP->new($self) or die;
}
sub stop {

@ -2,10 +2,10 @@
use strict;
use warnings;
use Rtpengine::Test;
use NGCP::Rtpengine::Test;
use IO::Socket;
my $r = Rtpengine::Test->new();
my $r = NGCP::Rtpengine::Test->new();
my ($a, $b) = $r->client_pair(
{sockdomain => &Socket::AF_INET},
{sockdomain => &Socket::AF_INET}

@ -2,9 +2,9 @@
use strict;
use warnings;
use Rtpengine::Test;
use NGCP::Rtpengine::Test;
my $r = Rtpengine::Test->new();
my $r = NGCP::Rtpengine::Test->new();
my $a = $r->client(dtls => 1);
my $b = $r->client();

@ -2,9 +2,9 @@
use strict;
use warnings;
use Rtpengine::Test;
use NGCP::Rtpengine::Test;
my $r = Rtpengine::Test->new();
my $r = NGCP::Rtpengine::Test->new();
my $a = $r->client(ice => 1);
my $b = $r->client(sockdomain => &Socket::AF_INET);

@ -2,10 +2,10 @@
use strict;
use warnings;
use Rtpengine::Test;
use NGCP::Rtpengine::Test;
use IO::Socket;
my $r = Rtpengine::Test->new(host => '192.168.1.128');
my $r = NGCP::Rtpengine::Test->new(host => '192.168.1.128');
my ($a, $b) = $r->client_pair(
{sockdomain => &Socket::AF_INET},
{sockdomain => &Socket::AF_INET}

@ -7,7 +7,7 @@ use warnings;
use strict;
use Getopt::Long;
use Data::Dumper;
use Rtpengine;
use NGCP::Rtpengine;
my %options = ('proxy-address' => 'localhost', 'proxy-port' => 2223);
@ -99,7 +99,7 @@ elsif (defined($options{'sdp-file'})) {
$options{verbose} and print Dumper \%packet;
my $engine = Rtpengine->new($options{'proxy-address'}, $options{'proxy-port'});
my $engine = NGCP::Rtpengine->new($options{'proxy-address'}, $options{'proxy-port'});
my $resp = $engine->req(\%packet);
#print Dumper $resp;

Loading…
Cancel
Save