| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Icecast2::Mount; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$Net::Icecast2::Mount::VERSION = '0.005'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Icecast2 Server Mount API |
|
6
|
2
|
|
|
2
|
|
36619
|
use Moo; |
|
|
2
|
|
|
|
|
28425
|
|
|
|
2
|
|
|
|
|
13
|
|
|
7
|
2
|
|
|
2
|
|
3213
|
use MooX::Types::MooseLike::Base qw(Str); |
|
|
2
|
|
|
|
|
8124
|
|
|
|
2
|
|
|
|
|
192
|
|
|
8
|
|
|
|
|
|
|
extends 'Net::Icecast2'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
15
|
use Carp; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
122
|
|
|
11
|
2
|
|
|
2
|
|
958
|
use Sub::Quote qw(quote_sub); |
|
|
2
|
|
|
|
|
4486
|
|
|
|
2
|
|
|
|
|
132
|
|
|
12
|
2
|
|
|
2
|
|
1889
|
use PHP::HTTPBuildQuery qw(http_build_query); |
|
|
2
|
|
|
|
|
4049
|
|
|
|
2
|
|
|
|
|
1123
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Net::Icecast2::Mount - Icecast2 Server Mount API |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Net::Icecast2::Mount; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $icecast_mount = Net::Icecast2::Mount->new( |
|
23
|
|
|
|
|
|
|
host => 192.168.1.10, |
|
24
|
|
|
|
|
|
|
port => 8008, |
|
25
|
|
|
|
|
|
|
protocol => 'https', |
|
26
|
|
|
|
|
|
|
login => 'source', |
|
27
|
|
|
|
|
|
|
password => 'hackme', |
|
28
|
|
|
|
|
|
|
mount => '/my_mount.ogg', |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$icecast_mount->metadata_update( song => 'New song' ); |
|
32
|
|
|
|
|
|
|
$icecast_mount->fallback_update( '/new_fallback.ogg' ); |
|
33
|
|
|
|
|
|
|
$icecast_mount->list_clients; |
|
34
|
|
|
|
|
|
|
$icecast_mount->move_client( '/new_mount_point.ogg' ); |
|
35
|
|
|
|
|
|
|
$icecast_mount->kill_client( 23444 ); |
|
36
|
|
|
|
|
|
|
$icecast_mount->kill_source; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 DESCRIPTION |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Make request for Icecast2 Server Mount API |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 host |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Description : Icecast2 Server hostname |
|
47
|
|
|
|
|
|
|
Default : localhost |
|
48
|
|
|
|
|
|
|
Required : 0 |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 port |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Description : Icecast2 Server port |
|
55
|
|
|
|
|
|
|
Default : 8000 |
|
56
|
|
|
|
|
|
|
Required : 0 |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 protocol |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Description : Icecast2 Server protocol ( scheme ) |
|
63
|
|
|
|
|
|
|
Default : http |
|
64
|
|
|
|
|
|
|
Required : 0 |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 login |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Description : Icecast2 Server Mount username |
|
71
|
|
|
|
|
|
|
Default : source |
|
72
|
|
|
|
|
|
|
Required : 0 |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
has '+login' => ( |
|
76
|
|
|
|
|
|
|
required => 0, |
|
77
|
|
|
|
|
|
|
default => quote_sub(q{ 'source' }), |
|
78
|
|
|
|
|
|
|
); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 password |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Description : Icecast2 Server Mount password |
|
83
|
|
|
|
|
|
|
Required : 1 |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 mount |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Description : Icecast2 Server Mountpoint |
|
90
|
|
|
|
|
|
|
Required : 1 |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
|
93
|
|
|
|
|
|
|
has mount => ( |
|
94
|
|
|
|
|
|
|
is => 'ro', |
|
95
|
|
|
|
|
|
|
isa => Str, |
|
96
|
|
|
|
|
|
|
required => 1, |
|
97
|
|
|
|
|
|
|
); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 METHODS |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 metadata_update |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Usage : $icecast_mount->metadata_update( song => 'New song' ); |
|
104
|
|
|
|
|
|
|
Arguments : List or HashRef of data parameters must update |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Description : This function provides the ability for either a source client |
|
107
|
|
|
|
|
|
|
or any external program to update the metadata information for |
|
108
|
|
|
|
|
|
|
a particular mountpoint. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
sub metadata_update { |
|
112
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
113
|
0
|
0
|
|
|
|
|
my %data = ( ref $_[0] eq 'HashRef' ? %{$_[0]} : @_ ); |
|
|
0
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
scalar %data or print STDERR 'Updating with empty metadata'; |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$self->_make_request( '/metadata', mode => 'updinfo', %data ); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 fallback_update |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Usage : $icecast_mount->fallback_update( '/new_fallback.ogg' ); |
|
123
|
|
|
|
|
|
|
Arguments : New fallback mount point |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Description : This function provides the ability for either a source client |
|
126
|
|
|
|
|
|
|
or any external program to update the "fallback mountpoint" |
|
127
|
|
|
|
|
|
|
for a particular mountpoint. Fallback mounts are those that are |
|
128
|
|
|
|
|
|
|
used in the even of a source client disconnection. If a source |
|
129
|
|
|
|
|
|
|
client disconnects for some reason that all currently connected |
|
130
|
|
|
|
|
|
|
clients are sent immediately to the fallback mountpoint. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
|
133
|
|
|
|
|
|
|
sub fallback_update { |
|
134
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
135
|
0
|
|
|
|
|
|
my $fallback = shift; |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
defined $fallback or croak 'Fallback must be defined'; |
|
138
|
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$self->_make_request( '/fallbacks', fallback => $fallback ); |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 list_clients |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Usage : $icecast_mount->list_clients; |
|
145
|
|
|
|
|
|
|
Arguments : No Arguments |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Description : This function lists all the clients currently connected to a |
|
148
|
|
|
|
|
|
|
specific mountpoint. The results are sent back in XML form. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Return : HashRef like |
|
151
|
|
|
|
|
|
|
mount => mount point |
|
152
|
|
|
|
|
|
|
listeners => listeners number |
|
153
|
|
|
|
|
|
|
listener => Array with info per each listener |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
|
156
|
|
|
|
|
|
|
sub list_clients { |
|
157
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
$self->_make_request( '/listclients' ); |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 move_clients |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Usage : $icecast_mount->move_client( '/new_mount_point.ogg' ); |
|
165
|
|
|
|
|
|
|
Arguments : New mount point |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Description : This function provides the ability to migrate currently |
|
168
|
|
|
|
|
|
|
connected listeners from one mountpoint to another. This |
|
169
|
|
|
|
|
|
|
function requires 2 mountpoints to be passed in: mount |
|
170
|
|
|
|
|
|
|
(the *from* mountpoint) and destination (the *to* mountpoint). |
|
171
|
|
|
|
|
|
|
After processing this function all currently connected |
|
172
|
|
|
|
|
|
|
listeners on mount will be connected to destination. Note that |
|
173
|
|
|
|
|
|
|
the destination mountpoint must exist and have a sounce client |
|
174
|
|
|
|
|
|
|
already feeding it a stream. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Return : 1 on success and 0 on failure |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
|
179
|
|
|
|
|
|
|
sub move_clients { |
|
180
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
181
|
0
|
|
|
|
|
|
my $new_mount = shift; |
|
182
|
|
|
|
|
|
|
|
|
183
|
0
|
0
|
|
|
|
|
defined $new_mount or croak 'Destination mount should be defined'; |
|
184
|
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
$self->_make_request( '/moveclients', ( destination => $new_mount ) ); |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 kill_client |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Usage : $icecast_mount->kill_client( 23444 ); |
|
191
|
|
|
|
|
|
|
Arguments : User ID can get from 'list_client' method |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Description : This function provides the ability to disconnect a specific |
|
194
|
|
|
|
|
|
|
listener of a currently connected mountpoint. Listeners are |
|
195
|
|
|
|
|
|
|
identified by a unique id that can be retrieved by via the |
|
196
|
|
|
|
|
|
|
"List Clients" admin function. This id must be passed in to |
|
197
|
|
|
|
|
|
|
the request. After processing this request, the listener will |
|
198
|
|
|
|
|
|
|
no longer be connected to the mountpoint. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Return : 1 on success and 0 on failure |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub kill_client { |
|
205
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
206
|
0
|
|
|
|
|
|
my $client_id = shift; |
|
207
|
|
|
|
|
|
|
|
|
208
|
0
|
0
|
|
|
|
|
defined $client_id or croak "Clinet ID should be defined"; |
|
209
|
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
$self->_make_request( '/killclient', id => $client_id ); |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head2 kill_source |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Usage : $icecast_mount->kill_source; |
|
216
|
|
|
|
|
|
|
Arguments : No Argements |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Description : This function will provide the ability to disconnect a specific |
|
219
|
|
|
|
|
|
|
mountpoint from the server. The mountpoint to be disconnected is |
|
220
|
|
|
|
|
|
|
specified via the variable "mount". |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=cut |
|
223
|
|
|
|
|
|
|
sub kill_source { |
|
224
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
225
|
|
|
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
$self->_make_request( '/killsource' ); |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
# Arguments : Request path and GET method data |
|
230
|
|
|
|
|
|
|
# Description : Private method for build correct GET request to mount point API |
|
231
|
|
|
|
|
|
|
# Return : XML Parsed data from server |
|
232
|
|
|
|
|
|
|
sub _make_request { |
|
233
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
234
|
0
|
|
|
|
|
|
my $path = shift; |
|
235
|
|
|
|
|
|
|
|
|
236
|
0
|
0
|
|
|
|
|
defined $path or croak "Request path should be defined"; |
|
237
|
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
|
my %data = ( @_, mount => $self->mount ); |
|
239
|
0
|
|
|
|
|
|
my $full_path = $path .'?'. http_build_query( \%data ); |
|
240
|
|
|
|
|
|
|
|
|
241
|
0
|
|
|
|
|
|
$self->request( $full_path ); |
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
|
|
244
|
2
|
|
|
2
|
|
16
|
no Moo; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
23
|
|
|
245
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
246
|
|
|
|
|
|
|
1; |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Icecast2 server: http://www.icecast.org |
|
251
|
|
|
|
|
|
|
Icecast2 API Docs: http://www.icecast.org/docs/icecast-trunk/icecast2_admin.html |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Related modules L L |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 AUTHOR |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Pavel R3VoLuT1OneR Zhytomirsky |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Pavel R3VoLuT1OneR Zhytomirsky. |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
264
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=cut |
|
267
|
|
|
|
|
|
|
|