Changeset 53d7625 for gutenbach/debian
- Timestamp:
- Oct 24, 2003, 4:31:42 PM (21 years ago)
- Branches:
- master, debian, mac, no-cups, nodebathena, web
- Children:
- ab55f2e
- Parents:
- 6761cd4
- git-author:
- jtwang <jtwang> (10/24/03 16:31:42)
- git-committer:
- jtwang <jtwang> (10/24/03 16:31:42)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gutenbach/debian/lib/sipbmp3-filter
r6761cd4 r53d7625 2 2 # Play the data on STDIN as an audio file 3 3 # 4 # $Id: sipbmp3-filter,v 1.1 0 2003-10-22 20:36:08 jhawkExp $4 # $Id: sipbmp3-filter,v 1.11 2003-10-24 20:31:42 jtwang Exp $ 5 5 # $Source: /tmp/tmp.UFBNno9997/RCS/sipbmp3-filter,v $ 6 6 # … … 43 43 # -P logname 44 44 # -Q queuename (lpr -Q) 45 # -Z random user-specified options 45 46 # -a printcap af (accounting file name) 46 47 # -d printcap sd entry (spool dir) … … 122 123 # 123 124 # Where <URI> is a valid URI for the stream, and <format> is a 124 # recognized format name (currently 'MP3' or 'OGG' ). <user:pass>125 # is an optional user and password pair for HTTP Basic Auth.125 # recognized format name (currently 'MP3' or 'OGG' or 'SHOUTCAST'). 126 # <user:pass> is an optional user and password pair for HTTP Basic Auth. 126 127 my $format, $uri, $userpass; 127 128 … … 152 153 print ZEPHYR "Couldn't fork: $!\n"; 153 154 close(ZEPHYR); 154 return;155 die; 155 156 } 156 157 … … 165 166 elsif ($contenttype eq "application/x-ogg") { $format="OGG" } 166 167 elsif ($contenttype eq "application/ogg") { $format="OGG" } 168 elsif ($contenttype eq "audio/x-scpls") { $format="SHOUTCAST" } 167 169 else { 168 170 print ZEPHYR … … 194 196 if (($format eq "MP3") || 195 197 ($format eq "mp3")) { 196 print ZEPHYR " PlayingMP3 audio stream...\n";198 print ZEPHYR "MP3 audio stream...\n"; 197 199 close(ZEPHYR); 198 200 &play_mpeg_stream($uri, $userpass); 199 } elsif (($format eq "OGG") || 201 } 202 elsif ($format eq "SHOUTCAST") { 203 print ZEPHYR "Shoutcast playlist...\n"; 204 #Don't close ZEPHYR yet, will print the name of the stream if available 205 $uri = &get_shoutcast($uri); 206 close(ZEPHYR); 207 &play_mpeg_stream($uri, undef); 208 } 209 elsif (($format eq "OGG") || 200 210 ($format eq "ogg")) { 201 print ZEPHYR " Playing OggVorbis audiostream...\n";211 print ZEPHYR "OggVorbis stream...\n"; 202 212 close(ZEPHYR); 203 213 &play_ogg_stream($uri, $userpass); … … 208 218 } 209 219 220 # Process a Shoutcast playlist 221 # get_shoutcast(URI) 222 sub get_shoutcast { 223 my $uri = shift(@_); 224 225 # grab the shoutcast .pls file 226 my $pid = open(W3M, "-|"); 227 unless (defined $pid) { 228 print ZEPHYR "Couldn't fork: $!\n"; 229 close(ZEPHYR); 230 die; 231 } 232 if (!$pid) { # child 233 exec("/mit/sipb/bin/w3m","-dump_source",$uri) || die "Couldn't fork"; 234 } 235 while (<W3M>) { 236 if (/^File\d+=(\S+)/) { 237 push(@uris, $1); 238 } 239 if (/^Title\d+=(.+)$/) { 240 push(@titles, $1); 241 } 242 } 243 close(W3M); 244 245 # choose a random server 246 $server = int(rand scalar(@uris)); 247 # print the name of the stream if available 248 print ZEPHYR "$titles[$server]\n"; 249 return $uris[$server]; 250 } 210 251 211 252 # Play an MPEG audio stream … … 255 296 # redirect STDERR to STDOUT 256 297 open STDERR, '>&STDOUT'; 257 exec("/mit/infoagents/bin/mpg123", "-b16384", "-q", $up, $uri) || 298 299 # disabling the buffer seems to improve streaming performances 300 # (files don't get cut in the middle) - perhaps mpg123 fails to 301 # wait for OS TCP buffer to be filled. -- jtwang 22 Oct 2003 302 #exec("/mit/infoagents/bin/mpg123", "-b16384", "-q", $up, $uri || 303 # die "Couldn't exec"; 304 exec("/mit/infoagents/bin/mpg123", "-q", $up, $uri) || 258 305 die "Couldn't exec"; 259 306 }
Note: See TracChangeset
for help on using the changeset viewer.