| 1 | package POE::Component::Client::Icecast; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Carp 'carp', 'croak'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use POE::Session; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use POE::Filter::Stream; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use POE::Component::Client::TCP; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use constant TRACE => $ENV{'ICECAST_TRACE'} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Condition50%1/2
$ENV{'ICECAST_TRACE'} || 0
MC/DC0%0/1
$ENV{'ICECAST_TRACE'} || 0
$ENV{'ICECAST_TRACE'}
Truth table50%1/2
A
A= $ENV{'ICECAST_TRACE'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use constant DEBUG => $ENV{'ICECAST_DEBUG'} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Condition50%1/2
$ENV{'ICECAST_DEBUG'} || 0
MC/DC0%0/1
$ENV{'ICECAST_DEBUG'} || 0
$ENV{'ICECAST_DEBUG'}
Truth table50%1/2
A
A= $ENV{'ICECAST_DEBUG'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | our $VERSION = 0.6; | |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my $param = {@_}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my $mi = $type.'->new()'; # hi, Rocco Caputto! | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | croak "$mi requires an even number of parameters" if @_ & 1; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | my $stream = $param->{'Stream'} ? _parse_stream_param($param->{'Stream'}) : {}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $path = $stream->{'Path'} || $param->{'Path'} || croak "$mi requires Path param to stream"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$stream->{'Path'} || $param->{'Path'} || croak("$mi requires Path param to stream")
$stream->{"Path"} or $param->{"Path"}
MC/DC0%0/2
$stream->{'Path'} || $param->{'Path'} || croak("$mi requires Path param to stream")
$stream->{"Path"}
$param->{"Path"}
Truth table0%0/3
A or B
A= $stream->{"Path"}B= $param->{"Path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | $path = "/$path" unless $path =~ m{^/}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | POE::Component::Client::TCP->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | (map { $_ => $stream->{$_} || $param->{$_} } 'Alias', 'RemoteAddress', 'RemotePort', 'BindAddress', 'BindPort'), | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$stream->{$_} || $param->{$_}
MC/DC0%0/2
$stream->{$_} || $param->{$_}
$stream->{$_}
$param->{$_}
Truth table0%0/3
A || B
A= $stream->{$_}B= $param->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 'Filter' => POE::Filter::Stream->new, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | 'Connected' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $_[HEAP]->{'server'}->put(grep { DEBUG && warn $_;1 } join "\n", | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | "GET $path HTTP/1.0", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 'Icy-MetaData: 1', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ('') x 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | 'ServerInput' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | DEBUG && warn 'Server input ' . length $_[ARG0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | return unless my %tag = $_[ARG0] =~ /Stream(\w+)='(.*?)';/g; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | DEBUG && warn $tag{'Title'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | local $_[ARG0] = \%tag; | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | ref $param->{'GetTags'} eq 'CODE' && $param->{'GetTags'}->(@_); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | 'Disconnected' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | DEBUG && warn "$mi disconnected"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ($param->{'Reconnect'}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | DEBUG && warn "$mi will reconnect, delay is $param->{'Reconnect'}"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $_[KERNEL]->delay('reconnect' => $param->{'Reconnect'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | 'ConnectError' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | warn "$param->{'Stream'} connect error: " . $_[ARG2] . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($param->{'Reconnect'}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | DEBUG && warn "$mi will reconnect, delay is $param->{'Reconnect'}"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $_[KERNEL]->delay('reconnect' => $param->{'Reconnect'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | 'ServerError' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # XXX: can croak if args | ||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | warn "$param->{'Stream'} server error: " . $_[ARG0] . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | 'SessionParams' => [ 'options' => { 'trace' => TRACE } ], | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ) or croak "$mi has error: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub _parse_stream_param { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_stream_param: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $stream = shift || return {}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || (return {})
MC/DC0%0/1
shift() || (return {})
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my($domain, $path) = $stream =~ m{^ http :// ([^/]+) / (.*) }x; | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my($addr, $port) = $domain =~ m{^ (.*) : (.*) }x; | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | 'Host' => $addr || $domain, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$addr || $domain
$addr || $domain
$port || 80
MC/DC0%0/2
$addr || $domain
$addr
$domain
MC/DC0%0/2
$addr || $domain
$addr
$domain
MC/DC0%0/1
$port || 80
$port
Truth table0%0/3
A || B
A= $addrB= $domain
Truth table0%0/3
A || B
A= $addrB= $domain
Truth table0%0/2
A
A= $port
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 'RemoteAddress' => $addr || $domain, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 'RemotePort' => $port || 80, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 'Path' => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||