commiting recent changes
[iceplex.git] / yashout
diff --git a/yashout b/yashout
index 58868fc..87b5a91 100644 (file)
--- a/yashout
+++ b/yashout
 
 use strict;
 use subs qw(daemonize);
+use POSIX qw(:sys_wait_h setsid);
 use Shout;
 
+my $encoder_password = 'haze420';
+
 #read options from commandline
 my($filename, $mountpoint, $port) = @ARGV;
 
@@ -21,21 +24,40 @@ my $conn = new Shout (
   ip          => 'localhost',
   port        => $port || 8000,
   mount       => $mountpoint,
+  password    => $encoder_password,
   icy_compat  => 0,
   dumpfile    => undef,
   name        => 'Fonestream audio',
   url         => 'http://www.fonestream.com/',
   genre       => 'talk',
   description => 'The easiest way to webcast.',
-  bitrate     => 64,
+  bitrate     => 16,
   ispublic    => 0,
 );
 $conn->connect or die "Failed to connect: ". $conn->error;
 
+open(SFILE,"</home/ivan/plexmp3/silence.mp3") or die "Can't open silence.mp3: $!";
 open(FILE,"<$filename") or die "Can't open $filename: $!";
 
 daemonize(); #fork/disconnect so plex.pls will return to client
 
+if ( 0 ) {
+
+  #send silence header to server
+  my( $sbuffer, $sbytes ) = ( '', 0 );
+  while ( ( $sbytes = read( SFILE, $sbuffer, 4096 ) ) > 0 ) {
+    $conn->sendData( $sbuffer ) && next;
+    # error handling???
+    print STDERR "Error while sending: ", $conn->error, "\n";
+    last;
+  } continue {
+    $conn->sleep;
+  }
+
+}
+
+sleep 10;
+
 #spool file to server
 my( $buffer, $bytes ) = ( '', 0 );
 while ( ( $bytes = read( FILE, $buffer, 4096 ) ) > 0 ) {
@@ -55,7 +77,7 @@ sub daemonize {
   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;
+    #exit unless $pid_file;
     #my $pidfh = new IO::File ">$pid_file" or exit;
     #print $pidfh "$pid\n";
     exit;