[xiph-cvs] cvs commit: shout-perl example.pl example2.pl

Brendan brendan at xiph.org
Sat Jul 5 11:42:03 PDT 2003



brendan     03/07/05 14:42:03

  Modified:    .        example.pl example2.pl
  Log:
  minor updates

Revision  Changes    Path
1.2       +4 -5      shout-perl/example.pl

Index: example.pl
===================================================================
RCS file: /usr/local/cvsroot/shout-perl/example.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -u -r1.1 -r1.2
--- example.pl	3 Jul 2003 16:42:05 -0000	1.1
+++ example.pl	5 Jul 2003 18:42:03 -0000	1.2
@@ -10,21 +10,22 @@ my $conn = new Shout;
 # setup all the params
 $conn->host('localhost');
 $conn->port(8000);
-$conn->mount('/testing');
+$conn->mount('/example');
 $conn->password('hackme');
 $conn->public(0);
 $conn->format(SHOUT_FORMAT_MP3);
 $conn->protocol(SHOUT_PROTOCOL_HTTP);
+$conn->set_audio_info(SHOUT_AI_BITRATE => 128, SHOUT_AI_SAMPLERATE => 44100);
 
 # try to connect
 if ($conn->open) {
     print "connected...\n";
-    $conn->setMetadata("song" => "Streaming from standard in");
+    $conn->set_metadata("song" => "Streaming from standard in");
 
     # if we connect, grab data from stdin and shoot it to the server
     my ($buff, $len);
     while (($len = sysread(STDIN, $buff, 4096)) > 0) {
-	unless ($conn->send_data($buff)) {
+	unless ($conn->send($buff)) {
             print "Error while sending: " . $conn->get_error . "\n";
             last;
         }
@@ -38,5 +39,3 @@ if ($conn->open) {
 } else {
     print "couldn't connect...\n";
 }
-
-

<p><p>1.2       +11 -6     shout-perl/example2.pl

Index: example2.pl
===================================================================
RCS file: /usr/local/cvsroot/shout-perl/example2.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -u -r1.1 -r1.2
--- example2.pl	3 Jul 2003 16:42:05 -0000	1.1
+++ example2.pl	5 Jul 2003 18:42:03 -0000	1.2
@@ -10,15 +10,18 @@ use Shout; 
 use vars qw{$Debug $Lame};
 chomp( $Lame = `which lame` );
 my $Bitrate=64;
+my $Samplerate = 22050;
 ### Create a new streaming object
 my $streamer = new Shout
-	host			=> "localhost",
+	host		=> "localhost",
         port		=> 8000,
-	mount		=> "/test2",
-	password	=> "icenc",
-	format => SHOUT_FORMAT_MP3;
-	protocol => SHOUT_PROTOCOL_HTTP;
+	mount		=> "/example2",
+	password	=> "hackme",
+	format          => SHOUT_FORMAT_MP3,
+	protocol        => SHOUT_PROTOCOL_HTTP;
 
+$streamer->set_audio_info(SHOUT_AI_BITRATE => $Bitrate,
+  SHOUT_AI_SAMPLERATE => 22050);
 
 ###############################################################################
 ###	M A I N   P R O G R A M
@@ -40,13 +43,15 @@ for my $file ( @ARGV ) {
         print STDERR "Can't read '$file': $!" unless -r $file;
         print "Sending $file...\n";
 
+        $streamer->set_metadata(song => "Now Playing: $file");
+
         ### Run lame in downsampling mode on the file we're going to send
         open( LAME, "-|" ) || exec $Lame, qw{--mp3input -b}, $Bitrate, qw{-m j -f -S}, $file, "-";
 
         my $buff;
         READ: while ((my $len = sysread(LAME, $buff, 4096)) > 0) {
                 print STDERR "Read $len bytes...\n" if $Debug;
-		$streamer->send_data( $buff ) && next;
+		$streamer->send( $buff ) && next;
 
                 warn( "send failed: ", $streamer->get_error, "\n" );
                 last READ;

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list