POE-Component-Client-Icecast
view release on metacpan or search on metacpan
lib/POE/Component/Client/Icecast.pm view on Meta::CPAN
}
#
sub _parse_stream_param {
my $stream = shift || return {};
my($domain, $path) = $stream =~ m{^ http :// ([^/]+) / (.*) }x;
my($addr, $port) = $domain =~ m{^ (.*) : (.*) }x;
return {
'Host' => $addr || $domain,
'RemoteAddress' => $addr || $domain,
'RemotePort' => $port || 80,
'Path' => $path,
};
}
1;
__END__
=head1 NAME
POE::Component::Client::Icecast - non-blocking client to Icecast server for getting tags
=head1 SYNOPSIS
use strict;
use POE qw(Component::Client::Icecast);
use Data::Dumper;
POE::Component::Client::Icecast->new(
Stream => 'http://station20.ru:8000/station-128',
Reconnect => 10,
GetTags => sub {
warn Dumper $_[ARG0];
},
);
# or
POE::Component::Client::Icecast->new(
Host => 'station20.ru',
Path => '/station-128',
RemoteAddress => '87.242.82.108',
RemotePort => 8000,
BindPort => 8103, # for only one permanent client
Reconnect => 10,
GetTags => sub {
warn Dumper $_[ARG0];
},
);
POE::Kernel->run;
=head1 DESCRIPTION
The module is a non-blocking client to Icecast streaming multimedia server for getting stream tags.
See L<http://www.icecast.org/>.
POE::Component::Client::Icecast is based on L<POE::Component::Client::TCP>.
=head1 METHODS
=head2 new
POE::Component::Client::Icecast->new(
Stream => 'http://station20.ru:8000/station-128',
# or
Host => 'station20.ru',
Path => '/station-128',
RemoteAddress => '87.242.82.108',
RemotePort => 8000,
BindPort => 8103, # for only one permanent client
# get tags from server
GetTags => sub {
warn Dumper $_[ARG0];
},
);
PoCo::Client::Icecast's new method takes a few named parameters:
=over 9
=item * I<Stream>
The stream url to Icecast stream, which contains domain, port and path to stream. Recommended.
Instead of this param you ought to use: I<Host>, I<Path>, I<RemoteAddr> and I<RemotePort>.
=item * I<Host>
The host of Icecast server (without port).
=item * I<Path>
The path to Icecast stream.
=item * I<RempoteAddress>
The remote address to connect to Icecast server (host or ip).
It's a param of L<POE::Component::Client::TCP>.
=item * I<RemotePort>
The remote port to connect.
It's a param of L<POE::Component::Client::TCP>.
=item * I<BindAddress>
The param specifies the local interface address to bind to before starting to connect.
( run in 2.631 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )