3 # (the Shout library causes warnings if we use -w)
6 # Usage: yashout filename mountpoint [ port ]
8 # Copyright (c) 2003 Ivan Kohler
10 # This program is free software; you can redistribute it and/or modify it under
11 # the same terms as Perl itself.
14 use subs qw(daemonize);
15 use POSIX qw(:sys_wait_h setsid);
18 my $encoder_password = 'haze420';
20 #read options from commandline
21 my($filename, $mountpoint, $port) = @ARGV;
23 my $conn = new Shout (
25 port => $port || 8000,
27 password => $encoder_password,
30 name => 'Fonestream audio',
31 url => 'http://www.fonestream.com/',
33 description => 'The easiest way to webcast.',
37 $conn->connect or die "Failed to connect: ". $conn->error;
39 open(SFILE,"</home/ivan/plexmp3/silence.mp3") or die "Can't open silence.mp3: $!";
40 open(FILE,"<$filename") or die "Can't open $filename: $!";
42 daemonize(); #fork/disconnect so plex.pls will return to client
46 #send silence header to server
47 my( $sbuffer, $sbytes ) = ( '', 0 );
48 while ( ( $sbytes = read( SFILE, $sbuffer, 4096 ) ) > 0 ) {
49 $conn->sendData( $sbuffer ) && next;
51 print STDERR "Error while sending: ", $conn->error, "\n";
62 my( $buffer, $bytes ) = ( '', 0 );
63 while ( ( $bytes = read( FILE, $buffer, 4096 ) ) > 0 ) {
64 $conn->sendData( $buffer ) && next;
66 print STDERR "Error while sending: ", $conn->error, "\n";
75 chdir "/" or die "Can't chdir to /: $!";
76 open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
77 defined(my $pid = fork) or die "Can't fork: $!";
79 #print "yashout started with pid $pid\n"; #logging to $log_file\n";
80 #exit unless $pid_file;
81 #my $pidfh = new IO::File ">$pid_file" or exit;
82 #print $pidfh "$pid\n";
85 open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
86 setsid or die "Can't start a new session: $!";
87 open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
89 #$SIG{__DIE__} = \&_die;
90 #$SIG{__WARN__} = \&_logmsg;