as appropriate:
- Database location/user/pass
- Path to mp3 file storage on the icecast servers.
- - Icecast Port number
+ - Icecast port number
+ -
- Run iceplexd and configure your init scripts to start it upon boot.
- Create an "iceplex" user.
- Run "ssh-keygen -t dsa" as the "iceplex" user to genarate SSH keys.
<http://search.cpan.org/author/DWHEELER/DBD-Pg/>
- Install plex.pls in /cgi-bin/ on the central multiplexing server or main
webserver. This file can be installed as or linked to as "plex.m3u" if
- desired.
+ desired. chown this file to the "iceplex", chgrp this file to the
+ user Apache runs as (www-data or httpd), and chown this file to 4750
On each icecast server:
- Create an "iceplex" user.
- Copy "/home/iceplex/.ssh/id_dsa.pub" from the central multiplexing server
to "/home/iceplex/.ssh/authorized_keys".
- - Verify that the
+ - Verify that the iceplex user on the central multiplexing server can
+ ssh to this server without a password.
- Install libshout C library 1.0.9 and Shout perl interface:
<http://developer.icecast.org/libshout/>
+ - Set the encoder password in yashout
- Install yashout from this archive in /usr/local/bin
On end-user webpages:
- - Link to:
+ - Link to (see example.html):
<http://multi.plexing.server/cgi-bin/plex.pls?customer=XXXXXX;user=YYYY>
Optional, improves stream start latency:
+- Reliability: yashout errors bubble back to plex.pls & cause server to be
+ taken out of rotation?
+
+- Log yashout errors feeding to server somewhere?
+
+- Configurability of yashoult name/url/genre/description/bitrate/ispublic/etc.
+
- mp3 file storage should be in hashed directories for scalability
+
+- for scalability, some amount of iceplexd parallelism: fping for ping?
+ fork so as to not block on waiting for listeners?
+ (is one process per server too much?)
#!/usr/bin/perl
+#
+# iceplexd
+#
+# Copyright (c) 2003 Ivan Kohler
+# All rights reserved.
+# This program is free software; you can redistribute it and/or modify it under
+# the same terms as Perl itself.
+
+# TODO, fake it for now :)
+
+# daemonize
+
+while (1) {
+
+ # select all servers
+ # SELECT * FROM iceplex_servers
+
+ foreach my $server ( @servers ) {
+ #ping , set status
+ # ask # of listeners
+ #update database
+
+ }
+
+sleep 5;
+}
my $mountpoint = md5_hex($cgi->remote_host. $$. time. int(rand(4294967296)));
#signal encoder to start streaming to mountpoint & wait for confirmation
-ssh($server, 'yashout', $filename, $mountpoint );
+ssh($server, 'yashout', $filename, $mountpoint, $port );
#send file back to client browser
#!/usr/bin/perl
+#!/usr/bin/perl -w
+# (the Shout library causes warnings if we use -w)
#
# yashout
-# Usage: yashout filename mountpoint
+# Usage: yashout filename mountpoint [ port ]
#
# Copyright (c) 2003 Ivan Kohler
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it under
# the same terms as Perl itself.
+use strict;
+use subs qw(daemonize);
use Shout;
+
+#read options from commandline
+my($filename, $mountpoint, $port) = @ARGV;
+
+my $conn = new Shout (
+ ip => 'localhost',
+ port => $port || 8000,
+ mount => $mountpoint,
+ icy_compat => 0,
+ dumpfile => undef,
+ name => 'Fonestream audio',
+ url => 'http://www.fonestream.com/',
+ genre => 'talk',
+ description => 'The easiest way to webcast.',
+ bitrate => 64,
+ ispublic => 0,
+);
+$conn->connect or die "Failed to connect: ". $conn->error;
+
+open(FILE,"<$filename") or die "Can't open $filename: $!";
+
+daemonize(); #fork/disconnect so plex.pls will return to client
+
+#spool file to server
+my( $buffer, $bytes ) = ( '', 0 );
+while ( ( $bytes = read( FILE, $buffer, 4096 ) ) > 0 ) {
+ $conn->sendData( $buffer ) && next;
+ # error handling???
+ print STDERR "Error while sending: ", $conn->error, "\n";
+ last;
+} continue {
+ $conn->sleep;
+}
+
+$conn->disconnect;
+
+sub daemonize {
+ chdir "/" or die "Can't chdir to /: $!";
+ open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
+ defined(my $pid = fork) or die "Can't fork: $!";
+ if ( $pid ) {
+ #print "yashout started with pid $pid\n"; #logging to $log_file\n";
+ exit unless $pid_file;
+ #my $pidfh = new IO::File ">$pid_file" or exit;
+ #print $pidfh "$pid\n";
+ exit;
+ }
+ open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
+ setsid or die "Can't start a new session: $!";
+ open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
+
+ #$SIG{__DIE__} = \&_die;
+ #$SIG{__WARN__} = \&_logmsg;
+
+}
+
+