[xiph-commits] r7653 - in icecast/tags/ices0: . ices-0_4
ices-0_4/doc ices-0_4/src
brendan at motherfish-iii.xiph.org
brendan at motherfish-iii.xiph.org
Sat Aug 28 11:55:23 PDT 2004
Author: brendan
Date: 2004-08-28 11:55:23 -0700 (Sat, 28 Aug 2004)
New Revision: 7653
Added:
icecast/tags/ices0/ices-0_4/
icecast/tags/ices0/ices-0_4/BUGS
icecast/tags/ices0/ices-0_4/NEWS
icecast/tags/ices0/ices-0_4/README
icecast/tags/ices0/ices-0_4/TODO
icecast/tags/ices0/ices-0_4/configure.ac
icecast/tags/ices0/ices-0_4/doc/ices.1.in
icecast/tags/ices0/ices-0_4/doc/icesmanual.html
icecast/tags/ices0/ices-0_4/src/
icecast/tags/ices0/ices-0_4/src/Makefile.am
icecast/tags/ices0/ices-0_4/src/crossfade.c
icecast/tags/ices0/ices-0_4/src/cue.c
icecast/tags/ices0/ices-0_4/src/cue.h
icecast/tags/ices0/ices-0_4/src/definitions.h
icecast/tags/ices0/ices-0_4/src/ices.c
icecast/tags/ices0/ices-0_4/src/ices_config.h
icecast/tags/ices0/ices-0_4/src/icestypes.h
icecast/tags/ices0/ices-0_4/src/id3.c
icecast/tags/ices0/ices-0_4/src/id3.h
icecast/tags/ices0/ices-0_4/src/in_flac.c
icecast/tags/ices0/ices-0_4/src/in_flac.h
icecast/tags/ices0/ices-0_4/src/in_mp4.c
icecast/tags/ices0/ices-0_4/src/in_mp4.h
icecast/tags/ices0/ices-0_4/src/in_vorbis.c
icecast/tags/ices0/ices-0_4/src/in_vorbis.h
icecast/tags/ices0/ices-0_4/src/log.c
icecast/tags/ices0/ices-0_4/src/log.h
icecast/tags/ices0/ices-0_4/src/metadata.c
icecast/tags/ices0/ices-0_4/src/metadata.h
icecast/tags/ices0/ices-0_4/src/mp3.c
icecast/tags/ices0/ices-0_4/src/mp3.h
icecast/tags/ices0/ices-0_4/src/playlist/
icecast/tags/ices0/ices-0_4/src/reencode.h
icecast/tags/ices0/ices-0_4/src/setup.c
icecast/tags/ices0/ices-0_4/src/setup.h
icecast/tags/ices0/ices-0_4/src/signals.c
icecast/tags/ices0/ices-0_4/src/signals.h
icecast/tags/ices0/ices-0_4/src/stream.c
icecast/tags/ices0/ices-0_4/src/stream.h
icecast/tags/ices0/ices-0_4/src/util.c
icecast/tags/ices0/ices-0_4/src/util.h
Removed:
icecast/tags/ices0/ices-0_4/BUGS
icecast/tags/ices0/ices-0_4/NEWS
icecast/tags/ices0/ices-0_4/README
icecast/tags/ices0/ices-0_4/TODO
icecast/tags/ices0/ices-0_4/configure.ac
icecast/tags/ices0/ices-0_4/doc/ices.1.in
icecast/tags/ices0/ices-0_4/doc/icesmanual.html
icecast/tags/ices0/ices-0_4/src/
icecast/tags/ices0/ices-0_4/src/Makefile.am
icecast/tags/ices0/ices-0_4/src/crossfade.c
icecast/tags/ices0/ices-0_4/src/cue.c
icecast/tags/ices0/ices-0_4/src/cue.h
icecast/tags/ices0/ices-0_4/src/definitions.h
icecast/tags/ices0/ices-0_4/src/ices.c
icecast/tags/ices0/ices-0_4/src/ices_config.h
icecast/tags/ices0/ices-0_4/src/icestypes.h
icecast/tags/ices0/ices-0_4/src/id3.c
icecast/tags/ices0/ices-0_4/src/id3.h
icecast/tags/ices0/ices-0_4/src/in_vorbis.c
icecast/tags/ices0/ices-0_4/src/in_vorbis.h
icecast/tags/ices0/ices-0_4/src/log.c
icecast/tags/ices0/ices-0_4/src/log.h
icecast/tags/ices0/ices-0_4/src/metadata.c
icecast/tags/ices0/ices-0_4/src/metadata.h
icecast/tags/ices0/ices-0_4/src/mp3.c
icecast/tags/ices0/ices-0_4/src/mp3.h
icecast/tags/ices0/ices-0_4/src/playlist/
icecast/tags/ices0/ices-0_4/src/reencode.h
icecast/tags/ices0/ices-0_4/src/setup.c
icecast/tags/ices0/ices-0_4/src/setup.h
icecast/tags/ices0/ices-0_4/src/signals.c
icecast/tags/ices0/ices-0_4/src/signals.h
icecast/tags/ices0/ices-0_4/src/stream.c
icecast/tags/ices0/ices-0_4/src/stream.h
icecast/tags/ices0/ices-0_4/src/util.c
icecast/tags/ices0/ices-0_4/src/util.h
Log:
Tag ices 0.4
Copied: icecast/tags/ices0/ices-0_4 (from rev 7407, icecast/trunk/ices0)
Deleted: icecast/tags/ices0/ices-0_4/BUGS
===================================================================
--- icecast/trunk/ices0/BUGS 2004-07-28 22:50:47 UTC (rev 7407)
+++ icecast/tags/ices0/ices-0_4/BUGS 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,4 +0,0 @@
-* Handles error conditions poorly.
-* Crossfader mishandles sample rate change. Maybe I need a resampler?
-
-$Id$
Copied: icecast/tags/ices0/ices-0_4/BUGS (from rev 7455, icecast/trunk/ices0/BUGS)
Deleted: icecast/tags/ices0/ices-0_4/NEWS
===================================================================
--- icecast/trunk/ices0/NEWS 2004-07-28 22:50:47 UTC (rev 7407)
+++ icecast/tags/ices0/ices-0_4/NEWS 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,91 +0,0 @@
- * Crossfader added.
- * Tested with LAME 3.96.1
-0.3 2003-07-13
- * Updated to libshout2, which brings icecast2 compatibility.
- * ices will now attempt to trim junk and short frames from MP3 files,
- which should help if you've been hearing chirps between songs.
- * Reencoding is much more reliable - VBR, sampling rate changes, and
- a wide variety of bitrates have been tested.
- * Stability stability stability.
- * Ogg reencoding works on bigendian (eg PowerPC) systems now.
- * Mono reencoding bug fixed.
- * ID3v2 tag support.
- * A blank line in a playlist will terminate ices.
- * -i (icy_compat) has been removed in favor of -t 'protocol'
-0.2.3 2002-05-01
- As always, the longer the time between releases, the less changed:
- * ices no longer uses threads, making it much leaner and more portable.
- * bundled with libshout 1.0.9, which makes it much less likely to
- segfault on normal MP3 files.
- * Will now attempt to reload playlist modules when sighup'd. Make your
- scripting changes without interrupting your stream.
- * Still includes a number of bugs (see BUGS)
-0.2.2 2001-08-01
- * You can now specify the host and port for each mount point
- separately. In fact, you have to.
- * MP3 encoding output buffer size increased, seems to handle VBRs
- better, don't know why this is necessary at the moment.
- * Thread stack size increased again.
- * Write to stdout directly for usage/-V info, so it doesn't get
- swallowed if ices is configured to run in the background.
- * Include system configuration info in ices -V output.
- * Use setsid() to detach from tty, not setpgid().
- * Load perl module as a proper module. This means you'd better return
- 1 at the end of your module.
- * Set PYTHONPATH reliably (not using an automatic variable), and
- removed the arbitrary length limit.
- * Log file no longer appends PID. In general I think this is a silly
- practice. I would have removed it from the cue file too, but a)
- I don't use the cue file, and b) it at least cleans up after itself
- on exit.
- * Build dependency bugs fixed.
-0.2.1 2001-07-12
- * Thread stack size increased, to prevent segfaults during metadata
- updates on Solaris, FreeBSD, OpenBSD, and probably anything that
- isn't Linux.
- * Sleep code fixed to work better on other platforms. Solaris users
- should be happy.
- * All playlist functions but ices_get_next made optional.
- * Compatibility code uses old ices_(perl|python)_... function names
- if new, documented (man 1 ices) functions aren't found.
-0.2 2001-06-29
- * This is a development release. It is not guaranteed to be as stable
- as 0.1.
- * Multiple streams are supported. Add multiple stream sections to
- ices.conf or use multiple -m options on the command line. See the
- man page for details.
- * Oh yeah, there's a man page.
- * ices can decode ogg vorbis files and reencode them as MP3
- * New ices_get_metadata function added for playlist scripts.
- * Better recovery from transient network problems.
- * SIGUSR1 causes ices to jump to the next track
-0.1.0 2001-06-15
- * Reencoder updated to new LAME API of 3.88.
- * new option --with-xmlconfig when building to locate xml libraries
- * configure looks for python 2
- * new commandline option -V for version/feature info
- * cue file song length field now correct
- * BaseDirectory configuration option works
- * support for using an installed libshout
- * fixes to metadata update (first song metadata now set)
-0.0.1b5 2000-08-29
- * Perl module now supports dynamic loading of modules (e.g "use Socket")
- * Ices now exits after 10 consecutive filename or other errors. (Removes spamming problems)
-0.0.1b4 2000-08-24
- * New options to change sample rate and number of channels
- when reencoding.
-0.0.1b3 2000-08-08
- * Reencoding fixes, commented config file and README.playlist
- * Changed perl module to use user specified module
- * ices.py and ices.pm now commented
- * Configure.in now checks for gmake, and tells user to use this
- if found.
- * ices.pm,ices.py and README.playlist included in dist.
- * Moved README to README.old and lynx -dump -nolist on
- doc/icesmanual.html to the new README. (I don't want to
- maintain two sets of documentation)
- * Started to work on the FAQ
-0.0.1b2 2000-08-02
- * Code cleanup, lots of code comments added
-0.0.1b1 2000-07-19
- * first release
Copied: icecast/tags/ices0/ices-0_4/NEWS (from rev 7652, icecast/trunk/ices0/NEWS)
Deleted: icecast/tags/ices0/ices-0_4/README
===================================================================
--- icecast/trunk/ices0/README 2004-07-28 22:50:47 UTC (rev 7407)
+++ icecast/tags/ices0/ices-0_4/README 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,311 +0,0 @@
-
- Ices Manual
- __________
-
- A. Introduction
- B. What's it for?
- C. What can it do?
- 1. Cue file
- 2. Signal Handling
- 3. Playlist Handling
- 4. Reencoding
- D. Configuring
- 1. Command line options
- 2. Configuration file (ices.conf)
- E. Licensing
- F. Developers resources
- _______
-
- A. Introduction
- For a very long time, the only good streaming tool for command
- line systems was shout. Shout had a lot of issues, it was a quick
- and dirty hack, it was buggy, it was sending data too fast or too
- slow, and it was just something no one wanted to fix. So we
- rewrote it from scratch, and the next generation streamer, 'ices',
- is here. 'ices' is short for 'icesource', a source for the icecast
- server. 'ices' should be pronounced 'isis' like the egyptian
- godess of fertility. For more information about icecast, I suggest
- you check out the icecast webpage at http://www.icecast.org/.
- B. What's it for?
- ices, armed with a list of mp3 files, sends a continuous stream of
- mp3 data to an icecast server. The server is then responsible for
- accepting client connections and feeding the mp3 stream to them.
- But the stream originates in the streamer, 'ices'. The terms
- 'encoder', 'streamer' and 'source' are used equivalently
- throughout this document, and throughout all the documentation in
- the streaming system.
- C. What can it do?
- 1. Cue file
- The cue file holds information on the file that ices is
- currently feeding to the server. This is neat for you people
- out there who like running scripts. I myself, use the cue
- file in a tcl script, running from a eggdrop bot, on irc.
- That way I can ask the bot what song is currently playing,
- how long it is, how much of it has been played, and get
- information about the next songs on the playlist.
- The file currently has the following lines, (in this order).
- o filename
- o size (in bytes)
- o bitrate (in kbits/s)
- o minutes:seconds (total song length)
- o percent played (i.e 25, no %-sign)
- o playlist line index (i.e 3, if we're playing the 4:th
- line in the internal playlist. Logical, huh? ) Also, for
- you scripting people, when ices starts, it writes its
- process id to the file ices.pid.
- o ID3 Artist
- o ID3 Title
- 2. Signal handling
- o Sending SIGINT to ices will make it exit.
- o Sending SIGHUP to ices will make it close and reopen the
- logfile.
- 3. Reencoding
- If compiled with support for reencoding using libmp3lame, and
- you supply the -R command line option or set the
- Execution/Reencode to 1 in the XML config file, then ices
- will start reencoding your files on the fly to the bitrate
- you specified with the -b option or the Stream/Bitrate tag.
- The sample rate, number of channels, etc, will be chosen on
- the fly by lame itself, unless you specify something using
- the -H and -N options.
- If you want to change it, I suggest you add support for this
- to ices and mail me a patch.
- I think you should be fine with whatever lame chooses though.
- Also, please make sure that your files are ok before you
- start reencoding them with ices. This is because the mpglib
- part of lame (what does the decoding) is rather unstable and
- will call exit(0) when errors are encountered.
- This will make ices exit, which is kinda bad :)
- You'll need at least lame 3.88beta, and current CVS is a bit
- better.
- 4. Playlist handling
- About 96% of all emails I got about shout was people asking
- me to add small changes to shout playlist handling to suit
- their specific needs. This is course is not how I want to
- spend my life :) Shout had a feature to call an external
- program with a system() call, before each song, and that
- could possibly modify the playlist. This was rather ugly, but
- did the trick. In ices, we take this a step further an
- include scripting support inside the program. You can write
- your own playlist handler in perl or python, whatever you
- prefer. Your script module has to define 5 functions; test,
- init, shutdown, get_next, and get_current_lineno. I suggest
- you take a look in the distributed module files and just
- expand on that.
- D. Configuring
- ices can do everything shout could do, and more. It can be
- configured through hard coded defaults, a configfile, and command
- line options. The configfile is in XML, but don't get scared and
- run off. Just edit the distributed configfile and change the
- values you need. The command line options should be familiar to
- old shout users, although some options have been renamed.
- 1. Command line options
- Options:
- o -B (Background (daemon mode))
- o -b <stream bitrate>
- o -c <configfile>
- o -D <base directory>
- o -d <stream description>
- o -f <dumpfile on server>
- o -F <playlist>
- o -g <stream genre>
- o -h <host>
- o -i (use icy headers)
- o -M <interpreter module>
- o -m <mountpoint>
- o -n <stream name>
- o -p <port>
- o -P <password>
- o -r (randomize playlist)
- o -s (private stream)
- o -S <perl|python|builtin>
- o -u <stream url>
- o -N <Reencoded number of channels>
- o -H <Reencoded sample rate>
- 2. Configuration file (icec.conf)
- Here's a sample configuration file. It's the same as the
- ices.conf.dist that is included in the ices distribution.
-
- <?xml version="1.0"?>
- <ices:Configuration xmlns:ices="http://www.icecast.org/
-projects/ices">
- <ices:Playlist>
- <ices:File>apan.txt</ices:File>
- <ices:Randomize>1</ices:Randomize>
- <ices:Type>builtin</ices:Type>
- <ices:Module>ices</ices:Module>
- </ices:Playlist>
- <ices:Server>
- <ices:Hostname>localhost</ices:Hostname>
- <ices:Port>8000</ices:Port>
- <ices:Password>letmein</ices:Password>
- <ices:Protocol>xaudiocast</ices:Protocol>
- </ices:Server>
- <ices:Execution>
- <ices:Background>0</ices:Background>
- <ices:Verbose>1</ices:Verbose>
- <ices:BaseDirectory>/tmp</ices:BaseDirectory>
- <ices:Reencode>0</ices:Reencode>
- <ices:Samplerate>-1</ices:Samplerate>
- <ices:Channels>-1</ices:Channels>
- </ices:Execution>
- <ices:Stream>
- <ices:Name>Cool ices default name from XML</ice
-s:Name>
- <ices:Genre>Cool ices genre from XML</ices:Genr
-e>
- <ices:Description>Cool ices description from XM
-L</ices:Description>
- <ices:URL>Cool ices URL from XML</ices:URL>
- <ices:Bitrate>128</ices:Bitrate>
- <ices:Public>1</ices:Public>
- </ices:Stream>
- </ices:Configuration>
- 3. Configurations options
- This describes all the different options in ices.
- o Server Hostname
- Command line option: -h <host>
- Config file tag: Server/Hostname
- This is the name, or ip, of the host ices should connect
- to. It has to run a streaming server, capable of the
- xaudiocast or icy protocol.
- This value defaults to localhost.
- o Server Port
- Command line option: -p <port>
- Config file tag: Server/Port
- This is the port the server is listening on, by default
- 8000.
- o Server Password
- Command line option: -P <password>
- Config file tag: Server/Password
- The encoder password for the server. If this is not
- correct, then ices cannot log in on the server, and ices
- will exit.
- o Server Protocol
- Command line option: -i for icy-headers
- Config file tag: Server/Protocol
- Either xaudiocast or icy. Use xaudiocast if you can, and
- icy if you must.
- o Execution Background
- Command line option: -B
- Config file tag: Execution/Background
- This will launch ices in the background, as a daemon.
- o Execution Verbose
- Command line option: -v
- Config file tag: Execution/Verbose
- Normally ices outputs what stream is playing and a small
- amount of extra information. With verbose turned on, you
- get a whole lot of debugging information and lots of
- track info.
- o Execution Base Directory
- Command line option: -D <directory>
- Config file tag: Execution/BaseDirectory
- ices uses this directory for cue files, log files and
- temporary playlist files. You need write permissions in
- this directory. The default is /tmp
- o Execution Reencode
- Command line option: -R (turns reencoding on)
- Config file tag: Execution/Reencode
- When you turn this option on, ices (if compiled with
- libmp3lame support) will reencode your mp3 files on the
- fly to whatever bitrate you specify with the Stream
- Bitrate option.
- PLEASE note that if your files are corrupt, this might
- crash ices because the library used to decode (mpglib)
- is not very stable. I suggest you check your files with
- mp3check or some other mp3 verification program before
- you add them to your playlist. Just popping them into
- your favourite player and checking the sound is
- definately not enough.
- For legal reasons, this option is not available on the
- binary distributions.
- o Execution Samplerate
- Command line option: -H <samplerate>
- Config file tag: Execution/Samplerate
- Use this to force liblame reencoding to output mp3 data
- with this samplerate.
- o Execution Channels
- Command line option: -N <number of channels>
- Config file tag: Execution/Channels
- Use this to force liblame reencoding to output mp3 data
- with this many channels.
- o Stream Mountpoint
- Command line option: -m <mount point>
- Config file tag: Stream/Mountpoint
- This is the name of the mountpoint for this stream on the
- icecast server. Clients can access this stream at
- http://host:port/<mount point>.
- NOTE: This option does nothing if you are running in shoutcast
- compatibility mode.
- o Stream Name
- Command line option: -n <stream name>
- Config file tag: Stream/Name
- This is the name of the stream, not to be confused with
- the name of the song playing.
- o Stream Genre
- Command line option: -g <stream genre>
- Config file tag: Stream/Genre
- This is the genre of your stream, e.g Jazz or Static.
- o Stream Description
- Command line option: -d <stream description>
- Config file tag: Stream/Description
- This option is a description of your stream.
- o Stream URL
- Command line option: -u <URL>
- Config file tag: Stream/URL
- This should be a URL describing your stream.
- o Stream Bitrate
- Command line option: -b <bitrate>
- Config file tag: Stream/Bitrate
- If you turn on reencoding then this will be the bitrate
- of the stream, otherwize the actual bitrate of the
- stream is the bitrate your files are encoded at, and
- this value is for displaying purposes only.
- Read the last 3 lines again, please.
- o Stream Public
- Command line option: -s (makes stream private)
- Config file tag: Stream/Public
- This regulates whether the icecast server will display
- your stream on a directory server. Default is 1 (yes).
- o Playlist File
- Command line option: -F <file>
- Config file tag: Playlist/File
- This is the file where ices originally looks for files
- to play.
- When using playlist modules in perl or python, this
- argument is passed to the playlist handler.
- o Playlist Randomize
- Command line option: -r (randomizes file)
- Config file tag: Playlist/Randomize
- This option is passed to the playlist handler, and tells
- it to randomize the playlist.
- o Playlist Type
- Command line option: -S <perl|python|builtin>
- Config file tag: Playlist/Type
- By default, ices using a builtin playlist handler. It
- handles randomization and not much more. Most people
- want sophisticated playlist handlers that interface
- databases and keeps track of god knows what. ices
- handles embedded python and embedded perl, so now you
- can write your own modules, without modifying ices, that
- does just about anything. Use this option to change the
- playlist handler type from builtin (default), to python
- or perl.
- o Playlist Module
- Command line option: -M <module>
- Config file tag: Playlist/Module
- Use this option to execute a different python or perl
- module than the default.
- Default for python is ices.py and default for perl is
- ices.pm, although do NOT specify the file extension for
- the module. Use 'whatever' instead of 'whatever.pm' or
- 'whatever.py'
- E. Licensing
- ices is licensed under the Gnu General Public License, and for
- more info about that I suggest you read the file named COPYING.
- F. Developers resources
- If you want to write your own streaming software, or perhaps a
- nice streaming mp3 client, go to developer.icecast.org.
- _______
-
- This document is written by Alexander Haväng [eel at icecast.org].
Copied: icecast/tags/ices0/ices-0_4/README (from rev 7434, icecast/trunk/ices0/README)
Deleted: icecast/tags/ices0/ices-0_4/TODO
===================================================================
--- icecast/trunk/ices0/TODO 2004-07-28 22:50:47 UTC (rev 7407)
+++ icecast/tags/ices0/ices-0_4/TODO 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,4 +0,0 @@
-* Improved error handling
-* Make the scripting engines, and vorbis and MP3 reencoding, run-time linkable
-
-$Id: TODO,v 1.5 2003/03/19 18:58:24 brendan Exp $
Copied: icecast/tags/ices0/ices-0_4/TODO (from rev 7421, icecast/trunk/ices0/TODO)
Deleted: icecast/tags/ices0/ices-0_4/configure.ac
===================================================================
--- icecast/trunk/ices0/configure.ac 2004-07-28 22:50:47 UTC (rev 7407)
+++ icecast/tags/ices0/ices-0_4/configure.ac 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,314 +0,0 @@
-# configure script for ices
-# $Id$
-
-m4_define(ICES_MAJOR, 0)
-m4_define(ICES_MINOR, 3)
-m4_define(ICES_MICRO, 0pre4)
-m4_define(ICES_VERSION,
- m4_if(ICES_MICRO, 0, ICES_MAJOR.ICES_MINOR, ICES_MAJOR.ICES_MINOR.ICES_MICRO))
-
-AC_INIT([ices], ICES_VERSION, [icecast at xiph.org])
-AC_PREREQ(2.52)
-AC_CONFIG_SRCDIR([src/ices.c])
-
-AC_CONFIG_FILES([Makefile src/Makefile src/playlist/Makefile conf/Makefile
- conf/ices.conf.dist doc/Makefile])
-
-VERSION=ICES_VERSION
-
-dnl -- Finally, actual autoconf stuff --
-
-AC_ARG_PROGRAM
-
-dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_INSTALL
-AC_PROG_MAKE_SET
-
-if test "$GCC" = yes
-then
- CFLAGS="$CFLAGS -Wall"
-fi
-
-dnl -- System check --
-
-AC_CANONICAL_HOST
-AC_AIX
-AC_ISC_POSIX
-AC_MINIX
-
-case $host in
- *hpux*)
- CFLAGS="$CFLAGS -D_HPUX_SOURCE -DHPUX"
- if test "$CC" = cc
- then
- CFLAGS="$CFLAGS -Aa"
- fi
- ;;
-esac
-
-dnl -- Compiler feature check --
-
-AC_C_CONST
-AC_C_BIGENDIAN
-
-dnl -- System header check --
-
-AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([errno.h fcntl.h signal.h sys/signal.h sys/socket.h \
- sys/stat.h sys/time.h sys/types.h unistd.h])
-AC_HEADER_TIME
-
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-AC_TYPE_SIGNAL
-
-dnl -- System function check --
-
-AC_FUNC_STRFTIME
-AC_CHECK_FUNCS([vsnprintf setsid setlinebuf])
-
-dnl -- Build system init --
-
-AM_INIT_AUTOMAKE([1.6 foreign])
-AM_MAINTAINER_MODE
-AM_CONFIG_HEADER(config.h)
-AC_PROG_LIBTOOL
-AC_SUBST(LIBTOOL_DEPS)
-
-AC_ARG_WITH(docdir,
- [[ --with-docdir=DIR put documentation in DIR [PREFIX/doc/ices]]],
- [ices_cv_docdir="$with_docdir"],
- [ices_cv_docdir='${prefix}/doc/ices'])
-
-docdir="$ices_cv_docdir"
-AC_SUBST(docdir)
-
-AC_ARG_WITH(moddir,
- [[ --with-moddir=DIR put playlist modules in DIR [SYSCONFDIR/modules]]],
- [ices_cv_moddir="$with_moddir"],
- [ices_cv_moddir='${sysconfdir}/modules'])
-
-moddir="$ices_cv_moddir"
-AC_SUBST(moddir)
-
-dnl -- Required extra libraries --
-
-XIPH_PATH_SHOUT(, [AC_MSG_ERROR([Could not find a usable libshout])])
-CFLAGS="$CFLAGS $SHOUT_CPPFLAGS $SHOUT_CFLAGS"
-LIBS="$LIBS $SHOUT_LIBS"
-
-dnl -- Optional features --
-AC_CACHE_SAVE
-
-AC_ARG_WITH(xml-config,
- [ --with-xml-config=PATH use xml-config in PATH to find libxml ])
-
-have_xml="no"
-if test "$with_xml_config" != "no"
-then
- if test -n "$with_xml_config" -a "$with_xml_config" != "yes"
- then
- XMLCONFIG="$with_xml_config"
- if ! test -x "$XMLCONFIG"
- then
- AC_MSG_ERROR([$with_xml_config cannot be run])
- fi
- else
- AC_CHECK_PROGS(XMLCONFIG, [xml2-config xml-config])
- fi
-
- if test -n "$XMLCONFIG"
- then
- AC_DEFINE(HAVE_LIBXML, 1, [Define if you have the GNOME XML library])
- LIBS="$LIBS `$XMLCONFIG --libs`"
- CPPFLAGS="$CPPFLAGS `$XMLCONFIG --cflags`"
- ICES_OBJECTS="$ICES_OBJECTS ices_config.o"
- have_xml="yes"
- else
- AC_MSG_RESULT([Compiling without libxml support - no configfiles])
- fi
-fi
-AM_CONDITIONAL(USE_XML, test "$have_xml" = "yes")
-
-AC_ARG_WITH([python],
- [[ --with-python[=PATH] include python scripting support]],
- [enable_python="$with_python"],
- [enable_python="yes"])
-
-have_python="no"
-if test "$enable_python" != "no"
-then
- XIPH_PATH_PYTHON([$enable_python])
- if test -n "$PYTHON_LIBS"
- then
- have_python="yes"
- CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
- LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS"
- LIBS="$LIBS $PYTHON_LIBS"
- PLAYLIST_OBJECTS="$PLAYLIST_OBJECTS pm_python.o"
- AC_DEFINE(HAVE_LIBPYTHON, 1, [Define if you have the python library])
- fi
-fi
-
-if test "$with_python" != "no" -a "$have_python" != "yes"
-then
- if test -n "$with_python"
- then
- AC_MSG_ERROR([Could not link to python])
- else
- AC_MSG_RESULT([Could not link to python, python scripting disabled])
- fi
-fi
-
-AC_ARG_WITH(perl,
- [[ --with-perl[=PATH] include perl scripting support]])
-
-have_perl="no"
-PERL=perl
-if test "$with_perl" != "no"
-then
- if test -n "$with_perl" -a "$with_perl" != "yes"
- then
- PERL="$with_perl"
- if ! test -x "$PERL"
- then
- AC_MSG_ERROR([Perl not found in the specified location])
- fi
- fi
-
- PERLCFLAGS=`$PERL -MExtUtils::Embed -e ccopts`
- PERLLIBS=`$PERL -MExtUtils::Embed -e ldopts`
-
- saved_CPPFLAGS="$CPPFLAGS"
- saved_LIBS="$LIBS"
- CPPFLAGS="$CPPFLAGS $PERLCFLAGS"
- LIBS="$LIBS $PERLLIBS"
-
- AC_CHECK_FUNCS(perl_construct)
- if test "$ac_cv_func_perl_construct" != "no"
- then
- have_perl="yes"
- PLAYLIST_OBJECTS="$PLAYLIST_OBJECTS pm_perl.o"
- AC_DEFINE(HAVE_LIBPERL, 1, [Define if you have perl libraries])
- else
- CPPFLAGS="$saved_CPPFLAGS"
- LIBS="$saved_LIBS"
- fi
-fi
-
-if test "$with_perl" != "no" -a "$have_perl" != "yes"
-then
- if test -n "$with_perl"
- then
- AC_MSG_ERROR([Could not link to perl])
- else
- AC_MSG_RESULT([Could not link to perl, perl scripting disabled])
- fi
-fi
-
-AC_ARG_WITH(lame,
- [[ --with-lame[=DIR] enable support for reencoding with lame [in DIR]]])
-
-have_LAME="no"
-if test "$with_lame" != "no"
-then
- if test -n "$with_lame" -a "$with_lame" != "yes"
- then
- CPPFLAGS="$CPPFLAGS -I$with_lame/include"
- LDFLAGS="$LDFLAGS -L$with_lame/lib"
- fi
-
- AC_CHECK_HEADER(lame/lame.h, [
- have_LAME="maybe",
- AC_DEFINE(HAVE_LAME_LAME_H, 1, [Use <lame/lame.h> instead of <lame.h>])
- ], [
- AC_CHECK_HEADER(lame.h, [
- have_LAME="maybe"])])
-
- if test "$have_LAME" != "no"
- then
- AC_CHECK_LIB(mp3lame, lame_encode_flush_nogap, [
- have_LAME="yes"
- LIBS="$LIBS -lmp3lame"
- LIBM="-lm"
- ICES_OBJECTS="$ICES_OBJECTS reencode.o"
- AC_DEFINE(HAVE_LIBLAME, 1, [Define if you have the LAME MP3 library])
-
- AC_CHECK_FUNCS([lame_decode_exit])
- ], [have_LAME="no"], -lm)
- fi
-fi
-
-if test "$with_lame" != "no" -a "$have_LAME" != "yes"
-then
- if test -n "$with_lame"
- then
- AC_MSG_ERROR([Could not find a valid LAME library installation])
- else
- AC_MSG_RESULT([Could not find a valid LAME library, reencoding disabled])
- fi
-fi
-
-AC_ARG_WITH(vorbis,
- [[ --with-vorbis[=DIR] support for vorbis using libvorbisfile [in DIR]]])
-
-if test "$have_LAME" != "yes"
-then
- if test -n "$with_vorbis" -a "$with_vorbis" != "no"
- then
- AC_MSG_ERROR([Vorbis cannot be enabled without LAME])
- elif test "$with_vorbis" != "no"
- then
- AC_MSG_RESULT([Vorbis is disabled because LAME is not enabled])
- with_vorbis="no"
- fi
-fi
-
-have_vorbis="no"
-if test "$with_vorbis" != "no"
-then
- if test -n "$with_vorbis" -a "$with_vorbis" != "yes"
- then
- CPPFLAGS="$CPPFLAGS -I$with_vorbis/include"
- LDFLAGS="$LDFLAGS -L$with_vorbis/lib"
- fi
-
- AC_CHECK_HEADER(vorbis/vorbisfile.h, have_vorbis="maybe")
- if test "$have_vorbis" != "no"
- then
- AC_CHECK_LIB(vorbisfile, ov_open, [
- LIBS="$LIBS -lvorbisfile -lvorbis -logg"
- AC_DEFINE(HAVE_LIBVORBISFILE, 1, [Define if you have libvorbisfile])
- ICES_OBJECTS="$ICES_OBJECTS in_vorbis.o"
- have_vorbis="yes"
- ],[have_vorbis="no"],-lvorbis -logg)
- fi
-fi
-
-if test "$with_vorbis" != "no" -a "$have_vorbis" != "yes"
-then
- if test -n "$with_vorbis"
- then
- AC_MSG_ERROR([Could not find libvorbisfile])
- else
- AC_MSG_RESULT([Could not find libvorbisfile, vorbis support disabled])
- fi
-fi
-
-dnl -- and finish up --
-
-LIBS="$LIBS $LIBM $LIBDL"
-AC_SUBST(ICES_OBJECTS)
-AC_SUBST(PLAYLIST_OBJECTS)
-
-AC_OUTPUT
-
-AC_MSG_RESULT([Compiling with: $CPPFLAGS $CFLAGS])
-AC_MSG_RESULT([Linking with: $LDFLAGS $LIBS])
-AC_MSG_RESULT([Features:])
-AC_MSG_RESULT([ XML : $have_xml])
-AC_MSG_RESULT([ Python : $have_python])
-AC_MSG_RESULT([ Perl : $have_perl])
-AC_MSG_RESULT([ LAME : $have_LAME])
-AC_MSG_RESULT([ Vorbis : $have_vorbis])
Copied: icecast/tags/ices0/ices-0_4/configure.ac (from rev 7652, icecast/trunk/ices0/configure.ac)
Deleted: icecast/tags/ices0/ices-0_4/doc/ices.1.in
===================================================================
--- icecast/trunk/ices0/doc/ices.1.in 2004-07-28 22:50:47 UTC (rev 7407)
+++ icecast/tags/ices0/ices-0_4/doc/ices.1.in 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,301 +0,0 @@
-.TH "ices" "1" "July 2004" "ices @VERSION@" "Icecast media streaming system"
-.SH NAME
-ices \- stream MP3 audio to an icecast server
-
-.SH SYNOPSIS
-.B ices
-.RB [\| \-BVv \|]
-.\" Configuration path
-.RB [\| \-c
-.IR configfile \|]
-.\" Playlist options
-.RB [\| \-D
-.IR basedir \|]
-.RB [\| \-S\ builtin
-.RB [\| \-F
-.IR playlist \|]
-.RB [\| \-r \|]\|]\||[\| \-S
-.BR python \|| perl
-.RB [\| \-M
-.IR module \|]\|]
-.RB [\| \-C
-.IR crossfadesecs \|]
-.\" Server options
-.RB [\|[\| \-m
-.IR mount \|]
-.RB [\| \-h
-.IR host \|]
-.RB [\| \-p
-.IR port \|]
-.RB [\| \-P
-.IR password \|]
-.RB [\| \-t
-.IR protocol \|]
-.\" Stream options
-.RB [\| \-n
-.IR name \|]
-.RB [\| \-g
-.IR genre \|]
-.RB [\| \-d
-.IR description \|]
-.RB [\| \-u
-.IR url \|]
-.RB [\| -s \|]
-.RB [\| \-b
-.IR bitrate \|]
-.RB [\| \-f
-.IR dumpfile \|]
-.RB [\|[\| -R \|]
-.RB [\| \-H
-.IR samplerate \|]
-.RB [\| \-N
-.IR channels \|]\|]\|]\ .\|.\|.
-
-.nh
-.SH DESCRIPTION
-ices is a small but powerful and flexible encoder for icecast
-servers. Its features include:
-.IP \(bu
-A scripting interface to its playlist engine, using either python or
-perl as you prefer, in addition to a builtin static file server.
-Fetch your tracks from a database or update a webpage at each track
-change in a simple and robust way.
-.IP \(bu
-ices can read source audio from a FIFO. Between this and the script
-interface, it should be fairly easy to handle as complicated a
-media-delivery system as you can think up.
-.IP \(bu
-On-the-fly reencoding of your source audio to a different bitrate,
-number of channels and/or sample rate. ices can also decode Ogg Vorbis
-files and reencode them on the fly as MP3, for the benefit of older
-listening software.
-.IP \(bu
-Crossfading between tracks. This is a new feature, and requires
-reencoding support.
-.IP \(bu
-Multiple streams from the same playlist. In conjunction with
-reencoding this gives you a very easy way to provide the same music
-for broadband and narrowband listeners at the same time.
-.IP \(bu
-A constantly-updated cue file containing up to the second information
-about which track is currently playing, how much has been played, and
-other details.
-
-.SH OPTIONS
-.SS "Execution options"
-.TP
-.B \-B
-Detach from the console and run in the background.
-.TP
-.BI \-c \ configfile
-Load configuration options from
-.IR configfile ,
-instead of the default. Command line options will override these.
-.TP
-.BI \-D \ basedir
-Write the log and cue file to
-.IR basedir .
-.TP
-.B \-V
-Show version information and compile-time options and exit.
-.TP
-.B \-v
-Run in verbose mode.
-
-.SS "Playlist options"
-.TP
-.BI \-S \ interpreter
-Chooses which playlist interpreter ices will use to find source audio
-files for streaming. May be one of
-.BR builtin , \ python ,\ or \ perl .
-The default is
-.BR builtin .
-.TP
-.BI \-F \ playlist
-If using the
-.B builtin
-playlist interpreter, this option specifies the location of the
-.I playlist
-file ices will read to find audio files. This file simply contains
-the paths to audio files, one per line.
-If not using the
-.B builtin
-interpreter, this options does nothing.
-.TP
-.B \-r
-Select songs from the playlist file in random order. If not using the
-.B builtin
-interpreter, this option does nothing.
-.TP
-.BI \-M \ module
-If using the
-.BR perl \ or \ python
-playlist modules, load the module named
-.I module
-instead of the default,
-.BR ices .
-Otherwise this option does nothing.
-.TP
-.BI \-C \ crossfadesecs
-Crossfade between tracks. The length of the fade is
-.I crossfade
-seconds. This option requires reencoding support.
-
-.SS "Stream options"
-.TP
-.BI \-m \ mount
-Create a stream on the icecast server accessible at the mountpoint
-.IR mount .
-Clients may access your stream at
-.RI http:// host : port / mount .
-This option may be specified more than once to create multiple streams
-out of the same playlist. All stream options following each mount
-option apply to that mount only.
-
-If this option is not specified, an implicit mount named
-.B ices
-is implied.
-.TP
-.BI \-h \ host
-Connect to the icecast server on
-.IR host ,
-instead of the default,
-.BR localhost .
-.TP
-.BI \-p \ port
-Connect to the icecast server on
-.IR port ,
-instead of the default,
-.BR 8000 .
-.TP
-.BI \-P \ password
-Log into the icecast server using the password
-.IR password .
-.TP
-.BI \-t \ protocol
-Connect to the server using the streaming protocol
-.IR protocol .
-Protocol should be one of
-.BR http , \ xaudiocast ,\ or \ icy ,
-depending on whether your server is icecast 2, icecast 1,
-or shoutcast compatible, respectively. The default is
-.BR http .
-(Shoutcast would be most compatible but, unfortunately, that
-protocol does not support multiple mount points).
-.TP
-.BI \-n \ name
-Set the name of this stream to
-.IR name .
-.TP
-.BI \-g \ genre
-Set the genre of this stream to
-.IR genre .
-.TP
-.BI \-d \ description
-Set the description of this stream to
-.IR description .
-.TP
-.BI \-u \ url
-Set the URL of this stream to
-.IR url .
-.TP
-.B \-s
-Do not mark this stream as public. This instructs the icecast server
-not to update directory servers with information about this stream.
-.TP
-.BI \-b \ bitrate
-Set the bitrate of this stream to
-.IR bitrate .
-Unless reencoding is also enabled on this stream, this option is only
-informational.
-.TP
-.BI \-f \ dumpfile
-Write the contents of the stream to a file named
-.I dumpfile
-on the server. Use this option with care.
-.TP
-.B \-R
-Reencode this stream at the bitrate specified with the
-.B \-b
-option.
-.TP
-.BI \-H \ samplerate
-If reencoding, set the output sample rate to
-.IR samplerate .
-.TP
-.BI \-N \ channels
-If reencoding, set the number of output channels to
-.IR channels .
-May be
-.B 1
-for mono output or
-.B 2
-for stereo output. At low bitrates setting this to
-.B 1
-is a good way to improve sound quality.
-
-.SH "PLAYLIST SCRIPTING"
-In addition to its simple builtin playlist handler, ices can
-optionally call out to either a python or perl module for track
-information. Your module may define the following functions:
-
-.TP
-.B ices_init
-This function is called once when ices starts up, giving your module a
-chance to initialize itself (make database connections etc.). If this
-function returns a negative result, ices will terminate.
-.TP
-.B ices_shutdown
-This function is called before ices quits, to give your module a
-chance to free any resources it may have allocated.
-.TP
-.B ices_get_next
-This function is called at each track change. Your module should
-return a string containing the path to the next audio file to be
-played.
-.TP
-.B ices_get_metadata
-This function is called after
-.BR ices_get_next .
-If it returns a string, ices will use it as the title to be streamed
-instead of trying to build one from the ID3 or vorbis comment tags, or
-the filename if neither of those are available.
-.TP
-.B ices_get_lineno
-This function is also called after ices_get_next. Your module may
-return a number which will be inserted in the cue file as the current
-line number in the playlist. It serves no other purpose.
-
-Your module must at least define the
-.B ices_get_next
-function. All others are optional.
-
-.SH "SIGNAL HANDLING"
-Ices handles the following signals specially:
-.TP
-.B SIGINT
-Causes ices to perform a clean shutdown.
-.TP
-.B SIGHUP
-Causes ices to close and reopen the log file and the playlist. It will also
-reload and restart the playlist script if you're using one.
-.TP
-.B SIGUSR1
-Causes ices to skip to the next track in the playlist immediately.
-
-.SH FILES
-.TP
-.I @sysconfdir@/ices.conf
-Default XML configuration file. May be overriden with
-.BR -c .
-.TP
-.I @moddir@/ices.py
-Default path to the python playlist module.
-.TP
-.I @moddir@/ices.pm
-Default path to the perl playlist module.
-
-.SH AUTHORS
-ices was originally written by Alexander Haväng <eel at icecast.org>.
-.P
-It is currently developed by Brendan Cully <brendan at icecast.org>.
Copied: icecast/tags/ices0/ices-0_4/doc/ices.1.in (from rev 7434, icecast/trunk/ices0/doc/ices.1.in)
Deleted: icecast/tags/ices0/ices-0_4/doc/icesmanual.html
===================================================================
--- icecast/trunk/ices0/doc/icesmanual.html 2004-07-28 22:50:47 UTC (rev 7407)
+++ icecast/tags/ices0/ices-0_4/doc/icesmanual.html 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,474 +0,0 @@
-<html>
-<head><title>How to configure and run ices, the icecast streamer</title>
-</head>
-
-<body>
-
-<h1>Ices Manual</h1>
-<p align="left">
-
-<ol type=A>
- <li> <a href="#section_introduction">Introduction</a></li>
- <li> <a href="#section_purpose">What's it for?</a></li>
- <li> <a href="#section_features">What can it do?</a>
- <ol type=1>
- <li> <a href="#features_cue">Cue file </a></li>
- <li> <a href="#features_signals">Signal Handling </a></li>
- <li> <a href="#features_reencoding">Reencoding</a></li>
- <li> <a href="#features_crossfading">Crossfading</a></li>
- <li> <a href="#features_multistream">Multiple streams</a></li>
- <li> <a href="#features_playlists">Playlist Handling </a></li>
- </ol>
- </li>
- <li> <a href="#section_configuring"> Configuring </a>
- <ol type=1>
- <li> <a href="#configure_commandlineoptions"> Command line options </a> </li>
- <li> <a href="#configure_configurationfile"> Configuration file (ices.conf) </a> </li>
- </ol>
- </li>
- <li> <a href="#section_licensing"> Licensing </a>
- <li> <a href="#section_developer"> Developers resources </a></li>
-</ol>
-</p>
-
-<hr width="10%">
-
-<p>
-<ol type=A>
- <li> <a name="section_introduction">Introduction</a>
- <p>
-For a very long time, the only good streaming tool for command line systems
-was shout. Shout had a lot of issues, it was a quick and dirty hack, it
-was buggy, it was sending data too fast or too slow, and it was just something
-no one wanted to fix.
-
-So we rewrote it from scratch, and the next generation streamer, 'ices', is
-here. 'ices' is short for 'icesource', a source for the icecast server.
-'ices' should be pronounced 'isis' like the egyptian godess of fertility.
-
-For more information about icecast, I suggest you check out the icecast
-webpage at http://www.icecast.org/.
- </p>
- </li>
-
- <li> <a name="section_purpose">What's it for?</a>
- <p>
-ices, armed with a list of mp3 files, sends a continuous stream of mp3 data
-to an icecast server. The server is then responsible for accepting client
-connections and feeding the mp3 stream to them.
-But the stream originates in the streamer, 'ices'.
-The terms 'encoder', 'streamer' and 'source' are used equivalently throughout
-this document, and throughout all the documentation in the streaming system.
- </p>
-
- </li>
-
- <li> <a name="section_features">What can it do?</a>
- <ol type=1>
- <li> <a name="features_cue">Cue file</a>
- <p>
-The cue file holds information on the file that ices is currently feeding
-to the server. This is neat for you people out there who like running scripts.
-I myself, use the cue file in a tcl script, running from a eggdrop bot, on irc.
-That way I can ask the bot what song is currently playing, how long it is, how
-much of it has been played, and get information about the next songs on the
-playlist.<br>
-The file currently has the following lines, (in this order).<br>
- <ul>
- <li>filename</li>
- <li>size (in bytes)</li>
- <li>bitrate (in kbits/s)</li>
- <li>minutes:seconds (total song length)</li>
- <li>percent played (i.e 25, no %-sign)</li>
- <li>playlist line index (i.e 3, if we're playing the 4:th line in the internal
- playlist. Logical, huh? ) Also, for you scripting people, when ices
- starts, it writes its process id to the file ices.pid.</li>
- <li>ID3 Artist</li>
- <li>ID3 Title</li>
- </ul>
- </p>
- </li>
-
- <li> <a name="features_signals">Signal handling</a>
- <p>
- <ul>
- <li>Sending SIGINT to ices will make it exit.</li>
- <li>Sending SIGHUP to ices will make it close and reopen the
- logfile and playlist, and reload and restart the playlist script if
- you are using one.</li>
- <li>Sending SIGUSR1 to ices will make it skip to the next track.</li>
- </ul>
- </p>
- </li>
-
- <li> <a name="features_reencoding">Reencoding </a>
- <p>
-If compiled with support for reencoding using liblame, and you supply
-the -R command line option or set the Stream/Reencode to 1 in the
-XML config file, then ices will start reencoding your files on the fly
-to the bitrate you specified with the -b option or the Stream/Bitrate
-tag.
-<br>
-If you are reencoding and ices was compiled with vorbis support, you
-may also reencode Ogg Vorbis files as MP3 on the fly. This gives you
-the opportunity to convert your source files to Ogg Vorbis at your
-convenience while still supporting as many listeners as possible.
-<br>
-The sample rate, number of channels, etc, will be chosen on the fly by
-lame itself, unless you specify something using the -H and -N options.
-I think you should be fine with whatever lame chooses though.
-<br>
-Also, please make sure that your files are ok before you start
-reencoding them with ices. This is because the mpglib part of lame
-(what does the decoding) is rather unstable and will call exit(0) when
-errors are encountered.
-<br>
-This will make ices exit, which is kinda bad :)
- </p>
- </li>
-
- <li> <a name="features_crossfading">Crossfading</a>
- <p>
-If you've compiled with support for reencoding, you can
-crossfade between tracks (blend the end of one into the start
-of the next). This is controlled by the <tt>-C</tt> command line
-option or the <tt>Playlist/Crossfade</tt> parameter in the
-configuration file. Both of these take an integer argument,
-which is the number of seconds to crossfade.
-Songs less than twice the length of the crossfade requested will not
-be faded. This is handy for eg station IDs. <b>NOTE</b>: The
-crossfader doesn't know how to resample, so if you activate this
-feature you should make sure that all your source tracks have the
-same sampling rate.
- </p>
- </li>
-
- <li> <a name="features_multistream">Multiple streams</a>
- <p>
-You can feed the same playlist simultaneously to different
-mountpoints, by specifying multiple <tt>Stream</tt> sections in the
-config file or passing multiple <tt>-m</tt>options on the command
-line. This is especially useful in conjunction with reencoding because
-you can stream the same music at a high bitrate for broadband
-listeners and simultaneously at a low bitrate for POTS listeners.
- </p>
-
- <li> <a name="features_playlists">Playlist handling</a>
- <p>
-About 96% of all emails I got about shout was people asking me to add small
-changes to shout playlist handling to suit their specific needs.
-This is course is not how I want to spend my life :)
-Shout had a feature to call an external program with a system() call, before
-each song, and that could possibly modify the playlist.
-This was rather ugly, but did the trick.
-In ices, we take this a step further and include scripting support inside the
-program. You can write your own playlist handler in perl or python, whatever
-you prefer.
-<br>
-Your script module has to define at least a function named
-<tt>ices_get_next</tt>, which should return a path to a file or FIFO
-containing MP3 data.
-<br>
-In addition you may define the functions <tt>ices_init</tt> and
-<tt>ices_shutdown</tt> which will be called by ices once before asking
-for the first song and before shutting down, respectively.
-<br>
-You may also define <tt>ices_get_lineno</tt>, which specifies the line
-number of the current track in the cue file. If you don't use the cue
-file it is safe to omit this function.
-<br>
-Finally you can define <tt>ices_get_metadata</tt> to return a string
-you want to use for title streaming. Ices will call this function once
-per track after calling <tt>ices_get_next</tt>. If this function is
-not defined or returns null, ices will use whatever it can get out of
-the file itself, either tags or the file name.
-<br>
-I suggest you take a look in the distributed module files and just expand on
-that.
- </p>
-
- </li>
-
- </ol>
- </li>
-
- <li> <a name="section_configuring">Configuring</a>
- <p>
-ices can do everything shout could do, and more.
-It can be configured through hard coded defaults, a configfile, and command
-line options.
-
-The configfile is in XML, but don't get scared and run off. Just edit the
-distributed configfile and change the values you need.
-
-The command line options should be familiar to old shout users, although
-some options have been renamed.
- </p>
- <ol type=1>
- <li> <a name="configure_commandlineoptions"> Command line options </a>
- <p>
- Options:
- <ul>
- <li>-B (Background (daemon mode))</li>
- <li>-b <stream bitrate></li>
- <li>-C <crossfade seconds></li>
- <li>-c <configfile></li>
- <li>-D <base directory></li>
- <li>-d <stream description></li>
- <li>-f <dumpfile on server></li>
- <li>-F <playlist></li>
- <li>-g <stream genre></li>
- <li>-h <host></li>
- <li>-i (use icy headers)</li>
- <li>-M <interpreter module></li>
- <li>-m <mountpoint></li>
- <li>-n <stream name></li>
- <li>-p <port></li>
- <li>-P <password></li>
- <li>-r (randomize playlist)</li>
- <li>-s (private stream)</li>
- <li>-S <perl|python|builtin></li>
- <li>-u <stream url></li>
- <li>-N <Reencoded number of channels></li>
- <li>-H <Reencoded sample rate></li>
- </ul>
- </p>
- </li>
-Note that each time you specify a mount point with <tt>-m</tt> you are
-creating a new stream, and subsequent stream options will apply only
-to it.
- <li> <a name="configure_configurationfile"> Configuration file (ices.conf) </a>
- <p>
-Here's a sample configuration file. It's the same as the
-ices.conf.dist that is included in the ices distribution.
-You can specify multiple stream sections with different mountpoints,
-names, and reencoding options.
- <pre>
-
- <?xml version="1.0"?>
- <ices:Configuration xmlns:ices="http://www.icecast.org/projects/ices">
- <Playlist>
- <File>apan.txt</File>
- <Randomize>1</Randomize>
- <Type>builtin</Type>
- <Module>ices</Module>
- <Crossfade>0;<Crossfade>
- </Playlist>
- <Server>
- <Hostname>localhost</Hostname>
- <Port>8000</Port>
- <Password>letmein</Password>
- <Protocol>xaudiocast</Protocol>
- </Server>
- <Execution>
- <Background>0</Background>
- <Verbose>1</Verbose>
- <Base_Directory>/tmp</Base_Directory>
- </Execution>
- <Stream>
- <Name>Cool ices default name from XML</Name>
- <Genre>Cool ices genre from XML</Genre>
- <Description>Cool ices description from XML</Description>
- <URL>Cool ices URL from XML</URL>
- <Bitrate>128</Bitrate>
- <Public>1</Public>
- <Reencode>0</Reencode>
- <Samplerate>-1</Samplerate>
- <Channels>-1</Channels>
- </Stream>
- </ices:Configuration>
- </pre>
- </p>
- </li>
- <li> <a name="configure_options">Configurations options </a>
- <p>
- This describes all the different options in ices.
- <ul>
- <li> Server Hostname<br>
- Command line option: -h <host><br>
- Config file tag: Server/Hostname<br>
- This is the name, or ip, of the host ices should connect to.
- It has to run a streaming server, capable of the xaudiocast
- or icy protocol.<br>
- This value defaults to localhost.
- </li>
-
- <li> Server Port<br>
- Command line option: -p <port><br>
- Config file tag: Server/Port<br>
- This is the port the server is listening on, by default 8000.
- </li>
-
- <li> Server Password <br>
- Command line option: -P <password> <br>
- Config file tag: Server/Password <br>
- The encoder password for the server. If this is not correct,
- then ices cannot log in on the server, and ices will exit.
- </li>
-
- <li> Server Protocol <br>
- Command line option: -i for icy-headers <br>
- Config file tag: Server/Protocol <br>
- Either xaudiocast or icy. Use xaudiocast if you can, and icy if you must.
- </li>
-
- <li> Execution Background <br>
- Command line option: -B <br>
- Config file tag: Execution/Background <br>
- This will launch ices in the background, as a daemon.
- </li>
-
- <li> Execution Verbose <br>
- Command line option: -v <br>
- Config file tag: Execution/Verbose <br>
- Normally ices outputs what stream is playing and a small amount of extra information.
- With verbose turned on, you get a whole lot of debugging information and lots of track info.
- </li>
-
- <li> Execution Base Directory <br>
- Command line option: -D <directory> <br>
- Config file tag: Execution/Base_directory <br>
- ices uses this directory for cue files, log files and temporary playlist files.
- You need write permissions in this directory. The default is /tmp
- </li>
-
- <li> Stream Mountpoint <br>
-Command line option: -m <mountpoint><br>
-Config file tag: Stream/Mountpoint<br>
-This is the mountpoint of the stream on the icecast server, if using
-the x-audiocast protocol.
- <li> Stream Name <br>
- Command line option: -n <stream name> <br>
- Config file tag: Stream/Name<br>
- This is the name of the stream, not to be confused with the name of the song playing.<br>
- </li>
-
- <li> Stream Genre <br>
- Command line option: -g <stream genre> <br>
- Config file tag: Stream/Genre <br>
- This is the genre of your stream, e.g Jazz or Static.
- </li>
-
- <li> Stream Description <br>
- Command line option: -d <stream description> <br>
- Config file tag: Stream/Description <br>
- This option is a description of your stream.
- </li>
-
- <li> Stream URL <br>
- Command line option: -u <URL> <br>
- Config file tag: Stream/URL <br>
- This should be a URL describing your stream.
- </li>
-
- <li> Stream Bitrate <br>
- Command line option: -b <bitrate> <br>
- Config file tag: Stream/Bitrate <br>
- If you turn on reencoding then this will be the bitrate of the stream,
- otherwize the actual bitrate of the stream is the bitrate your files
- are encoded at, and this value is for displaying purposes only.<br>
- Read the last 3 lines again, please.
- </li>
-
- <li> Stream Public <br>
- Command line option: -s (makes stream private) <br>
- Config file tag: Stream/Public <br>
- This regulates whether the icecast server will display your stream on a directory server. Default is 1 (yes). <br>
- </li>
-
- <li> Stream Reencode <br>
- Command line option: -R (turns reencoding on) <br>
- Config file tag: Stream/Reencode <br>
- When you turn this option on, ices (if compiled with libmp3lame support) will reencode your mp3 files
- on the fly to whatever bitrate you specify
- with the Stream Bitrate option, unless
- the file bitrate is the same as the
- stream bitrate.<br>
- PLEASE note that if your files are corrupt, this might crash ices because the library used to decode (mpglib) is not very stable.
- I suggest you check your files with mp3check or some other mp3 verification program before you add them to your playlist.
- Just popping them into your favourite player and checking the sound is definitely not enough.<br>
- For legal reasons, this option is not available on the binary distributions.
- </li>
-
- <li> Stream Samplerate <br>
- Command line option: -H <samplerate> <br>
- Config file tag: Stream/Samplerate <br>
- Use this to force reencoding to output mp3 data with this samplerate.
- </li>
-
- <li> Stream Channels <br>
- Command line option: -N <number of channel> <br>
- Config file tag: Stream/Channels <br>
- Use this to force reencoding to output mp3 data with this many channels.
- </li>
-
- <li> Playlist File <br>
- Command line option: -F <file> <br>
- Config file tag: Playlist/File <br>
- This is the file where ices originally looks for files to play. <br>
- When using playlist modules in perl or python, this argument
- is ignored.
- </li>
-
- <li> Playlist Randomize <br>
- Command line option: -r (randomizes file) <br>
- Config file tag: Playlist/Randomize <br>
- This option is passed to the playlist handler, and tells it
- to randomize the playlist.
- </li>
-
- <li> Playlist Type <br>
- Command line option: -S <perl|python|builtin> <br>
- Config file tag: Playlist/Type <br>
- By default, ices using a builtin playlist handler. It handles randomization and not
- much more. Most people want
- sophisticated playlist handlers that
- interface with databases
- and keep track of god knows what. ices handles embedded python and embedded perl,
- so now you can write your own modules, without modifying ices, that do just about
- anything. Use this option to change the playlist handler type from builtin (default),
- to python or perl.
- </li>
-
- <li> Playlist Module <br>
- Command line option: -M <module> <br>
- Config file tag: Playlist/Module <br>
- Use this option to execute a different python or perl module than the default. <br>
- Default for python is ices.py and default for perl is ices.pm, although do NOT specify the file extension for the module. Use 'whatever' instead of 'whatever.pm' or 'whatever.py'<br>
- </li>
-
- <li>Crossfade<br/>
- Command line option: -C <seconds> <br/>
- Config file tag: Playlist/Crossfade<br>
-If this option is specified and reencoding is enabled, ices will
-crossfade <tt>seconds</tt> between tracks.
- </ul>
- </p>
- </ol>
- </li>
-
- <li> <a name="section_licensing"> Licensing </a>
- <p>
- ices is licensed under the Gnu General Public License, and for more info about that
- I suggest you read the file named COPYING.
- </p>
- </li>
-
- <li> <a name="section_developer">Developers resources</a>
- <p> If you want to write your own streaming software, or perhaps a nice streaming mp3 client, go to
- <a href="http://developer.icecast.org/">developer.icecast.org</a>.
- </p>
- </li>
-
-</ol>
-
-<hr width="10%">
-
-<p align=right> This document was mostly written by Alexander Haväng
- [eel at icecast.org].<br>
-
-</p>
-
-</body>
-</html>
-
Copied: icecast/tags/ices0/ices-0_4/doc/icesmanual.html (from rev 7455, icecast/trunk/ices0/doc/icesmanual.html)
Copied: icecast/tags/ices0/ices-0_4/src (from rev 7409, icecast/trunk/ices0/src)
Deleted: icecast/tags/ices0/ices-0_4/src/Makefile.am
===================================================================
--- icecast/trunk/ices0/src/Makefile.am 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/Makefile.am 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,19 +0,0 @@
-## Process this with automake to create Makefile.in
-
-SUBDIRS = playlist
-
-bin_PROGRAMS = ices
-
-noinst_HEADERS = icestypes.h definitions.h setup.h log.h stream.h util.h \
- cue.h metadata.h in_vorbis.h mp3.h id3.h signals.h reencode.h \
- ices_config.h
-
-ices_SOURCES = ices.c log.c setup.c stream.c util.c mp3.c cue.c metadata.c \
- id3.c signals.c crossfade.c
-
-EXTRA_ices_SOURCES = ices_config.c reencode.c in_vorbis.c
-
-ices_LDADD = $(ICES_OBJECTS) playlist/libplaylist.a
-ices_DEPENDENCIES = $(ices_LDADD)
-
-AM_CPPFLAGS = -DICES_ETCDIR=\"$(sysconfdir)\" -DICES_MODULEDIR=\"$(moddir)\"
Copied: icecast/tags/ices0/ices-0_4/src/Makefile.am (from rev 7428, icecast/trunk/ices0/src/Makefile.am)
Deleted: icecast/tags/ices0/ices-0_4/src/crossfade.c
===================================================================
--- icecast/trunk/ices0/src/crossfade.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/crossfade.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,169 +0,0 @@
-/* crossfade.c
- * Crossfader plugin
- * Copyright (c) 2004 Brendan Cully <brendan at xiph.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
-
-#include "definitions.h"
-
-static int cf_init(void);
-static void cf_new_track(input_stream_t *source);
-static int cf_process(int ilen, int16_t* il, int16_t* ir);
-static void cf_shutdown(void);
-
-static ices_plugin_t Crossfader = {
- "crossfade",
-
- cf_init,
- cf_new_track,
- cf_process,
- cf_shutdown,
-
- NULL
-};
-
-static int FadeSamples;
-static int16_t* FL = NULL;
-static int16_t* FR = NULL;
-static int16_t* Swap = NULL;
-static int fpos = 0;
-static int flen = 0;
-
-static int NewTrack = 0;
-
-/* public functions */
-ices_plugin_t *crossfade_plugin(int secs) {
- FadeSamples = secs * 44100;
-
- return &Crossfader;
-}
-
-/* private functions */
-static int cf_init(void) {
- if (!(FL = malloc(FadeSamples * 2)))
- goto err;
- if (!(FR = malloc(FadeSamples * 2)))
- goto err;
- if (!(Swap = malloc(FadeSamples * 2)))
- goto err;
-
- ices_log_debug("Crossfading %d seconds between tracks", FadeSamples / 44100);
- return 0;
-
- err:
- ices_log_error("Crossfader could not allocate memory");
- cf_shutdown();
- return -1;
-}
-
-static void cf_new_track(input_stream_t *source) {
- static int skipnext = 0;
- static input_stream_t lasttrack;
- int filesecs;
-
- if (lasttrack.samplerate && lasttrack.samplerate != source->samplerate)
- skipnext = 1;
-
- memcpy(&lasttrack, source, sizeof(lasttrack));
-
- /* turn off crossfading for tracks less than twice the length of the fade */
- if (skipnext) {
- skipnext = 0;
- return;
- }
-
- if (source->filesize && source->bitrate) {
- filesecs = source->filesize / (source->bitrate * 128);
- if (filesecs < 10 || filesecs <= FadeSamples * 2 / 44100) {
- ices_log_debug("crossfade: not fading short track of %d secs", filesecs);
- skipnext = 1;
- return;
- }
- }
-
- NewTrack = FadeSamples;
-}
-
-static int cf_process(int ilen, int16_t* il, int16_t* ir)
-{
- int i, j, clen;
- float weight;
-
- i = 0;
- /* if the buffer is not full, don't attempt to crossfade, just fill it */
- if (flen < FadeSamples)
- NewTrack = 0;
-
- while (ilen && NewTrack > 0) {
- weight = (float)NewTrack / FadeSamples;
- il[i] = FL[fpos] * weight + il[i] * (1 - weight);
- ir[i] = FR[fpos] * weight + ir[i] * (1 - weight);
- i++;
- fpos = (fpos + 1) % FadeSamples;
- ilen--;
- NewTrack--;
- if (!NewTrack)
- flen = 0;
- }
-
- j = i;
- while (ilen && flen < FadeSamples) {
- clen = ilen < (FadeSamples - flen) ? ilen : (FadeSamples - flen);
- if (FadeSamples - fpos < clen)
- clen = FadeSamples - fpos;
- memcpy(FL + fpos, il + j, clen * 2);
- memcpy(FR + fpos, ir + j, clen * 2);
- fpos = (fpos + clen) % FadeSamples;
- j += clen;
- flen += clen;
- ilen -= clen;
- }
-
- while (ilen) {
- clen = ilen < (FadeSamples - fpos) ? ilen : FadeSamples - fpos;
- memcpy(Swap, il + j, clen * 2);
- memcpy(il + i, FL + fpos, clen * 2);
- memcpy(FL + fpos, Swap, clen * 2);
- memcpy(Swap, ir + j, clen * 2);
- memcpy(ir + i, FR + fpos, clen * 2);
- memcpy(FR + fpos, Swap, clen * 2);
- fpos = (fpos + clen) % FadeSamples;
- i += clen;
- j += clen;
- ilen -= clen;
- }
-
- return i;
-}
-
-static void cf_shutdown(void) {
- if (FL) {
- free(FL);
- FL = NULL;
- }
- if (FR) {
- free(FR);
- FR = NULL;
- }
- if (Swap) {
- free(Swap);
- Swap = NULL;
- }
-
- ices_log_debug("Crossfader shutting down");
-}
Copied: icecast/tags/ices0/ices-0_4/src/crossfade.c (from rev 7455, icecast/trunk/ices0/src/crossfade.c)
Deleted: icecast/tags/ices0/ices-0_4/src/cue.c
===================================================================
--- icecast/trunk/ices0/src/cue.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/cue.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,113 +0,0 @@
-/* cue.c
- * - Functions for cue file in ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include "definitions.h"
-#include "metadata.h"
-
-extern ices_config_t ices_config;
-
-char *ices_cue_filename = NULL;
-static int ices_cue_lineno = 0;
-
-/* Syntax of cue file
- * filename
- * size
- * bitrate
- * minutes:seconds total
- * % played
- * current line in playlist
- * artist
- * songname
- */
-
-/* Global function definitions */
-
-/* Update the cue file with a set of variables */
-void
-ices_cue_update (input_stream_t* source)
-{
- char buf[1024];
- char artist[1024];
- char title[1024];
- FILE *fp = ices_util_fopen_for_writing (ices_cue_get_filename());
-
- if (!fp) {
- ices_log ("Could not open cuefile [%s] for writing, cuefile not updated!", ices_cue_get_filename ());
- return;
- }
-
- artist[0] = '\0';
- title[0] = '\0';
- ices_metadata_get (artist, sizeof (artist), title, sizeof (title));
-
- fprintf (fp, "%s\n%d\n%d\n%s\n%f\n%d\n%s\n%s\n", source->path,
- (int)source->filesize, source->bitrate,
- ices_util_file_time (source->bitrate, source->filesize, buf),
- ices_util_percent (source->bytes_read, source->filesize),
- ices_cue_lineno, artist, title);
-
- ices_util_fclose (fp);
-}
-
-/* Cleanup the cue module by removing the cue file */
-void
-ices_cue_shutdown (void)
-{
- const char *filename = ices_cue_get_filename ();
-
- if (filename && filename[0])
- remove (filename);
-}
-
-void
-ices_cue_set_lineno (int lineno)
-{
- ices_cue_lineno = lineno;
-}
-
-/* Mutator for the cue filename */
-void
-ices_cue_set_filename (const char *filename)
-{
- ices_cue_filename = ices_util_strdup (filename);
-}
-
-/* Return the current cue filename, and create it if
- * necessary */
-const char *
-ices_cue_get_filename (void)
-{
- static char buf[1024];
-
- if (ices_cue_filename)
- return ices_cue_filename;
-
- if (! ices_config.base_directory) {
- ices_log_error ("Base directory is invalid");
- return NULL;
- }
-
- snprintf (buf, sizeof (buf), "%s/ices.cue", ices_config.base_directory);
-
- return buf;
-}
-
-
-
Copied: icecast/tags/ices0/ices-0_4/src/cue.c (from rev 7407, icecast/trunk/ices0/src/cue.c)
Deleted: icecast/tags/ices0/ices-0_4/src/cue.h
===================================================================
--- icecast/trunk/ices0/src/cue.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/cue.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,26 +0,0 @@
-/* cue.h
- * - Cue file function declarations for ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-/* Public function declarations */
-void ices_cue_update (input_stream_t* source);
-void ices_cue_shutdown (void);
-void ices_cue_set_filename (const char *filename);
-void ices_cue_set_lineno (int lineno);
-const char *ices_cue_get_filename (void);
Copied: icecast/tags/ices0/ices-0_4/src/cue.h (from rev 7407, icecast/trunk/ices0/src/cue.h)
Deleted: icecast/tags/ices0/ices-0_4/src/definitions.h
===================================================================
--- icecast/trunk/ices0/src/definitions.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/definitions.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,137 +0,0 @@
-/* definitions.h
- * - All declarations and defines for ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef _ICES_DEFINITIONS_H
-#define _ICES_DEFINITIONS_H
-
-#ifdef _WIN32
-# include <win32config.h>
-#else
-# ifdef HAVE_CONFIG_H
-# include <config.h>
-# endif
-#endif
-
-#ifndef __USE_MISC
-# define __USE_MISC
-#endif
-
-#ifndef __USE_GNU
-# define __USE_GNU
-#endif
-
-#ifndef __USE_BSD
-# define __USE_BSD
-#endif
-
-#ifndef __EXTENSIONS__
-# define __EXTENSIONS__
-#endif
-
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-#endif
-
-#ifndef __USE_POSIX
-# define __USE_POSIX
-#endif
-
-#ifndef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 199506L
-#endif
-
-/* This for freebsd (needed on 3.2 at least) */
-#ifdef SOMEBSD
-# ifndef _POSIX_VERSION
-# define _POSIX_VERSION 199309L
-# endif
-#endif
-
-#include <stdio.h>
-#include <stdarg.h>
-#ifdef HAVE_SHOUT_SHOUT_H
-# include <shout/shout.h>
-#else
-# include <shout.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-/* This has all the datatypes */
-#include "icestypes.h"
-
-#include "setup.h"
-#include "stream.h"
-#include "log.h"
-#include "util.h"
-#include "cue.h"
-#include "id3.h"
-#include "mp3.h"
-#include "signals.h"
-#include "reencode.h"
-#include "ices_config.h"
-#include "playlist/playlist.h"
-
-ices_plugin_t *crossfade_plugin(int secs);
-
-#define BUFSIZE 8192
-#define ICES_DEFAULT_HOST "127.0.0.1"
-#define ICES_DEFAULT_PORT 8000
-#define ICES_DEFAULT_MOUNT "/ices"
-#define ICES_DEFAULT_PASSWORD "letmein"
-#define ICES_DEFAULT_PROTOCOL http_protocol_e
-#define ICES_DEFAULT_NAME "Default stream name"
-#define ICES_DEFAULT_GENRE "Default genre"
-#define ICES_DEFAULT_DESCRIPTION "Default description"
-#define ICES_DEFAULT_URL "http://www.icecast.org/"
-#define ICES_DEFAULT_BITRATE 128
-#define ICES_DEFAULT_ISPUBLIC 1
-#define ICES_DEFAULT_MODULE "ices"
-#define ICES_DEFAULT_CONFIGFILE "ices.conf"
-#define ICES_DEFAULT_PLAYLIST_FILE "playlist.txt"
-#define ICES_DEFAULT_RANDOMIZE_PLAYLIST 0
-#define ICES_DEFAULT_DAEMON 0
-#define ICES_DEFAULT_BASE_DIRECTORY "/tmp"
-#define ICES_DEFAULT_PLAYLIST_TYPE ices_playlist_builtin_e;
-#define ICES_DEFAULT_VERBOSE 0
-#define ICES_DEFAULT_REENCODE 0
-
-#endif
Copied: icecast/tags/ices0/ices-0_4/src/definitions.h (from rev 7458, icecast/trunk/ices0/src/definitions.h)
Deleted: icecast/tags/ices0/ices-0_4/src/ices.c
===================================================================
--- icecast/trunk/ices0/src/ices.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/ices.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,44 +0,0 @@
-/* ices.c
- * - Main Program *
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include "definitions.h"
-
-ices_config_t ices_config;
-
-/* Global function definitions */
-
-/* Ices starts here. But ends in ices_setup_shutdown(),
- * which calls exit(0) and that's the last you see of it. */
-int
-main (int argc, char **argv)
-{
- /* Make command line arguments available through
- * ices_util_get_argc() and argv */
- ices_util_set_args (argc, argv);
-
- /* Setup all options, and initialize all submodules */
- ices_setup_initialize ();
-
- /* Connect to server and keep streaming all the good stuff */
- ices_stream_loop (&ices_config);
-
- /* Not reached */
- return 0;
-}
Copied: icecast/tags/ices0/ices-0_4/src/ices.c (from rev 7407, icecast/trunk/ices0/src/ices.c)
Deleted: icecast/tags/ices0/ices-0_4/src/ices_config.h
===================================================================
--- icecast/trunk/ices0/src/ices_config.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/ices_config.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,22 +0,0 @@
-/* ices_config.h
- * - XML parser function declarations for ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-/* Public function declarations */
-int ices_xml_parse_config_file (ices_config_t *ices_config, const char *configfile);
Copied: icecast/tags/ices0/ices-0_4/src/ices_config.h (from rev 7407, icecast/trunk/ices0/src/ices_config.h)
Deleted: icecast/tags/ices0/ices-0_4/src/icestypes.h
===================================================================
--- icecast/trunk/ices0/src/icestypes.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/icestypes.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,128 +0,0 @@
-/* icestypes.h
- * - Datatypes for ices
- * Copyright (c) 2000 Alexander Haväng
- * Copyright (c) 2001-4 Brendan Cully <brendan at xiph.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef _ICES_ICESTYPES_H
-#define _ICES_ICESTYPES_H
-
-typedef enum {
- icy_protocol_e,
- xaudiocast_protocol_e,
- http_protocol_e
-} protocol_t;
-
-typedef enum {
- ices_playlist_builtin_e,
- ices_playlist_python_e,
- ices_playlist_perl_e
-} playlist_type_t;
-
-typedef struct ices_stream_St {
- shout_t* conn;
- time_t connect_delay;
- int errs;
- void* encoder_state;
-
- char *host;
- int port;
- char *password;
- protocol_t protocol;
-
- char* mount;
- char* dumpfile;
-
- char* name;
- char* genre;
- char* description;
- char* url;
- int ispublic;
-
- int reencode;
- int bitrate;
- int out_samplerate;
- int out_numchannels;
-
- struct ices_stream_St* next;
-} ices_stream_t;
-
-typedef struct {
- playlist_type_t playlist_type;
- int randomize;
- char* playlist_file;
- char* module;
-
- char* (*get_next) (void); /* caller frees result */
- char* (*get_metadata) (void); /* caller frees result */
- int (*get_lineno) (void);
- int (*reload) (void);
- void (*shutdown) (void);
-} playlist_module_t;
-
-/* -- input stream types -- */
-typedef enum {
- ICES_INPUT_VORBIS,
- ICES_INPUT_MP3
-} input_type_t;
-
-typedef struct _input_stream_t {
- input_type_t type;
-
- char* path;
- int fd;
- size_t filesize;
- size_t bytes_read;
- unsigned int bitrate;
- unsigned int samplerate;
- unsigned int channels;
-
- void* data;
-
- ssize_t (*read)(struct _input_stream_t* self, void* buf, size_t len);
- /* len is the size in bytes of left or right. The two buffers must be
- * the same size. */
- ssize_t (*readpcm)(struct _input_stream_t* self, size_t len, int16_t* left,
- int16_t* right);
- int (*close)(struct _input_stream_t* self);
-} input_stream_t;
-
-typedef struct _ices_plugin {
- const char *name;
-
- int (*init)(void);
- void (*new_track)(input_stream_t *source);
- int (*process)(int ilen, int16_t *il, int16_t *ir);
- void (*shutdown)(void);
-
- struct _ices_plugin *next;
-} ices_plugin_t;
-
-typedef struct {
- int daemon;
- int verbose;
- int reencode;
- char *configfile;
- char *base_directory;
- FILE *logfile;
-
- ices_stream_t* streams;
- playlist_module_t pm;
- ices_plugin_t *plugins;
-} ices_config_t;
-#endif
Copied: icecast/tags/ices0/ices-0_4/src/icestypes.h (from rev 7428, icecast/trunk/ices0/src/icestypes.h)
Deleted: icecast/tags/ices0/ices-0_4/src/id3.c
===================================================================
--- icecast/trunk/ices0/src/id3.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/id3.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,340 +0,0 @@
-/* id3.c
- * - Functions for id3 tags in ices
- * Copyright (c) 2000 Alexander Haväng
- * Copyright (c) 2001-3 Brendan Cully <brendan at icecast.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include "definitions.h"
-#include "metadata.h"
-
-/* Local definitions */
-typedef struct {
- unsigned char major_version;
- unsigned char minor_version;
- unsigned char flags;
- size_t len;
-
- char* artist;
- char* title;
-
- unsigned int pos;
-} id3v2_tag;
-
-typedef struct {
- size_t frame_len;
- const char* artist_tag;
- const char* title_tag;
-} id3v2_version_info;
-
-static id3v2_version_info vi[5] = {
- { 6, "TP1", "TT2" },
- { 6, "TP1", "TT2" },
- { 6, "TP1", "TT2" },
- { 10, "TPE1", "TIT2" },
- { 10, "TPE1", "TIT2" }
-};
-
-#define ID3V2_FLAG_UNSYNC (1<<7)
-#define ID3V2_FLAG_EXTHDR (1<<6)
-#define ID3V2_FLAG_EXPHDR (1<<5)
-#define ID3V2_FLAG_FOOTER (1<<4)
-
-#define ID3V2_FRAME_LEN(tagp) (vi[(tagp)->major_version].frame_len)
-#define ID3V2_ARTIST_TAG(tagp) (vi[(tagp)->major_version].artist_tag)
-#define ID3V2_TITLE_TAG(tagp) (vi[(tagp)->major_version].title_tag)
-
-/* Private function declarations */
-static int id3v2_read_exthdr (input_stream_t* source, id3v2_tag* tag);
-ssize_t id3v2_read_frame (input_stream_t* source, id3v2_tag* tag);
-static int id3v2_skip_data (input_stream_t* source, id3v2_tag* tag, size_t len);
-static int id3v2_decode_synchsafe (unsigned char* synchsafe);
-static int id3v2_decode_synchsafe3 (unsigned char* synchsafe);
-static int id3v2_decode_unsafe (unsigned char* in);
-
-/* Global function definitions */
-
-void
-ices_id3v1_parse (input_stream_t* source)
-{
- off_t pos;
- char buffer[1024];
- char title[31];
- int i;
-
- if (! source->filesize)
- return;
-
- buffer[30] = '\0';
- title[30] = '\0';
- pos = lseek (source->fd, 0, SEEK_CUR);
-
- lseek (source->fd, -128, SEEK_END);
-
- if ((read (source->fd, buffer, 3) == 3) && !strncmp (buffer, "TAG", 3)) {
- /* Don't stream the tag */
- source->filesize -= 128;
-
- if (read (source->fd, title, 30) != 30) {
- ices_log ("Error reading ID3v1 song title: %s",
- ices_util_strerror (errno, buffer, sizeof (buffer)));
- goto out;
- }
-
- for (i = strlen (title) - 1; i >= 0 && title[i] == ' '; i--)
- title[i] = '\0';
- ices_log_debug ("ID3v1: Title: %s", title);
-
- if (read (source->fd, buffer, 30) != 30) {
- ices_log ("Error reading ID3v1 artist: %s",
- ices_util_strerror (errno, buffer, sizeof (buffer)));
- goto out;
- }
-
- for (i = strlen (buffer) - 1; i >= 0 && buffer[i] == ' '; i--)
- buffer[i] = '\0';
- ices_log_debug ("ID3v1: Artist: %s", buffer);
-
- ices_metadata_set (buffer, title);
- }
-
-out:
- lseek (source->fd, pos, SEEK_SET);
-}
-
-void
-ices_id3v2_parse (input_stream_t* source)
-{
- unsigned char buf[1024];
- id3v2_tag tag;
- size_t remaining;
- ssize_t rv;
-
- if (source->read (source, buf, 10) != 10) {
- ices_log ("Error reading ID3v2");
-
- return;
- }
-
- tag.artist = tag.title = NULL;
- tag.pos = 0;
- tag.major_version = *(buf + 3);
- tag.minor_version = *(buf + 4);
- tag.flags = *(buf + 5);
- tag.len = id3v2_decode_synchsafe (buf + 6);
- ices_log_debug ("ID3v2: version %d.%d. Tag size is %d bytes.",
- tag.major_version, tag.minor_version, tag.len);
- if (tag.major_version > 4) {
- ices_log_debug ("ID3v2: Version greater than maximum supported (4), skipping");
- id3v2_skip_data (source, &tag, tag.len);
-
- return;
- }
-
- if ((tag.major_version > 2) &&
- (tag.flags & ID3V2_FLAG_EXTHDR) && id3v2_read_exthdr (source, &tag) < 0) {
- ices_log ("Error reading ID3v2 extended header");
-
- return;
- }
-
- remaining = tag.len - tag.pos;
- if ((tag.major_version > 3) && (tag.flags & ID3V2_FLAG_FOOTER))
- remaining -= 10;
-
- while (remaining > ID3V2_FRAME_LEN(&tag) && (tag.artist == NULL || tag.title == NULL)) {
- if ((rv = id3v2_read_frame (source, &tag)) < 0) {
- ices_log ("Error reading ID3v2 frames, skipping to end of ID3v2 tag");
- break;
- }
- /* found padding */
- if (rv == 0)
- break;
-
- remaining -= rv;
- }
-
- /* allow fallback to ID3v1 */
- if (tag.artist || tag.title)
- ices_metadata_set (tag.artist, tag.title);
- ices_util_free (tag.artist);
- ices_util_free (tag.title);
-
- remaining = tag.len - tag.pos;
- if (remaining)
- id3v2_skip_data (source, &tag, remaining);
-}
-
-static int
-id3v2_read_exthdr (input_stream_t* source, id3v2_tag* tag)
-{
- char hdr[6];
- size_t len;
-
- if (source->read (source, hdr, 6) != 6) {
- ices_log ("Error reading ID3v2 extended header");
-
- return -1;
- }
- tag->pos += 6;
-
- len = id3v2_decode_synchsafe (hdr);
- ices_log_debug ("ID3v2: %d byte extended header found, skipping.", len);
-
- if (len > 6)
- return id3v2_skip_data (source, tag, len - 6);
- else
- return 0;
-}
-
-ssize_t
-id3v2_read_frame (input_stream_t* source, id3v2_tag* tag)
-{
- char hdr[10];
- size_t len, len2;
- ssize_t rlen;
- char* buf;
-
- if (source->read (source, hdr, ID3V2_FRAME_LEN(tag)) != ID3V2_FRAME_LEN(tag)) {
- ices_log ("Error reading ID3v2 frame");
-
- return -1;
- }
- tag->pos += ID3V2_FRAME_LEN(tag);
-
- if (hdr[0] == '\0')
- return 0;
-
- if (tag->major_version < 3) {
- len = id3v2_decode_synchsafe3 (hdr + 3);
- hdr[3] = '\0';
- } else if (tag->major_version == 3) {
- len = id3v2_decode_unsafe (hdr + 4);
- hdr[4] = '\0';
- } else {
- len = id3v2_decode_synchsafe (hdr + 4);
- hdr[4] = '\0';
- }
- if (len > tag->len - tag->pos) {
- ices_log ("Error parsing ID3v2 frame header: Frame too large (%d bytes)", len);
-
- return -1;
- }
-
- /* ices_log_debug("ID3v2: Frame type [%s] found, %d bytes", hdr, len); */
- if (!strcmp (hdr, ID3V2_ARTIST_TAG(tag)) || !strcmp (hdr, ID3V2_TITLE_TAG(tag))) {
- if (! (buf = malloc(len+1))) {
- ices_log ("Error allocating memory while reading ID3v2 frame");
-
- return -1;
- }
- len2 = len;
- while (len2) {
- if ((rlen = source->read (source, buf, len)) < 0) {
- ices_log ("Error reading ID3v2 frame data");
- free (buf);
-
- return -1;
- }
- tag->pos += rlen;
- len2 -= rlen;
- }
-
- /* skip encoding */
- if (!strcmp (hdr, ID3V2_TITLE_TAG(tag))) {
- buf[len] = '\0';
- ices_log_debug ("ID3v2: Title found: %s", buf + 1);
- tag->title = ices_util_strdup (buf + 1);
- } else {
- buf[len] = '\0';
- ices_log_debug ("ID3v2: Artist found: %s", buf + 1);
- tag->artist = ices_util_strdup (buf + 1);
- }
-
- free (buf);
- } else if (id3v2_skip_data (source, tag, len))
- return -1;
-
- return len + ID3V2_FRAME_LEN(tag);
-}
-
-static int
-id3v2_skip_data (input_stream_t* source, id3v2_tag* tag, size_t len)
-{
- char* buf;
- ssize_t rlen;
-
- if (! (buf = malloc(len))) {
- ices_log ("Error allocating memory while skipping ID3v2 data");
-
- return -1;
- }
-
- while (len) {
- if ((rlen = source->read (source, buf, len)) < 0) {
- ices_log ("Error skipping in ID3v2 tag.");
- free (buf);
-
- return -1;
- }
- tag->pos += rlen;
- len -= rlen;
- }
-
- free (buf);
-
- return 0;
-}
-
-static int
-id3v2_decode_synchsafe (unsigned char* synchsafe)
-{
- int res;
-
- res = synchsafe[3];
- res |= synchsafe[2] << 7;
- res |= synchsafe[1] << 14;
- res |= synchsafe[0] << 21;
-
- return res;
-}
-
-static int
-id3v2_decode_synchsafe3 (unsigned char* synchsafe)
-{
- int res;
-
- res = synchsafe[2];
- res |= synchsafe[1] << 7;
- res |= synchsafe[0] << 14;
-
- return res;
-}
-
-/* id3v2.3 badly specifies frame length */
-static int
-id3v2_decode_unsafe (unsigned char* in)
-{
- int res;
-
- res = in[3];
- res |= in[2] << 8;
- res |= in[1] << 16;
- res |= in[0] << 24;
-
- return res;
-}
Copied: icecast/tags/ices0/ices-0_4/src/id3.c (from rev 7407, icecast/trunk/ices0/src/id3.c)
Deleted: icecast/tags/ices0/ices-0_4/src/id3.h
===================================================================
--- icecast/trunk/ices0/src/id3.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/id3.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,23 +0,0 @@
-/* id3.h
- * - id3 function declarations for ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-/* Public function declarations */
-void ices_id3v1_parse (input_stream_t* source);
-void ices_id3v2_parse (input_stream_t* source);
Copied: icecast/tags/ices0/ices-0_4/src/id3.h (from rev 7407, icecast/trunk/ices0/src/id3.h)
Copied: icecast/tags/ices0/ices-0_4/src/in_flac.c (from rev 7433, icecast/trunk/ices0/src/in_flac.c)
Copied: icecast/tags/ices0/ices-0_4/src/in_flac.h (from rev 7428, icecast/trunk/ices0/src/in_flac.h)
Copied: icecast/tags/ices0/ices-0_4/src/in_mp4.c (from rev 7425, icecast/trunk/ices0/src/in_mp4.c)
Copied: icecast/tags/ices0/ices-0_4/src/in_mp4.h (from rev 7421, icecast/trunk/ices0/src/in_mp4.h)
Deleted: icecast/tags/ices0/ices-0_4/src/in_vorbis.c
===================================================================
--- icecast/trunk/ices0/src/in_vorbis.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/in_vorbis.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,244 +0,0 @@
-/* in_vorbis.c
- * Plugin to read vorbis files as PCM
- *
- * Copyright (c) 2001-3 Brendan Cully <brendan at xiph.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include "in_vorbis.h"
-#include "metadata.h"
-
-#include <string.h>
-
-#include <vorbis/vorbisfile.h>
-
-#define SAMPLESIZE 2
-#ifdef WORDS_BIGENDIAN
-# define ICES_OV_BE 1
-#else
-# define ICES_OV_BE 0
-#endif
-
-/* -- data structures -- */
-typedef struct {
- OggVorbis_File* vf;
- vorbis_info* info;
- int link;
- int16_t buf[2048];
- size_t samples;
- int offset;
-} ices_vorbis_in_t;
-
-/* -- static prototypes -- */
-static int ices_vorbis_readpcm (input_stream_t* self, size_t len,
- int16_t* left, int16_t* right);
-static int ices_vorbis_close (input_stream_t* self);
-static void in_vorbis_parse (input_stream_t* self);
-static void in_vorbis_set_metadata (ices_vorbis_in_t* vorbis_data);
-
-/* try to open a vorbis file for decoding. Returns:
- * 0: success
- * 1: not a vorbis file
- * -1: error opening
- */
-int
-ices_vorbis_open (input_stream_t* self, char* buf, size_t len)
-{
- ices_vorbis_in_t* vorbis_data;
- OggVorbis_File* vf;
- FILE* fin;
- char errbuf[128];
- int rc;
-
- if (! (fin = fdopen (self->fd, "rb"))) {
- ices_util_strerror (errno, errbuf, sizeof (errbuf));
- ices_log_error ("Error opening %s: %s", self->path, errbuf);
-
- return -1;
- }
-
- if (! (vf = (OggVorbis_File*) malloc (sizeof (OggVorbis_File)))) {
- ices_log_error ("Malloc failed in ices_vorbis_open");
- return -1;
- }
-
- if ((rc = ov_open (fin, vf, buf, len)) != 0) {
- free (vf);
- fclose (fin);
-
- if (rc == OV_ENOTVORBIS)
- return 1;
-
- if (rc == OV_EREAD)
- ices_log_error ("Read error opening vorbis file");
- else if (rc == OV_EVERSION)
- ices_log_error ("Vorbis version mismatch");
- else if (rc == OV_EBADHEADER)
- ices_log_error ("Invalid vorbis header");
- else
- ices_log_error ("Error in ov_open: %d", rc);
-
- return -1;
- }
-
- if (!(vorbis_data = (ices_vorbis_in_t*)malloc (sizeof (ices_vorbis_in_t)))) {
- ices_log_error ("Malloc failed in ices_vorbis_open");
- ov_clear (vf);
- free (vf);
- return -1;
- }
-
- if (!(vorbis_data->info = ov_info(vf, -1))) {
- ices_log_error ("Vorbis: error reading vorbis info");
- ices_vorbis_close (self);
-
- return -1;
- }
-
- if (vorbis_data->info->channels < 1) {
- ices_log_error ("Vorbis: Cannot decode, %d channels of audio data!",
- vorbis_data->info->channels);
- ices_vorbis_close (self);
-
- return -1;
- }
-
- vorbis_data->vf = vf;
- vorbis_data->samples = 0;
- vorbis_data->link = -1;
-
- self->type = ICES_INPUT_VORBIS;
- self->data = vorbis_data;
-
- self->read = NULL;
- self->readpcm = ices_vorbis_readpcm;
- self->close = ices_vorbis_close;
-
- in_vorbis_parse (self);
-
- return 0;
-}
-
-static int
-ices_vorbis_readpcm (input_stream_t* self, size_t olen, int16_t* left,
- int16_t* right)
-{
- ices_vorbis_in_t* vorbis_data = (ices_vorbis_in_t*) self->data;
- int link;
- int len;
- int i;
-
- /* refill buffer if necessary */
- if (! vorbis_data->samples) {
- vorbis_data->offset = 0;
- do {
- if ((len = ov_read (vorbis_data->vf, (char*) vorbis_data->buf,
- sizeof (vorbis_data->buf), ICES_OV_BE, SAMPLESIZE, 1, &link)) <= 0) {
- if (len == OV_HOLE) {
- ices_log_error ("Skipping bad vorbis data");
- } else
- return len;
- }
- } while (len <= 0);
-
- if (vorbis_data->link == -1)
- vorbis_data->link = link;
- else if (vorbis_data->link != link) {
- vorbis_data->link = link;
- ices_log_debug("New Ogg link found in bitstream");
- in_vorbis_parse (self);
- ices_reencode_reset (self);
- ices_metadata_update (0);
- }
-
- vorbis_data->samples = len / SAMPLESIZE;
- if (vorbis_data->info->channels > 1)
- vorbis_data->samples /= vorbis_data->info->channels;
- self->bytes_read = ov_raw_tell (vorbis_data->vf);
- }
-
- len = 0;
- while (vorbis_data->samples && olen) {
- if (vorbis_data->info->channels == 1) {
- *left = *right = vorbis_data->buf[vorbis_data->offset++];
- left++;
- right++;
- } else {
- *left++ = vorbis_data->buf[vorbis_data->offset++];
- *right++ = vorbis_data->buf[vorbis_data->offset++];
- }
- for (i = 0; i < vorbis_data->info->channels - 2; i++)
- vorbis_data->offset++;
- vorbis_data->samples--;
- olen -= SAMPLESIZE;
- len++;
- }
-
- return len;
-}
-
-static int
-ices_vorbis_close (input_stream_t* self)
-{
- ices_vorbis_in_t* vorbis_data = (ices_vorbis_in_t*) self->data;
-
- ov_clear (vorbis_data->vf);
- free (vorbis_data->vf);
- free (vorbis_data);
-
- return 0;
-}
-
-static void in_vorbis_parse(input_stream_t* self) {
- ices_vorbis_in_t* vorbis_data = (ices_vorbis_in_t*) self->data;
-
- vorbis_data->info = ov_info(vorbis_data->vf, vorbis_data->link);
- self->bitrate = vorbis_data->info->bitrate_nominal / 1000;
- if (! self->bitrate)
- self->bitrate = ov_bitrate (vorbis_data->vf, vorbis_data->link) / 1000;
- self->samplerate = (unsigned int) vorbis_data->info->rate;
- self->channels = vorbis_data->info->channels;
-
- ices_log_debug("Ogg vorbis file found, version %d, %d kbps, %d channels, %ld Hz",
- vorbis_data->info->version, self->bitrate, vorbis_data->info->channels,
- self->samplerate);
- in_vorbis_set_metadata (vorbis_data);
-}
-
-static void
-in_vorbis_set_metadata (ices_vorbis_in_t* vorbis_data)
-{
- vorbis_comment* comment;
- char* key;
- char* artist = NULL;
- char* title = NULL;
- int i;
-
- if (! (comment = ov_comment (vorbis_data->vf, -1)))
- return;
-
- for (i = 0; i < comment->comments; i++) {
- key = comment->user_comments[i];
- ices_log_debug ("Vorbis comment found: %s", key);
- if (! strncasecmp ("artist", key, 6))
- artist = key+7;
- else if (! strncasecmp ("title", key, 5))
- title = key+6;
- }
-
- ices_metadata_set (artist, title);
-}
Copied: icecast/tags/ices0/ices-0_4/src/in_vorbis.c (from rev 7407, icecast/trunk/ices0/src/in_vorbis.c)
Deleted: icecast/tags/ices0/ices-0_4/src/in_vorbis.h
===================================================================
--- icecast/trunk/ices0/src/in_vorbis.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/in_vorbis.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,29 +0,0 @@
-/* vorbis.h
- * ices input plugin to read vorbis files as PCM
- *
- * Copyright (c) 2001-3 Brendan Cully
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef IN_VORBIS_H
-#define IN_VORBIS_H
-
-#include "definitions.h"
-
-int ices_vorbis_open (input_stream_t* self, char* buf, size_t len);
-
-#endif
Copied: icecast/tags/ices0/ices-0_4/src/in_vorbis.h (from rev 7407, icecast/trunk/ices0/src/in_vorbis.h)
Deleted: icecast/tags/ices0/ices-0_4/src/log.c
===================================================================
--- icecast/trunk/ices0/src/log.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/log.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,202 +0,0 @@
-/* log.c
- * - Functions for logging in ices
- * Copyright (c) 2000 Alexander Haväng
- * Copyright (c) 2001 Brendan Cully
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include "definitions.h"
-
-extern ices_config_t ices_config;
-
-/* Private function declarations */
-static void ices_log_string (char *format, char *string);
-static int ices_log_open_logfile (void);
-static int ices_log_close_logfile (void);
-
-static char lasterror[BUFSIZE];
-/* Public function definitions */
-
-/* Initialize the log module, creates log file */
-void
-ices_log_initialize (void)
-{
- if (!ices_log_open_logfile ()) {
- ices_log ("%s", ices_log_get_error ());
- }
- ices_log ("Logfile opened");
-}
-
-/* Shutdown the log module, close the logfile */
-void
-ices_log_shutdown (void)
-{
- if (!ices_log_close_logfile ()) {
- ices_log ("%s", ices_log_get_error ());
- }
-}
-
-/* Close everything, start up with clean slate when
- * run as a daemon */
-void
-ices_log_daemonize (void)
-{
- close (0);
- close (1);
- close (2);
-
- freopen ("/dev/null", "r", stdin);
- freopen ("/dev/null", "w", stdout);
- freopen ("/dev/null", "w", stderr);
-
- ices_log_reopen_logfile ();
-}
-
-/* Cycle the logfile, usually called from the SIGHUP handler */
-int
-ices_log_reopen_logfile (void)
-{
- ices_log_close_logfile ();
- return ices_log_open_logfile ();
-}
-
-/* Log only if verbose mode is set. Prepend output with DEBUG: */
-void
-ices_log_debug (const char *fmt, ...)
-{
- char buff[BUFSIZE];
- va_list ap;
-
- if (!ices_config.verbose)
- return;
-
- va_start(ap, fmt);
-#ifdef HAVE_VSNPRINTF
- vsnprintf(buff, BUFSIZE, fmt, ap);
-#else
- vsprintf(buff, fmt, ap);
-#endif
- va_end(ap);
-
- ices_log_string ("DEBUG: %s\n", buff);
-}
-
-/* Log to console and file */
-void
-ices_log (const char *fmt, ...)
-{
- char buff[BUFSIZE];
- va_list ap;
-
- va_start(ap, fmt);
-#ifdef HAVE_VSNPRINTF
- vsnprintf(buff, BUFSIZE, fmt, ap);
-#else
- vsprintf(buff, fmt, ap);
-#endif
- va_end(ap);
-
- ices_log_string ("%s\n", buff);
-}
-
-/* Store error information in module memory */
-void
-ices_log_error (const char *fmt, ...)
-{
- char buff[BUFSIZE];
- va_list ap;
-
- va_start(ap, fmt);
-#ifdef HAVE_VSNPRINTF
- vsnprintf(buff, BUFSIZE, fmt, ap);
-#else
- vsprintf(buff, fmt, ap);
-#endif
- va_end(ap);
-
- strncpy (lasterror, buff, BUFSIZE);
-}
-
-/* Get last error from log module */
-char *
-ices_log_get_error (void)
-{
- return lasterror;
-}
-
-/* Private function definitions */
-
-/* Function to log string to both console and file */
-static void
-ices_log_string (char *format, char *string)
-{
- if (ices_config.logfile) {
- fprintf (ices_config.logfile, format, string);
-#ifndef HAVE_SETLINEBUF
- fflush (ices_config.logfile);
-#endif
- }
-
- /* Don't log to console when daemonized */
- if (!ices_config.daemon) {
- fprintf (stdout, format, string);
- }
-}
-
-/* Open the ices logfile, create it if needed */
-static int
-ices_log_open_logfile (void)
-{
- char namespace[1024], buf[1024];
- FILE *logfp;
-
- if (! ices_config.base_directory ||
- strlen (ices_config.base_directory) > 1016)
- {
- ices_log_error ("Base directory is invalid");
- return 0;
- }
-
- snprintf (namespace, sizeof (namespace), "%s/ices.log",
- ices_config.base_directory);
-
- logfp = fopen (namespace, "a");
-
- if (!logfp) {
- ices_log_error ("Error while opening %s, error: %s", namespace,
- ices_util_strerror (errno, buf, 1024));
- return 0;
- }
-
- ices_config.logfile = logfp;
-#ifdef HAVE_SETLINEBUF
- setlinebuf (ices_config.logfile);
-#endif
-
- return 1;
-}
-
-/* Close ices' logfile */
-static int
-ices_log_close_logfile (void)
-{
- if (ices_config.logfile) {
- ices_util_fclose (ices_config.logfile);
- }
-
- return 1;
-}
Copied: icecast/tags/ices0/ices-0_4/src/log.c (from rev 7407, icecast/trunk/ices0/src/log.c)
Deleted: icecast/tags/ices0/ices-0_4/src/log.h
===================================================================
--- icecast/trunk/ices0/src/log.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/log.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,46 +0,0 @@
-/* log.h
- * - logging function declarations for ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-/* Public function declarations */
-void ices_log (const char *fmt, ...);
-void ices_log_error (const char *fmt, ...);
-void ices_log_debug (const char *fmt, ...);
-char *ices_log_get_error (void);
-int ices_log_reopen_logfile (void);
-void ices_log_initialize (void);
-void ices_log_shutdown (void);
-void ices_log_daemonize (void);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Copied: icecast/tags/ices0/ices-0_4/src/log.h (from rev 7407, icecast/trunk/ices0/src/log.h)
Deleted: icecast/tags/ices0/ices-0_4/src/metadata.c
===================================================================
--- icecast/trunk/ices0/src/metadata.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/metadata.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,173 +0,0 @@
-/* metadata.c
- * Copyright (c) 2001-3 Brendan Cully <brendan at xiph.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include "definitions.h"
-
-#define INITDELAY 500000
-
-extern ices_config_t ices_config;
-
-static char* Artist = NULL;
-static char* Title = NULL;
-static char* Filename = NULL;
-
-/* Private function declarations */
-static char* metadata_clean_filename (const char* path, char* buf,
- size_t len);
-static void metadata_update (int delay);
-
-/* Global function definitions */
-
-void
-ices_metadata_get (char* artist, size_t alen, char* title, size_t tlen)
-{
- if (Artist)
- snprintf (artist, alen, "%s", Artist);
- if (Title)
- snprintf (title, tlen, "%s", Title);
-}
-
-void
-ices_metadata_set (const char* artist, const char* title)
-{
- ices_util_free (Artist);
- Artist = NULL;
- ices_util_free (Title);
- Title = NULL;
-
- if (artist && *artist)
- Artist = ices_util_strdup (artist);
- if (title && *title)
- Title = ices_util_strdup (title);
-}
-
-void
-ices_metadata_set_file (const char* filename)
-{
- char buf[1024];
-
- ices_util_free (Filename);
- Filename = NULL;
-
- if (filename && *filename) {
- metadata_clean_filename (filename, buf, sizeof (buf));
- Filename = ices_util_strdup (buf);
- }
-}
-
-/* Update metadata on server via fork.
- * Note that the very first metadata update after connection is delayed,
- * because if we try to update our new info to the server and the server has
- * not yet accepted us as a source, the information is lost. */
-void
-ices_metadata_update (int delay)
-{
- pid_t child;
-
- if (delay)
- ices_log_debug ("Delaying metadata update...");
-
- if ((child = fork()) == 0) {
- metadata_update (delay ? INITDELAY : 0);
- _exit (0);
- }
-
- if (child == -1)
- ices_log_debug ("Metadata update failed: fork");
-}
-
-static void
-metadata_update (int delay)
-{
- ices_stream_t* stream;
- shout_metadata_t* metadata;
- char song[1024];
- char* playlist_metadata;
- char* value;
- int rc;
-
- if (delay)
- usleep (delay);
-
- if (! (playlist_metadata = ices_playlist_get_metadata ())) {
- if (Title) {
- if (Artist)
- snprintf (song, sizeof (song), "%s - %s", Artist, Title);
- else
- snprintf (song, sizeof (song), "%s", Title);
- } else
- snprintf (song, sizeof (song), "%s", Filename);
-
- value = song;
- } else
- value = playlist_metadata;
-
- if (!(metadata = shout_metadata_new())) {
- ices_log_error ("Error allocating metadata structure");
- ices_util_free (playlist_metadata);
- return;
- }
-
- if (shout_metadata_add (metadata, "song", value) != SHOUTERR_SUCCESS) {
- ices_log_error ("Error adding info to metadata structure");
- ices_util_free (playlist_metadata);
- shout_metadata_free (metadata);
- return;
- }
-
- for (stream = ices_config.streams; stream; stream = stream->next) {
- rc = shout_set_metadata (stream->conn, metadata);
-
- if (rc != SHOUTERR_SUCCESS)
- ices_log_error ("Updating metadata on %s failed.", stream->mount);
- else
- ices_log_debug ("Updated metadata on %s to: %s", stream->mount, value);
- }
-
- ices_util_free (playlist_metadata);
- shout_metadata_free (metadata);
-}
-
-/* Cleanup a filename so it looks more like a song name */
-static char *
-metadata_clean_filename (const char* path, char *buf, size_t len)
-{
- char *ptr =NULL;
-
- if (!path || !buf) {
- ices_log ("ERROR: Polluted strings sent to filename cleanup.");
- return NULL;
- }
-
- /* Find last slash */
- ptr = strrchr (path, '/');
-
- if (ptr && strlen (ptr) > 0) {
- strncpy (buf, ptr + 1, len);
- } else {
- strncpy (buf, path, len);
- }
-
- if ((ptr = strrchr (buf, '.'))) {
- *ptr = '\0';
- }
-
- ices_log_debug ("Filename cleaned up from [%s] to [%s]", path, buf);
- return buf;
-}
Copied: icecast/tags/ices0/ices-0_4/src/metadata.c (from rev 7407, icecast/trunk/ices0/src/metadata.c)
Deleted: icecast/tags/ices0/ices-0_4/src/metadata.h
===================================================================
--- icecast/trunk/ices0/src/metadata.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/metadata.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,24 +0,0 @@
-/* metadata.h
- * Copyright (c) 2001-3 Brendan Cully <brendan at xiph.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-/* Public function declarations */
-void ices_metadata_get (char* artist, size_t alen, char* title, size_t tlen);
-void ices_metadata_set (const char* artist, const char* title);
-void ices_metadata_set_file (const char* filename);
-void ices_metadata_update (int delay);
Copied: icecast/tags/ices0/ices-0_4/src/metadata.h (from rev 7407, icecast/trunk/ices0/src/metadata.h)
Deleted: icecast/tags/ices0/ices-0_4/src/mp3.c
===================================================================
--- icecast/trunk/ices0/src/mp3.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/mp3.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,512 +0,0 @@
-/* mp3.c
- * - Functions for mp3 in ices
- * Copyright (c) 2000 Alexander Haväng
- * Copyright (c) 2001-3 Brendan Cully
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id: mp3.c,v 1.35 2003/07/06 18:26:47 brendan Exp $
- */
-
-#include "definitions.h"
-
-/* reference: http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm */
-
-#define MPG_MD_MONO 3
-
-#define MP3_BUFFER_SIZE 4096
-
-typedef struct {
- unsigned int version;
- unsigned int layer;
- unsigned int error_protection;
- unsigned int bitrate;
- unsigned int samplerate;
- unsigned int padding;
- unsigned int extension;
- unsigned int mode;
- unsigned int mode_ext;
- unsigned int copyright;
- unsigned int original;
- unsigned int emphasis;
- unsigned int channels;
-} mp3_header_t;
-
-typedef struct {
- unsigned char* buf;
- size_t len;
- int pos;
-} ices_mp3_in_t;
-
-static unsigned int bitrates[2][3][15] =
-{
- /* MPEG-1 */
- {
- {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448},
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384},
- {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320}
- },
- /* MPEG-2 LSF, MPEG-2.5 */
- {
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}
- },
-};
-
-static unsigned int s_freq[3][4] =
-{
- {44100, 48000, 32000, 0},
- {22050, 24000, 16000, 0},
- {11025, 8000, 8000, 0}
-};
-
-static char *mode_names[5] = {"stereo", "j-stereo", "dual-ch", "mono", "multi-ch"};
-static char *layer_names[3] = {"I", "II", "III"};
-static char *version_names[3] = {"MPEG-1", "MPEG-2 LSF", "MPEG-2.5"};
-
-/* -- static prototypes -- */
-static int ices_mp3_parse (input_stream_t* source);
-static ssize_t ices_mp3_read (input_stream_t* self, void* buf, size_t len);
-#ifdef HAVE_LIBLAME
-static ssize_t ices_mp3_readpcm (input_stream_t* self, size_t len,
- int16_t* left, int16_t* right);
-#endif
-static int ices_mp3_close (input_stream_t* self);
-static int mp3_fill_buffer (input_stream_t* self, size_t len);
-static void mp3_trim_file (input_stream_t* self, mp3_header_t* header);
-static int mp3_parse_frame(const unsigned char* buf, mp3_header_t* header);
-static int mp3_check_vbr(input_stream_t* source, mp3_header_t* header);
-static size_t mp3_frame_length(mp3_header_t* header);
-
-/* Global function definitions */
-
-/* Parse mp3 file for header information; bitrate, channels, mode, sample_rate.
- */
-static int ices_mp3_parse (input_stream_t* source)
-{
- ices_mp3_in_t* mp3_data = (ices_mp3_in_t*) source->data;
- mp3_header_t mh;
- size_t len, framelen;
- int rc = 0;
- int off = 0;
-
- if (mp3_data->len < 4)
- return 1;
-
- /* Ogg/Vorbis often contains bits that almost look like MP3 headers */
- if (! strncmp ("OggS", mp3_data->buf, 4))
- return 1;
-
- /* first check for ID3v2 */
- if (! strncmp ("ID3", mp3_data->buf, 3))
- ices_id3v2_parse (source);
-
- /* ensure we have at least 4 bytes in the read buffer */
- if (!mp3_data->buf || mp3_data->len - mp3_data->pos < 4)
- mp3_fill_buffer (source, MP3_BUFFER_SIZE);
- if (mp3_data->len - mp3_data->pos < 4) {
- ices_log_error("Short file");
- return -1;
- }
-
- /* seek past garbage if necessary */
- do {
- len = mp3_data->len - mp3_data->pos;
-
- /* copy remaining bytes to front, refill buffer without malloc/free */
- if (len < 4) {
- char* buffer = mp3_data->buf;
-
- memcpy (buffer, buffer + mp3_data->pos, len);
- /* make read fetch from source instead of buffer */
- mp3_data->buf = NULL;
- len += source->read(source, buffer + len, mp3_data->len - len);
- mp3_data->buf = buffer;
- mp3_data->pos = 0;
- if (len < 4)
- break;
- }
-
- /* we must be able to read at least 4 bytes of header */
- while (mp3_data->len - mp3_data->pos >= 4) {
- /* don't bother with free bit rate MP3s - they are so rare that a parse error is more likely */
- if ((rc = mp3_parse_frame(mp3_data->buf + mp3_data->pos, &mh))
- && (framelen = mp3_frame_length (&mh))) {
- mp3_header_t next_header;
-
- source->samplerate = mh.samplerate;
- source->bitrate = mh.bitrate;
- source->channels = mh.channels;
-
- if (mp3_check_vbr (source, &mh)) {
- source->bitrate = 0;
- break;
- }
-
- /* check next frame if possible */
- if (mp3_fill_buffer (source, framelen + 4) <= 0)
- break;
-
- /* if we can't find the second frame, we assume the first frame was junk */
- if ((rc = mp3_parse_frame(mp3_data->buf + mp3_data->pos + framelen, &next_header))) {
- if (mh.version != next_header.version || mh.layer != next_header.layer
- || mh.samplerate != next_header.samplerate) {
- rc = 0;
- /* fallback VBR check if VBR tag is missing */
- } else {
- if (mh.bitrate != next_header.bitrate) {
- ices_log_debug ("Bit rate of first frame (%d) doesn't match second frame (%d), assuming VBR",
- mh.bitrate, next_header.bitrate);
- source->bitrate = 0;
- }
- break;
- }
- }
- if (!rc)
- ices_log_debug ("Bad frame at offset %d", source->bytes_read + mp3_data->pos);
- }
- mp3_data->pos++;
- off++;
- }
- } while (!rc);
-
- if (!rc) {
- ices_log_error ("Couldn't find synch");
- return -1;
- }
-
- if (off)
- ices_log_debug("Skipped %d bytes of garbage before MP3", off);
-
- /* adjust file size for short frames */
- mp3_trim_file (source, &mh);
-
- if (source->bitrate)
- ices_log_debug ("%s layer %s, %d kbps, %d Hz, %s", version_names[mh.version],
- layer_names[mh.layer - 1], mh.bitrate, mh.samplerate, mode_names[mh.mode]);
- else
- ices_log_debug ("%s layer %s, VBR, %d Hz, %s", version_names[mh.version],
- layer_names[mh.layer - 1], mh.samplerate, mode_names[mh.mode]);
- ices_log_debug ("Ext: %d\tMode_Ext: %d\tCopyright: %d\tOriginal: %d", mh.extension,
- mh.mode_ext, mh.copyright, mh.original);
- ices_log_debug ("Error Protection: %d\tEmphasis: %d\tPadding: %d", mh.error_protection,
- mh.emphasis, mh.padding);
-
- return 0;
-}
-
-int
-ices_mp3_open (input_stream_t* self, const char* buf, size_t len)
-{
- ices_mp3_in_t* mp3_data;
- int rc;
-
- if (!len)
- return -1;
-
- if (! ((mp3_data = (ices_mp3_in_t*) malloc (sizeof (ices_mp3_in_t))) &&
- (mp3_data->buf = (unsigned char*) malloc (len))))
- {
- ices_log_error ("Malloc failed in ices_mp3_open");
- return -1;
- }
-
- memcpy (mp3_data->buf, buf, len);
- mp3_data->len = len;
- mp3_data->pos = 0;
-
- self->type = ICES_INPUT_MP3;
- self->data = mp3_data;
-
- self->read = ices_mp3_read;
-#ifdef HAVE_LIBLAME
- self->readpcm = ices_mp3_readpcm;
-#else
- self->readpcm = NULL;
-#endif
- self->close = ices_mp3_close;
-
- ices_id3v1_parse (self);
-
- if ((rc = ices_mp3_parse (self))) {
- free (mp3_data->buf);
- free (mp3_data);
- return rc;
- }
-
- return 0;
-}
-
-/* input_stream_t wrapper for fread */
-static ssize_t
-ices_mp3_read (input_stream_t* self, void* buf, size_t len)
-{
- ices_mp3_in_t* mp3_data = self->data;
- int remaining;
- int rlen = 0;
-
- if (mp3_data->buf) {
- remaining = mp3_data->len - mp3_data->pos;
- if (remaining > len) {
- rlen = len;
- memcpy (buf, mp3_data->buf + mp3_data->pos, len);
- mp3_data->pos += len;
- } else {
- rlen = remaining;
- memcpy (buf, mp3_data->buf + mp3_data->pos, remaining);
- free (mp3_data->buf);
- mp3_data->buf = NULL;
- }
- } else {
- /* we don't just use EOF because we'd like to avoid the ID3 tag */
- if (self->filesize && self->filesize - self->bytes_read < len)
- len = self->filesize - self->bytes_read;
- if (len)
- rlen = read (self->fd, buf, len);
- }
-
- self->bytes_read += rlen;
-
- return rlen;
-}
-
-#ifdef HAVE_LIBLAME
-static ssize_t
-ices_mp3_readpcm (input_stream_t* self, size_t len, int16_t* left,
- int16_t* right)
-{
- unsigned char buf[MP3_BUFFER_SIZE];
- ssize_t rlen;
- int nsamples = 0;
-
- while (! nsamples) {
- if ((rlen = self->read (self, buf, sizeof (buf))) <= 0)
- return rlen;
-
- nsamples = ices_reencode_decode (buf, rlen, len, left, right);
- }
-
- return nsamples;
-}
-#endif
-
-static int
-ices_mp3_close (input_stream_t* self)
-{
- ices_mp3_in_t* mp3_data = (ices_mp3_in_t*) self->data;
-
- ices_util_free (mp3_data->buf);
- free (self->data);
-
- return close (self->fd);
-}
-
-/* trim short frame from end of file if necessary */
-static void mp3_trim_file (input_stream_t* self, mp3_header_t* header) {
- char buf[MP3_BUFFER_SIZE];
- mp3_header_t match;
- off_t cur, start, end;
- int framelen;
- int rlen, len;
-
- if (! self->filesize)
- return;
-
- cur = lseek (self->fd, 0, SEEK_CUR);
- end = self->filesize;
- while (end > cur) {
- start = end - sizeof(buf);
- if (start < cur)
- start = cur;
-
- /* load buffer */
- lseek (self->fd, start, SEEK_SET);
- for (len = 0; start + len < end; len += rlen) {
- if ((rlen = read (self->fd, buf + len, end - (start + len))) <= 0) {
- ices_log_debug ("Error reading MP3 while trimming end");
- lseek (self->fd, cur, SEEK_SET);
- return;
- }
- }
- end = start;
-
- /* search buffer backwards looking for sync */
- for (len -= 4; len >= 0; len--) {
- if (mp3_parse_frame (buf + len, &match) && (framelen = mp3_frame_length (&match))
- && header->version == match.version && header->layer == match.layer
- && header->samplerate == match.samplerate
- && (!self->bitrate || self->bitrate == match.bitrate)) {
- if (start + len + framelen < self->filesize) {
- self->filesize = start + len + framelen;
- ices_log_debug ("Trimmed file to %d bytes", self->filesize);
- } else if (start + len + framelen > self->filesize) {
- ices_log_debug ("Trimmed short frame (%d bytes missing) at offset %d",
- (int)(start + len + framelen) - self->filesize, (int)start + len);
- self->filesize = start + len;
- }
-
- lseek (self->fd, cur, SEEK_SET);
- return;
- }
- }
- }
- lseek (self->fd, cur, SEEK_SET);
-}
-
-/* make sure source buffer has at least len bytes.
- * returns: 1: success, 0: EOF before len, -1: malloc error, -2: read error */
-static int mp3_fill_buffer (input_stream_t* self, size_t len) {
- ices_mp3_in_t* mp3_data = (ices_mp3_in_t*) self->data;
- char errbuf[1024];
- char* buffer;
- size_t buflen;
- ssize_t rlen;
- size_t needed;
-
- buflen = mp3_data->len - mp3_data->pos;
-
- if (mp3_data->buf && len < buflen)
- return 1;
-
- if (self->filesize && len > buflen + self->filesize - self->bytes_read)
- return 0;
-
- /* put off adjusting mp3_data->len until read succeeds. len indicates how much valid
- * data is in the buffer, not how much has been allocated. We don't need to track
- * that for free or even realloc, although in the odd case that we can't fill the
- * extra memory we may end up reallocing when we don't strictly have to. */
- if (!mp3_data->buf) {
- needed = len;
- if (!(mp3_data->buf = malloc(needed)))
- return -1;
- mp3_data->pos = 0;
- mp3_data->len = 0;
- } else {
- needed = len - buflen;
- if (!(buffer = realloc(mp3_data->buf, mp3_data->len + needed)))
- return -1;
- mp3_data->buf = buffer;
- }
-
- while (needed && (rlen = read(self->fd, mp3_data->buf + mp3_data->len, needed)) > 0) {
- mp3_data->len += rlen;
- self->bytes_read += rlen;
- needed -= rlen;
- }
-
- if (!needed)
- return 1;
-
- if (!rlen)
- return 0;
-
- ices_log_error ("Error filling read buffer: %s",
- ices_util_strerror (errno, errbuf, sizeof (errbuf)));
- return -1;
-}
-
-static int mp3_parse_frame(const unsigned char* buf, mp3_header_t* header) {
- int bitrate_idx, samplerate_idx;
-
- if (((buf[0] << 4) | ((buf[1] >> 4) & 0xE)) != 0xFFE)
- return 0;
-
- switch ((buf[1] >> 3 & 0x3)) {
- case 3:
- header->version = 0;
- break;
- case 2:
- header->version = 1;
- break;
- case 0:
- header->version = 2;
- break;
- default:
- return 0;
- }
-
- bitrate_idx = (buf[2] >> 4) & 0xF;
- samplerate_idx = (buf[2] >> 2) & 0x3;
- header->mode = (buf[3] >> 6) & 0x3;
- header->layer = 4 - ((buf[1] >> 1) & 0x3);
- header->emphasis = (buf[3]) & 0x3;
-
- if (bitrate_idx == 0xF || samplerate_idx == 0x3
- || header->layer == 4 || header->emphasis == 2)
- return 0;
-
- header->error_protection = !(buf[1] & 0x1);
- if (header->version == 0)
- header->bitrate = bitrates[0][header->layer-1][bitrate_idx];
- else
- header->bitrate = bitrates[1][header->layer-1][bitrate_idx];
- header->samplerate = s_freq[header->version][samplerate_idx];
- header->padding = (buf[2] >> 1) & 0x01;
- header->extension = buf[2] & 0x01;
- header->mode_ext = (buf[3] >> 4) & 0x03;
- header->copyright = (buf[3] >> 3) & 0x01;
- header->original = (buf[3] >> 2) & 0x1;
- header->channels = (header->mode == MPG_MD_MONO) ? 1 : 2;
-
- return 1;
-}
-
-static int mp3_check_vbr(input_stream_t* source, mp3_header_t* header) {
- ices_mp3_in_t* mp3_data = (ices_mp3_in_t*) source->data;
- int offset;
-
- /* check for VBR tag */
- /* Tag offset varies (but FhG VBRI is always MPEG1 Layer III 160 kbps stereo) */
- if (header->version == 0) {
- if (header->channels == 1)
- offset = 21;
- else
- offset = 36;
- } else {
- if (header->channels == 1)
- offset = 13;
- else
- offset = 21;
- }
- /* only needed if frame length can't be calculated (free bitrate) */
- if (mp3_fill_buffer (source, offset + 4) <= 0) {
- ices_log_debug ("Error trying to read VBR tag");
- return -1;
- }
-
- offset += mp3_data->pos;
- if (!strncmp("VBRI", mp3_data->buf + offset, 4)
- || !strncmp("Xing", mp3_data->buf + offset, 4)) {
- ices_log_debug("VBR tag found");
- return 1;
- }
-
- return 0;
-}
-
-/* Calculate the expected length of the next frame, or return 0 if we don't know how */
-static size_t mp3_frame_length(mp3_header_t* header) {
- if (!header->bitrate)
- return 0;
-
- if (header->layer == 1) {
- return (12000 * header->bitrate / header->samplerate + header->padding) * 4;
- } else if (header->layer ==3 && header->version > 0) {
- return 72000 * header->bitrate / header->samplerate + header->padding;
- }
-
- return 144000 * header->bitrate / header->samplerate + header->padding;
-}
Copied: icecast/tags/ices0/ices-0_4/src/mp3.c (from rev 7407, icecast/trunk/ices0/src/mp3.c)
Deleted: icecast/tags/ices0/ices-0_4/src/mp3.h
===================================================================
--- icecast/trunk/ices0/src/mp3.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/mp3.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,22 +0,0 @@
-/* mp3.h
- * mp3 function declarations for ices
- * Copyright (c) 2001-3 Brendan Cully
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-/* Public function declarations */
-int ices_mp3_open (input_stream_t* self, const char* buf, size_t len);
Copied: icecast/tags/ices0/ices-0_4/src/mp3.h (from rev 7407, icecast/trunk/ices0/src/mp3.h)
Copied: icecast/tags/ices0/ices-0_4/src/playlist (from rev 7407, icecast/trunk/ices0/src/playlist)
Deleted: icecast/tags/ices0/ices-0_4/src/reencode.h
===================================================================
--- icecast/trunk/ices0/src/reencode.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/reencode.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,31 +0,0 @@
-/* reencode.h
- * - Function declarations for reencoding
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-/* Public function declarations */
-void ices_reencode_initialize (void);
-void ices_reencode_shutdown (void);
-void ices_reencode_reset (input_stream_t* source);
-int ices_reencode_decode (unsigned char* buf, size_t blen, size_t olen,
- int16_t* left, int16_t* right);
-int ices_reencode (ices_stream_t* stream, int nsamples, int16_t* left,
- int16_t* right, unsigned char *outbuf, int outlen);
-int ices_reencode_flush (ices_stream_t* stream, unsigned char *outbuf,
- int maxlen);
-
Copied: icecast/tags/ices0/ices-0_4/src/reencode.h (from rev 7407, icecast/trunk/ices0/src/reencode.h)
Deleted: icecast/tags/ices0/ices-0_4/src/setup.c
===================================================================
--- icecast/trunk/ices0/src/setup.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/setup.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,650 +0,0 @@
-/* setup.c
- * - Functions for initialization in ices
- * Copyright (c) 2000 Alexander Haväng
- * Copyright (c) 2002-4 Brendan Cully <brendan at xiph.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include "definitions.h"
-#include "metadata.h"
-
-/* Local function declarations */
-static void ices_setup_parse_options (ices_config_t *ices_config);
-static void ices_setup_parse_defaults (ices_config_t *ices_config);
-#ifdef HAVE_LIBXML
-static void ices_setup_parse_config_file (ices_config_t *ices_config, const char *configfile);
-#endif
-static void ices_setup_parse_command_line (ices_config_t *ices_config, char **argv, int argc);
-static void ices_setup_parse_command_line_for_new_configfile (ices_config_t *ices_config, char **argv, int argc);
-static void ices_setup_activate_libshout_changes (const ices_config_t *ices_config);
-static void ices_setup_usage (void);
-static void ices_setup_version (void);
-static void ices_setup_update_pidfile (int icespid);
-static void ices_setup_daemonize (void);
-static void ices_free_all (ices_config_t *ices_config);
-
-extern ices_config_t ices_config;
-
-/* Global function definitions */
-
-/* Top level initialization function for ices.
- * It will parse options, initialize modules,
- * and if requested, become a daemon. */
-void
-ices_setup_initialize (void)
-{
- ices_stream_t* stream;
- ices_plugin_t* plugin;
-
- shout_init();
-
- /* Setup signal handlers */
- ices_signals_setup ();
-
- /* Parse the options in the config file, and the command line */
- ices_setup_parse_options (&ices_config);
-
- if (ices_config.daemon)
- ices_setup_daemonize ();
-
- /* Open logfiles */
- ices_log_initialize ();
-
- /* Initialize the libshout structure */
- for (stream = ices_config.streams; stream; stream = stream->next) {
- if (!(stream->conn = shout_new ())) {
- ices_log ("Could not create shout interface");
- ices_setup_shutdown ();
- }
- }
-
- ices_setup_activate_libshout_changes (&ices_config);
-
- /* Initialize the playlist handler */
- ices_playlist_initialize ();
-
-#ifdef HAVE_LIBLAME
- /* Initialize liblame for reeencoding */
- ices_reencode_initialize ();
-
- while (ices_config.plugins && ices_config.plugins->init() < 0)
- ices_config.plugins = ices_config.plugins->next;
-
- for (plugin = ices_config.plugins; plugin->next; plugin = plugin->next)
- if (plugin->next->init() < 0)
- plugin->next = plugin->next->next;
-#endif
-
- ices_log_debug("Startup complete\n");
-}
-
-/* Top level ices shutdown function.
- * This is the _only_ way out of here */
-void
-ices_setup_shutdown (void)
-{
- ices_stream_t* stream;
- ices_plugin_t* plugin;
-
- /* Tell libshout to disconnect from server */
- for (stream = ices_config.streams; stream; stream = stream->next)
- if (stream->conn)
- shout_close (stream->conn);
-
-#ifdef HAVE_LIBLAME
- for (plugin = ices_config.plugins; plugin; plugin = plugin->next)
- plugin->shutdown();
-
- /* Order the reencoding engine to shutdown */
- ices_reencode_shutdown ();
-#endif
-
- /* Tell the playlist module to shutdown and cleanup */
- ices_playlist_shutdown ();
-
- /* Cleanup the cue file (the cue module has no init yet) */
- ices_cue_shutdown ();
-
- /* Make sure we're not leaving any memory allocated around when
- * we exit. This makes it easier to find memory leaks, and
- * some systems actually don't clean up that well */
- ices_free_all (&ices_config);
-
- /* Let the log and console know we went down ok */
- ices_log ("Ices Exiting...");
-
- /* Close logfiles */
- ices_log_shutdown ();
-
- shout_shutdown();
-
- /* Down and down we go... */
- exit (1);
-}
-
-/* Local function definitions */
-
-/* Top level option parsing function.
- * Sets of options object (ices_config), with:
- * - Hardcoded defaults
- * - Configfile settings
- * - Command line options */
-static void
-ices_setup_parse_options (ices_config_t *ices_config)
-{
- /* Get default values for the settings */
- ices_setup_parse_defaults (ices_config);
-
- /* Look for given configfile on the commandline */
- ices_setup_parse_command_line_for_new_configfile (ices_config, ices_util_get_argv(), ices_util_get_argc ());
-
-#ifdef HAVE_LIBXML
- /* Parse the configfile */
- ices_setup_parse_config_file (ices_config, ices_config->configfile);
-#endif
-
- /* Parse the commandline */
- ices_setup_parse_command_line (ices_config, ices_util_get_argv(), ices_util_get_argc());
-}
-
-/* Function for placing hardcoded defaults in the
- * options object (ices_config) */
-static void
-ices_setup_parse_defaults (ices_config_t *ices_config)
-{
- ices_config->configfile = ices_util_strdup (ICES_DEFAULT_CONFIGFILE);
- ices_config->daemon = ICES_DEFAULT_DAEMON;
- ices_config->base_directory = ices_util_strdup (ICES_DEFAULT_BASE_DIRECTORY);
- ices_config->verbose = ICES_DEFAULT_VERBOSE;
- ices_config->reencode = 0;
-
- ices_config->pm.playlist_file =
- ices_util_strdup (ICES_DEFAULT_PLAYLIST_FILE);
- ices_config->pm.module = ices_util_strdup (ICES_DEFAULT_MODULE);
- ices_config->pm.randomize = ICES_DEFAULT_RANDOMIZE_PLAYLIST;
- ices_config->pm.playlist_type = ICES_DEFAULT_PLAYLIST_TYPE;
-
- ices_config->streams = (ices_stream_t*) malloc (sizeof (ices_stream_t));
-
- ices_setup_parse_stream_defaults (ices_config->streams);
-}
-
-/* Place hardcoded defaults into an ices_stream_t object */
-void
-ices_setup_parse_stream_defaults (ices_stream_t* stream)
-{
- stream->conn = NULL;
- stream->host = ices_util_strdup (ICES_DEFAULT_HOST);
- stream->port = ICES_DEFAULT_PORT;
- stream->password = ices_util_strdup (ICES_DEFAULT_PASSWORD);
- stream->protocol = ICES_DEFAULT_PROTOCOL;
-
- stream->mount = ices_util_strdup (ICES_DEFAULT_MOUNT);
- stream->dumpfile = NULL;
-
- stream->name = ices_util_strdup (ICES_DEFAULT_NAME);
- stream->genre = ices_util_strdup (ICES_DEFAULT_GENRE);
- stream->description = ices_util_strdup (ICES_DEFAULT_DESCRIPTION);
- stream->url = ices_util_strdup (ICES_DEFAULT_URL);
- stream->ispublic = ICES_DEFAULT_ISPUBLIC;
-
- stream->bitrate = ICES_DEFAULT_BITRATE;
- stream->reencode = ICES_DEFAULT_REENCODE;
- stream->out_numchannels = -1;
- stream->out_samplerate = -1;
-
- stream->encoder_state = NULL;
- stream->connect_delay = 0;
-
- stream->next = NULL;
-}
-
-/* Frees ices_stream_t data (but not the object itself) */
-static void
-ices_setup_free_stream (ices_stream_t* stream)
-{
- if (stream->conn)
- shout_free (stream->conn);
- ices_util_free (stream->host);
- ices_util_free (stream->password);
-
- ices_util_free (stream->mount);
- ices_util_free (stream->dumpfile);
-
- ices_util_free (stream->name);
- ices_util_free (stream->genre);
- ices_util_free (stream->description);
- ices_util_free (stream->url);
-}
-
-/* Function to free() all allocated memory when ices shuts down. */
-static void
-ices_free_all (ices_config_t *ices_config)
-{
- ices_stream_t *stream, *next;
-
- ices_util_free (ices_config->configfile);
- ices_util_free (ices_config->base_directory);
-
- ices_util_free (ices_config->pm.playlist_file);
- ices_util_free (ices_config->pm.module);
-
- for (stream = ices_config->streams; stream; stream = next)
- {
- next = stream->next;
-
- ices_setup_free_stream (stream);
- ices_util_free (stream);
- }
-}
-
-#ifdef HAVE_LIBXML
-/* Tell the xml module to parse the config file. */
-static void
-ices_setup_parse_config_file (ices_config_t *ices_config, const char *configfile)
-{
- char namespace[1024];
- const char *realname = NULL;
- int ret;
-
- if (ices_util_verify_file (configfile)) {
- realname = configfile;
- } else {
- sprintf (namespace, "%s/%s", ICES_ETCDIR, configfile);
- if (ices_util_verify_file (namespace))
- realname = &namespace[0];
- }
-
- if (realname) {
- ret = ices_xml_parse_config_file (ices_config, realname);
-
- if (ret == -1) {
- /* ret == -1 means we have no libxml support */
- ices_log_debug ("%s", ices_log_get_error ());
- } else if (ret == 0) {
- /* A real error */
- ices_log ("%s", ices_log_get_error ());
- }
- }
-}
-#endif
-
-/* This function looks through the command line options for a new
- * configfile. */
-static void
-ices_setup_parse_command_line_for_new_configfile (ices_config_t *ices_config, char **argv, int argc)
-{
- int arg;
- char *s;
-
- arg = 1;
-
- while (arg < argc) {
- s = argv[arg];
-
- if (s[0] == '-') {
- switch (s[1]) {
- case 'c':
- arg++;
- if (ices_config->configfile)
- ices_util_free (ices_config->configfile);
- ices_config->configfile = ices_util_strdup (argv[arg]);
-#ifndef HAVE_LIBXML
- fprintf (stderr, "Cannot use config file (no XML support).\n");
- ices_setup_shutdown ();
-#endif
- break;
- }
- }
- arg++;
- }
-}
-
-/* This function parses the command line options */
-static void
-ices_setup_parse_command_line (ices_config_t *ices_config, char **argv,
- int argc)
-{
- int arg;
- char *s;
- ices_stream_t* stream = ices_config->streams;
- /* each -m option creates a new stream, subsequent options are applied
- * to it. */
- int nstreams = 1;
-
- arg = 1;
-
- while (arg < argc) {
- s = argv[arg];
-
- if (s[0] == '-') {
- if ((strchr ("BRrsVv", s[1]) == NULL) && arg >= (argc - 1)) {
- fprintf (stderr, "Option %c requires an argument!\n", s[1]);
- ices_setup_usage ();
- ices_setup_shutdown ();
- return;
- }
-
- switch (s[1]) {
- case 'B':
- ices_config->daemon = 1;
- break;
- case 'b':
- arg++;
- stream->bitrate = atoi (argv[arg]);
- break;
- case 'C':
- arg++;
- if (atoi(argv[arg]) > 0)
- /* TODO: stack plugins */
- ices_config->plugins = crossfade_plugin(atoi(argv[arg]));
- case 'c':
- arg++;
- break;
- case 'd':
- arg++;
- ices_util_free (stream->description);
- stream->description = ices_util_strdup (argv[arg]);
- break;
- case 'D':
- arg++;
- ices_util_free (ices_config->base_directory);
- ices_config->base_directory = ices_util_strdup (argv[arg]);
- break;
- case 'F':
- arg++;
- ices_util_free (ices_config->pm.playlist_file);
- ices_config->pm.playlist_file = ices_util_strdup (argv[arg]);
- break;
- case 'f':
- arg++;
- ices_util_free (stream->dumpfile);
- stream->dumpfile = ices_util_strdup (argv[arg]);
- break;
- case 'g':
- arg++;
- ices_util_free (stream->genre);
- stream->genre = ices_util_strdup (argv[arg]);
- break;
- case 'h':
- arg++;
- ices_util_free (stream->host);
- stream->host = ices_util_strdup (argv[arg]);
- break;
- case 'H':
- arg++;
- stream->out_samplerate = atoi (argv[arg]);
- break;
- case 'M':
- arg++;
- ices_util_free (ices_config->pm.module);
- ices_config->pm.module = ices_util_strdup (argv[arg]);
- break;
- case 'm':
- arg++;
- if (nstreams > 1) {
- stream->next =
- (ices_stream_t*) malloc (sizeof (ices_stream_t));
- stream = stream->next;
- ices_setup_parse_stream_defaults (stream);
- }
- ices_util_free (stream->mount);
- stream->mount = ices_util_strdup (argv[arg]);
- nstreams++;
- break;
- case 'N':
- arg++;
- stream->out_numchannels = atoi (argv[arg]);
- break;
- case 'n':
- arg++;
- ices_util_free (stream->name);
- stream->name = ices_util_strdup (argv[arg]);
- break;
- case 'P':
- arg++;
- ices_util_free (stream->password);
- stream->password = ices_util_strdup (argv[arg]);
- break;
- case 'p':
- arg++;
- stream->port = atoi (argv[arg]);
- break;
- case 'R':
-#ifdef HAVE_LIBLAME
- stream->reencode = 1;
-#else
- fprintf (stderr, "This ices wasn't compiled with reencoding support\n");
- ices_setup_shutdown ();
-#endif
- break;
- case 'r':
- ices_config->pm.randomize = 1;
- break;
- case 'S':
- arg++;
- if (strcmp (argv[arg], "python") == 0)
- ices_config->pm.playlist_type = ices_playlist_python_e;
- else if (strcmp (argv[arg], "perl") == 0)
- ices_config->pm.playlist_type = ices_playlist_perl_e;
- else
- ices_config->pm.playlist_type = ices_playlist_builtin_e;
- break;
- case 's':
- stream->ispublic = 0;
- break;
- case 't':
- arg++;
- if (!strcmp (argv[arg], "http"))
- stream->protocol = http_protocol_e;
- else if (!strcmp (argv[arg], "xaudiocast"))
- stream->protocol = xaudiocast_protocol_e;
- else if (!strcmp (argv[arg], "icy"))
- stream->protocol = icy_protocol_e;
- else {
- fprintf (stderr, "Unknown protocol %s. Use 'http', 'xaudiocast' or 'icy'.\n", argv[arg]);
- ices_setup_shutdown ();
- }
- break;
- case 'u':
- arg++;
- ices_util_free (stream->url);
- stream->url = ices_util_strdup (argv[arg]);
- break;
- case 'V':
- ices_setup_version ();
- exit (0);
- case 'v':
- ices_config->verbose = 1;
- break;
- default:
- ices_setup_usage ();
- break;
- }
- }
- arg++;
- }
-}
-
-/* This function takes all the new configuration and copies it to the
- libshout object. */
-static void
-ices_setup_activate_libshout_changes (const ices_config_t *ices_config)
-{
- ices_stream_t* stream;
- shout_t* conn;
- int streamno = 0;
- char useragent[64];
- char bitrate[8];
-
- snprintf(useragent, sizeof(useragent), "ices/" VERSION " libshout/%s",
- shout_version(NULL, NULL, NULL));
-
- for (stream = ices_config->streams; stream; stream = stream->next) {
- conn = stream->conn;
-
- shout_set_host (conn, stream->host);
- shout_set_port (conn, stream->port);
- shout_set_password (conn, stream->password);
- shout_set_format (conn, SHOUT_FORMAT_MP3);
- if (stream->protocol == icy_protocol_e)
- shout_set_protocol(conn, SHOUT_PROTOCOL_ICY);
- else if (stream->protocol == http_protocol_e)
- shout_set_protocol(conn, SHOUT_PROTOCOL_HTTP);
- else
- shout_set_protocol(conn, SHOUT_PROTOCOL_XAUDIOCAST);
- if (stream->dumpfile)
- shout_set_dumpfile(conn, stream->dumpfile);
- shout_set_name (conn, stream->name);
- shout_set_url (conn, stream->url);
- shout_set_genre (conn, stream->genre);
- shout_set_description (conn, stream->description);
-
- snprintf(bitrate, sizeof(bitrate), "%d", stream->bitrate);
- shout_set_audio_info (conn, SHOUT_AI_BITRATE, bitrate);
-
- shout_set_public (conn, stream->ispublic);
- shout_set_mount (conn, stream->mount);
- shout_set_agent (conn, useragent);
-
- ices_log_debug ("Sending following information to libshout:");
- ices_log_debug ("Stream: %d", streamno);
- ices_log_debug ("Host: %s:%d (protocol: %s)", shout_get_host (conn),
- shout_get_port (conn),
- stream->protocol == icy_protocol_e ? "icy" :
- stream->protocol == http_protocol_e ? "http" : "xaudiocast");
- ices_log_debug ("Mount: %s, Password: %s", shout_get_mount (conn), shout_get_password (conn));
- ices_log_debug ("Name: %s\tURL: %s", shout_get_name (conn), shout_get_url(conn));
- ices_log_debug ("Genre: %s\tDesc: %s", shout_get_genre (conn),
- shout_get_description (conn));
- ices_log_debug ("Bitrate: %s\tPublic: %d", shout_get_audio_info (conn, SHOUT_AI_BITRATE),
- shout_get_public (conn));
- ices_log_debug ("Dump file: %s", ices_util_nullcheck (shout_get_dumpfile (conn)));
- streamno++;
- }
-}
-
-/* Display all command line options for ices */
-static void
-ices_setup_usage (void)
-{
- printf ("This is ices " VERSION "\n"
- "ices <options>\n"
- "Options:\n"
- "\t-B (Background (daemon mode))\n"
- "\t-b <stream bitrate>\n"
- "\t-C <crossfade seconds>\n");
- printf ("\t-c <configfile>\n");
- printf ("\t-D <base directory>\n");
- printf ("\t-d <stream description>\n");
- printf ("\t-f <dumpfile on server>\n");
- printf ("\t-F <playlist>\n");
- printf ("\t-g <stream genre>\n");
- printf ("\t-h <host>\n");
- printf ("\t-i (use icy headers)\n");
- printf ("\t-M <interpreter module>\n");
- printf ("\t-m <mountpoint>\n");
- printf ("\t-n <stream name>\n");
- printf ("\t-p <port>\n");
- printf ("\t-P <password>\n");
- printf ("\t-R (activate reencoding)\n");
- printf ("\t-r (randomize playlist)\n");
- printf ("\t-s (private stream)\n");
- printf ("\t-S <perl|python|builtin>\n");
- printf ("\t-t <http|xaudiocast|icy>\n");
- printf ("\t-u <stream url>\n");
- printf ("\t-v (verbose output)\n");
- printf ("\t-H <reencoded sample rate>\n");
- printf ("\t-N <reencoded number of channels>\n");
-}
-
-/* display version information */
-static void
-ices_setup_version (void)
-{
- printf ("ices " VERSION "\nFeatures: "
-#ifdef HAVE_LIBLAME
- "LAME "
-#endif
-#ifdef HAVE_LIBPERL
- "Perl "
-#endif
-#ifdef HAVE_LIBPYTHON
- "python "
-#endif
-#ifdef HAVE_LIBXML
- "libxml "
-#endif
-#ifdef HAVE_LIBVORBISFILE
- "Vorbis "
-#endif
- "\n"
- "System configuration file: " ICES_ETCDIR "/ices.conf\n"
-#if defined (HAVE_LIBPERL) || defined (HAVE_LIBPYTHON)
- "Playlist module directory: " ICES_MODULEDIR "\n"
-#endif
- );
-}
-
-/* Put ices in the background, as a daemon */
-static void
-ices_setup_daemonize (void)
-{
- int icespid = fork ();
-
- if (icespid == -1) {
- ices_log ("ERROR: Cannot fork(), that means no daemon, sorry!");
- return;
- }
-
- if (icespid != 0) {
- /* Update the pidfile (so external applications know what pid
- ices is running with. */
- printf ("Into the land of the dreaded daemons we go... (pid: %d)\n", icespid);
- ices_setup_shutdown ();
- }
-#ifdef HAVE_SETSID
- setsid ();
-#endif
-
- ices_log_daemonize ();
- ices_setup_update_pidfile (getpid());
-}
-
-/* Update a file called ices.pid with the given process id */
-static void
-ices_setup_update_pidfile (int icespid)
-{
- char buf[1024];
- FILE* pidfd;
-
- if (! ices_config.base_directory) {
- ices_log_error ("Base directory is invalid");
- return;
- }
-
- snprintf (buf, sizeof (buf), "%s/ices.pid", ices_config.base_directory);
-
- pidfd = ices_util_fopen_for_writing (buf);
-
- if (pidfd) {
- fprintf (pidfd, "%d", icespid);
- ices_util_fclose (pidfd);
- }
-}
-
-
Copied: icecast/tags/ices0/ices-0_4/src/setup.c (from rev 7428, icecast/trunk/ices0/src/setup.c)
Deleted: icecast/tags/ices0/ices-0_4/src/setup.h
===================================================================
--- icecast/trunk/ices0/src/setup.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/setup.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,26 +0,0 @@
-/* setup.h
- * - initialization function declarations for ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-/* Public function declarations */
-void ices_setup_initialize (void);
-void ices_setup_shutdown (void);
-
-/* exported for the config parser */
-void ices_setup_parse_stream_defaults (ices_stream_t*);
Copied: icecast/tags/ices0/ices-0_4/src/setup.h (from rev 7407, icecast/trunk/ices0/src/setup.h)
Deleted: icecast/tags/ices0/ices-0_4/src/signals.c
===================================================================
--- icecast/trunk/ices0/src/signals.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/signals.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,116 +0,0 @@
-/* signals.c
- * - Functions for signal handling in ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include "definitions.h"
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-
-#ifdef HAVE_SYS_SIGNAL_H
-#include <sys/signal.h>
-#endif
-
-/* Private function declarations */
-static RETSIGTYPE signals_child (const int sig);
-static RETSIGTYPE signals_int (const int sig);
-static RETSIGTYPE signals_hup (const int sig);
-static RETSIGTYPE signals_usr1 (const int sig);
-
-/* Global function definitions */
-
-/* Setup signal handlers for some signals that we don't want
- * delivered to icecast, and some that we want to handle in
- * a certain way, like SIGINT to cleanup and exit, and hup
- * to close and reopen logfiles */
-void
-ices_signals_setup (void)
-{
-#ifndef _WIN32
- struct sigaction sa;
-
- sigemptyset (&sa.sa_mask);
- sa.sa_flags = 0;
-
- sa.sa_handler = SIG_IGN;
- sigaction (SIGPIPE, &sa, NULL);
- sigaction (SIGIO, &sa, NULL);
- sigaction (SIGALRM, &sa, NULL);
-
- sa.sa_handler = signals_int;
- sigaction (SIGINT, &sa, NULL);
- sigaction (SIGTERM, &sa, NULL);
-
-#ifdef SA_RESTART
- sa.sa_flags = SA_RESTART;
-#endif
- sa.sa_handler = signals_child;
- sigaction (SIGCHLD, &sa, NULL);
-
- sa.sa_handler = signals_hup;
- sigaction (SIGHUP, &sa, NULL);
-
- sa.sa_handler = signals_usr1;
- sigaction (SIGUSR1, &sa, NULL);
-}
-
-/* Guess we fork()ed, let's take care of the dead process */
-static RETSIGTYPE
-signals_child (const int sig)
-{
- int stat;
-
- wait (&stat);
-}
-
-/* SIGINT, ok, let's be nice and just drop dead */
-static RETSIGTYPE
-signals_int (const int sig)
-{
- ices_log_debug ("Caught signal, shutting down...");
- ices_setup_shutdown ();
-}
-
-/* SIGHUP caught, let's cycle logfiles and try to reload the playlist module */
-static RETSIGTYPE
-signals_hup (const int sig)
-{
- ices_log_debug ("Caught SIGHUP, cycling logfiles and reloading playlist...");
- ices_log_reopen_logfile ();
- ices_playlist_reload ();
-}
-
-/* I'm not sure whether I'll keep this... */
-static RETSIGTYPE
-signals_usr1 (const int sig)
-{
- ices_log_debug ("Caught SIGUSR1, skipping to next track...");
- ices_stream_next ();
-#endif
-}
-
Copied: icecast/tags/ices0/ices-0_4/src/signals.c (from rev 7407, icecast/trunk/ices0/src/signals.c)
Deleted: icecast/tags/ices0/ices-0_4/src/signals.h
===================================================================
--- icecast/trunk/ices0/src/signals.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/signals.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,22 +0,0 @@
-/* signal.h
- * - Signal handling function declarations for ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-/* Public function declarations */
-void ices_signals_setup (void);
Copied: icecast/tags/ices0/ices-0_4/src/signals.h (from rev 7407, icecast/trunk/ices0/src/signals.h)
Deleted: icecast/tags/ices0/ices-0_4/src/stream.c
===================================================================
--- icecast/trunk/ices0/src/stream.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/stream.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,434 +0,0 @@
-/* stream.c
- * - Functions for streaming in ices
- * Copyright (c) 2000 Alexander Haväng
- * Copyright (c) 2001-4 Brendan Cully <brendan at xiph.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
-
-#include "definitions.h"
-#include "metadata.h"
-
-#ifdef HAVE_LIBVORBISFILE
-#include "in_vorbis.h"
-#endif
-
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
-
-#define INPUT_BUFSIZ 4096
-#define OUTPUT_BUFSIZ 32768
-/* sleep this long in ms when every stream has errors */
-#define ERROR_DELAY 999
-
-typedef struct {
- char* data;
- size_t len;
-} buffer_t;
-
-static volatile int finish_send = 0;
-
-/* Private function declarations */
-static int stream_connect (ices_stream_t* stream);
-static int stream_send (ices_config_t* config, input_stream_t* source);
-static int stream_send_data (ices_stream_t* stream, unsigned char* buf,
- size_t len);
-static int stream_open_source (input_stream_t* source);
-static int stream_needs_reencoding (input_stream_t* source, ices_stream_t* stream);
-
-/* Public function definitions */
-
-/* Top level streaming function, called once from main() to
- * connect to server and start streaming */
-void
-ices_stream_loop (ices_config_t* config)
-{
- int consecutive_errors = 0;
- input_stream_t source;
- ices_stream_t* stream;
- int rc;
-
- while (1) {
- source.path = ices_playlist_get_next ();
-
- if (!(source.path && source.path[0])) {
- ices_log ("Playlist file name is empty, shutting down.");
- ices_setup_shutdown ();
- }
-
- ices_cue_set_lineno (ices_playlist_get_current_lineno ());
-
- ices_metadata_set (NULL, NULL);
- ices_metadata_set_file (source.path);
-
- /* This stops ices from entering a loop with 10-20 lines of output per
- second. Usually caused by a playlist handler that produces only
- invalid file names. */
- if (consecutive_errors > 10) {
- ices_log ("Exiting after 10 consecutive errors.");
- ices_util_free (source.path);
- ices_setup_shutdown ();
- }
-
- if (stream_open_source (&source) < 0) {
- ices_log ("Error opening %s: %s", source.path, ices_log_get_error ());
- ices_util_free (source.path);
- consecutive_errors++;
- continue;
- }
-
- if (!source.read)
- for (stream = config->streams; stream; stream = stream->next)
- if (!stream->reencode) {
- ices_log ("Cannot play %s without reencoding", source.path);
- source.close (&source);
- ices_util_free (source.path);
- consecutive_errors++;
- continue;
- }
-
- rc = stream_send (config, &source);
- source.close (&source);
-
- /* If something goes on while transfering, we just go on */
- if (rc < 0) {
- ices_log ("Encountered error while transfering %s: %s", source.path, ices_log_get_error ());
-
- consecutive_errors++;
-
- ices_util_free (source.path);
- continue;
- } else {
- /* Reset the consecutive error counter */
- consecutive_errors = 0;
- }
-
- ices_util_free (source.path);
- }
-}
-
-/* set a flag to tell stream_send to finish early */
-void
-ices_stream_next (void)
-{
- finish_send = 1;
-}
-
-/* This function is called to stream a single file */
-static int
-stream_send (ices_config_t* config, input_stream_t* source)
-{
- ices_stream_t* stream;
- unsigned char ibuf[INPUT_BUFSIZ];
- char namespace[1024];
- ssize_t len;
- ssize_t olen;
- int samples;
- int rc;
- int do_sleep;
-#ifdef HAVE_LIBLAME
- int decode = 0;
- buffer_t obuf;
- ices_plugin_t *plugin;
- /* worst case decode: 22050 Hz at 8kbs = 44.1 samples/byte */
- static int16_t left[INPUT_BUFSIZ * 45];
- static int16_t right[INPUT_BUFSIZ * 45];
- static int16_t* rightp;
-#endif
-
-#ifdef HAVE_LIBLAME
- obuf.data = NULL;
- obuf.len = 0;
-
- if (config->reencode) {
- ices_reencode_reset (source);
- if (config->plugins) {
- decode = 1;
- for (plugin = config->plugins; plugin; plugin = plugin->next)
- plugin->new_track(source);
- } else
- for (stream = config->streams; stream; stream = stream->next)
- if (stream->reencode && stream_needs_reencoding (source, stream)) {
- decode = 1;
- break;
- }
- }
-
- if (decode) {
- obuf.len = OUTPUT_BUFSIZ;
- if (!(obuf.data = malloc(OUTPUT_BUFSIZ))) {
- ices_log_error("Error allocating encode buffer");
- return -1;
- }
- }
-#endif
-
- for (stream = config->streams; stream; stream = stream->next)
- stream->errs = 0;
-
- ices_log ("Playing %s", source->path);
-
- ices_metadata_update (0);
-
- finish_send = 0;
- while (! finish_send) {
- len = samples = 0;
- /* fetch input buffer */
- if (source->read) {
- len = source->read (source, ibuf, sizeof (ibuf));
-#ifdef HAVE_LIBLAME
- if (decode)
- samples = ices_reencode_decode (ibuf, len, sizeof (left), left, right);
- } else if (source->readpcm) {
- len = samples = source->readpcm (source, sizeof (left), left, right);
-#endif
- }
-
-#ifdef HAVE_LIBLAME
- /* run output through plugin */
- for (plugin = config->plugins; plugin; plugin = plugin->next)
- if (samples)
- samples = plugin->process(samples, left, right);
-#endif
-
- if (len == 0) {
- ices_log_debug ("Done sending");
- break;
- }
- if (len < 0) {
- ices_log_error ("Read error: %s", ices_util_strerror (errno, namespace, 1024));
- goto err;
- }
-
- do_sleep = 1;
- while (do_sleep) {
- rc = olen = 0;
- for (stream = config->streams; stream; stream = stream->next) {
- /* don't reencode if the source is MP3 and the same bitrate */
-#ifdef HAVE_LIBLAME
- if (stream->reencode && (config->plugins || stream_needs_reencoding (source, stream))) {
- if (samples > 0) {
- /* for some reason we have to manually duplicate right from left to get
- * LAME to output stereo from a mono source */
- if (source->channels == 1 && stream->out_numchannels != 1)
- rightp = left;
- else
- rightp = right;
- if (obuf.len < (unsigned int) (7200 + samples + samples / 4)) {
- char *tmpbuf;
-
- /* pessimistic estimate from lame.h */
- obuf.len = 7200 + 5 * samples / 2;
- if (!(tmpbuf = realloc(obuf.data, obuf.len))) {
- ices_log_error ("Error growing output buffer, aborting track");
- goto err;
- }
- obuf.data = tmpbuf;
- ices_log_debug ("Grew output buffer to %d bytes", obuf.len);
- }
- if ((olen = ices_reencode (stream, samples, left, rightp, obuf.data,
- obuf.len)) < -1) {
- ices_log_error ("Reencoding error, aborting track");
- goto err;
- } else if (olen == -1) {
- char *tmpbuf;
-
- if ((tmpbuf = realloc(obuf.data, obuf.len + OUTPUT_BUFSIZ))) {
- obuf.data = tmpbuf;
- obuf.len += OUTPUT_BUFSIZ;
- ices_log_debug ("Grew output buffer to %d bytes", obuf.len);
- } else
- ices_log_debug ("%d byte output buffer is too small", obuf.len);
- } else if (olen > 0) {
- rc = stream_send_data (stream, obuf.data, olen);
- }
- }
- } else
-#endif
- rc = stream_send_data (stream, ibuf, len);
-
- if (rc < 0) {
- if (stream->errs > 10) {
- ices_log ("Too many stream errors, giving up");
- ices_setup_shutdown ();
- }
- ices_log ("Error during send: %s", ices_log_get_error ());
- } else {
- do_sleep = 0;
- }
- /* this is so if we have errors on every stream we pause before
- * attempting to reconnect */
- if (do_sleep) {
- struct timeval delay;
- delay.tv_sec = ERROR_DELAY / 1000;
- delay.tv_usec = ERROR_DELAY % 1000 * 1000;
-
- select (1, NULL, NULL, NULL, &delay);
- }
- }
- }
- ices_cue_update (source);
- }
-
-#ifdef HAVE_LIBLAME
- for (stream = config->streams; stream; stream = stream->next)
- if (stream->reencode && stream_needs_reencoding (source, stream)) {
- len = ices_reencode_flush (stream, obuf.data, obuf.len);
- if (len > 0)
- rc = stream_send_data (stream, obuf.data, len);
- }
-
- if (obuf.data)
- free(obuf.data);
-#endif
-
- return 0;
-
-err:
-#ifdef HAVE_LIBLAME
- if (obuf.data)
- free(obuf.data);
-#endif
- return -1;
-}
-
-/* open up path, figure out what kind of input it is, and set up source */
-static int
-stream_open_source (input_stream_t* source)
-{
- char buf[INPUT_BUFSIZ];
- size_t len;
- int fd;
- int rc;
-
- source->filesize = 0;
- source->bytes_read = 0;
- source->channels = 2;
-
- if (source->path[0] == '-' && source->path[1] == '\0') {
- ices_log_debug("Reading audio from stdin");
- fd = 0;
- } else if ((fd = open (source->path, O_RDONLY)) < 0) {
- ices_util_strerror (errno, buf, sizeof (buf));
- ices_log_error ("Error opening: %s", buf);
-
- return -1;
- }
-
- source->fd = fd;
-
- if ((rc = lseek (fd, 0, SEEK_END)) >= 0) {
- source->filesize = rc;
- lseek (fd, 0, SEEK_SET);
- }
-
- if ((len = read (fd, buf, sizeof (buf))) <= 0) {
- ices_util_strerror (errno, buf, sizeof (buf));
- ices_log_error ("Error reading header: %s", source->path, buf);
-
- close (fd);
- return -1;
- }
-
- if (!(rc = ices_mp3_open (source, buf, len)))
- return 0;
- if (rc < 0) {
- close (fd);
- return -1;
- }
-
-#ifdef HAVE_LIBVORBISFILE
- if (!(rc = ices_vorbis_open (source, buf, len)))
- return 0;
-#endif
-
- close (fd);
- return -1;
-}
-
-/* wrapper for shout_send_data, shout_sleep with error handling */
-static int
-stream_send_data (ices_stream_t* stream, unsigned char* buf, size_t len)
-{
- if (shout_get_connected (stream->conn) != SHOUTERR_CONNECTED) {
- stream_connect (stream);
- if (shout_get_connected (stream->conn) == SHOUTERR_CONNECTED)
- ices_metadata_update (1);
- else
- return -1;
- }
-
- shout_sync(stream->conn);
- if (shout_send (stream->conn, buf, len) == SHOUTERR_SUCCESS) {
- stream->errs = 0;
-
- return 0;
- }
-
- ices_log_error ("Libshout reported send error, disconnecting: %s",
- shout_get_error (stream->conn));
- shout_close (stream->conn);
- stream->errs++;
-
- return -1;
-}
-
-static int
-stream_connect (ices_stream_t* stream)
-{
- time_t now = time(NULL);
- const char* mount = shout_get_mount (stream->conn);
-
- if (stream->connect_delay > now)
- return -1;
-
- if (shout_open (stream->conn) != SHOUTERR_SUCCESS) {
- ices_log_error ("Mount failed on http://%s:%d%s%s, error: %s",
- shout_get_host (stream->conn), shout_get_port (stream->conn),
- (mount && mount[0] == '/') ? "" : "/", ices_util_nullcheck (mount),
- shout_get_error (stream->conn));
- stream->connect_delay = now + 1;
- stream->errs++;
-
- return -1;
- }
-
- ices_log ("Mounted on http://%s:%d%s%s", shout_get_host (stream->conn),
- shout_get_port (stream->conn),
- (mount && mount[0] == '/') ? "" : "/", ices_util_nullcheck (mount));
-
- return 0;
-}
-
-static int stream_needs_reencoding (input_stream_t* source, ices_stream_t* stream) {
- if (!source->read || source->bitrate != (unsigned int)stream->bitrate
- || (stream->out_samplerate > 0 &&
- source->samplerate != (unsigned int)stream->out_samplerate)
- || (stream->out_numchannels > 0 &&
- source->channels != (unsigned int)stream->out_numchannels))
- return 1;
-
- return 0;
-}
Copied: icecast/tags/ices0/ices-0_4/src/stream.c (from rev 7428, icecast/trunk/ices0/src/stream.c)
Deleted: icecast/tags/ices0/ices-0_4/src/stream.h
===================================================================
--- icecast/trunk/ices0/src/stream.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/stream.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,23 +0,0 @@
-/* stream.h
- * - streaming function declarations for ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-/* Public function declarations */
-void ices_stream_loop (ices_config_t* config);
-void ices_stream_next (void);
Copied: icecast/tags/ices0/ices-0_4/src/stream.h (from rev 7407, icecast/trunk/ices0/src/stream.h)
Deleted: icecast/tags/ices0/ices-0_4/src/util.c
===================================================================
--- icecast/trunk/ices0/src/util.c 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/util.c 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,320 +0,0 @@
-/* util.c
- * - utility functions for ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include "definitions.h"
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <string.h>
-
-extern ices_config_t ices_config;
-
-char **ices_argv;
-int ices_argc;
-const char cnull[7] = "(null)";
-
-/* Public function definitions */
-
-/* Wrapper function around strdup. Will always return
- * an allocated string, "(null)" if given NULL argument. */
-char *
-ices_util_strdup (const char *string)
-{
- char *out;
-
- if (string) {
- out = strdup (string);
- } else {
- out = strdup ("(null)");
- }
-
- return out;
-}
-
-/* Wrapper function around CLI argv */
-char **
-ices_util_get_argv (void)
-{
- return ices_argv;
-}
-
-/* Wrapper function around CLI argc */
-int
-ices_util_get_argc (void)
-{
- return ices_argc;
-}
-
-/* Mutator function for CLI args */
-void
-ices_util_set_args (int argc, char **argv)
-{
- ices_argc = argc;
- ices_argv = argv;
-}
-
-/* Wrapper function around open */
-int
-ices_util_open_for_reading (const char *file)
-{
- if (file)
- return open (file, O_RDONLY);
- return -1;
-}
-
-/* Wrapper function around fopen */
-FILE *
-ices_util_fopen_for_reading (const char *file)
-{
- if (! (file && *file))
- return NULL;
-
- return fopen (file, "r");
-}
-
-/* fOpen file for writing, in the base directory, unless
- * filename starts with '/' */
-FILE *
-ices_util_fopen_for_writing (const char *file)
-{
- if (!file)
- return NULL;
-
- return fopen (file, "w");
-}
-
-/* Wrapper function around fclose */
-void
-ices_util_fclose (FILE *fp)
-{
- if (fp)
- fclose (fp);
-}
-
-/* Verify the validity of a file descriptor */
-int
-ices_util_valid_fd (int fd)
-{
- return (fd >= 0);
-}
-
-/* Return a dynamically allocated string, the next line read
- * from FILE *fp */
-char *
-ices_util_read_line (FILE *fp)
-{
- char temp[1024];
-
- if (!fp)
- return NULL;
-
- temp[0] = '\0';
-
- if (!fgets (temp, 1024, fp)) {
-
- if (!feof (fp)) {
- ices_log_error ("Got error while reading file, error: [%s]", ices_util_strerror (errno, temp, 1024));
- return NULL;
- }
-
- return ices_util_strdup (temp);
- }
-
- return ices_util_strdup (temp);
-}
-
-/* Create a box-unique filename of a certain type */
-char *
-ices_util_get_random_filename (char *namespace, char *type)
-{
- if (!namespace || !type) {
- ices_log ("WARNING: ices_util_get_random_filename() called with NULL pointers.");
- return NULL;
- }
-
-#ifdef _WIN32
- doooh();
-#else
- sprintf (namespace, "ices.%s.%d", type, (int)getpid ());
- return namespace;
-#endif
-}
-
-/* Wrapper function around remove() */
-int
-ices_util_remove (const char *filename)
-{
- if (filename)
- return remove (filename);
- return -1;
-}
-
-/* Function to get a box-unique integer */
-int
-ices_util_get_random (void)
-{
-#ifdef _WIN32
- doooh();
-#else
- return getpid();
-#endif
-}
-
-/* Verify that the file descriptor is a regular file
- * return -1 on error
- * 1 when file is a regular file or link
- * -2 when fd is a directory
- * else 0 (fifo or pipe or something weird) */
-int
-ices_util_is_regular_file (int fd)
-{
- struct stat st;
-
- if (fstat (fd, &st) == -1) {
- ices_log_error ("ERROR: Could not stat file");
- return -1;
- }
-
- if (S_ISLNK (st.st_mode) || S_ISREG (st.st_mode))
- return 1;
-
- if (S_ISDIR(st.st_mode)) {
- ices_log_error ("ERROR: Is directory!");
- return -2;
- }
-
- return 0;
-}
-
-/* Make sure directory exists and is a directory */
-int
-ices_util_directory_exists (const char *name)
-{
- struct stat st;
-
- if (!name) {
- ices_log ("ices_util_directory_exists() called with NULL");
- return 0;
- }
-
- if (stat (name, &st) == -1)
- return 0;
-
- if (!S_ISDIR (st.st_mode))
- return 0;
-
- return 1;
-}
-
-/* Wrapper function around directory creation */
-int
-ices_util_directory_create (const char *name)
-{
- if (name)
- return mkdir (name, 00755);
- return -1;
-}
-
-/* Verify that the string is not null, and if it is, return "(null)" */
-const char *
-ices_util_nullcheck (const char *string)
-{
- if (!string)
- return &cnull[0];
- return string;
-}
-
-/* Wrapper function for percentage */
-double
-ices_util_percent (int num, int den)
-{
- if (! den)
- return 0;
-
- return (double)((double)num / (double)den) * 100.0;
-}
-
-/* Given bitrate and filesize, report the length of the given file
- * by nice formatting in string buf.
- * Note: This only works ok with CBR */
-char *
-ices_util_file_time (unsigned int bitrate, unsigned int filesize, char *buf)
-{
- unsigned long int days, hours, minutes, nseconds, remains;
- unsigned long int seconds;
-
- if (!bitrate) {
- sprintf (buf, "0:0:0:0");
- return buf;
- }
-
- /* << 7 == 1024 (bits->kbits) / 8 (bits->bytes) */
- seconds = filesize / ((bitrate * 1000) >> 3);
-
- if (!buf)
- return NULL;
-
- days = seconds / 86400;
- remains = seconds % 86400;
-
- hours = remains / 3600;
- remains = remains % 3600;
-
- minutes = remains / 60;
- nseconds = remains % 60;
-
- sprintf (buf, "%lu:%lu:%lu:%lu", days, hours, minutes, nseconds);
-
- return buf;
-}
-
-/* Threadsafe version of strerror */
-const char *
-ices_util_strerror (int error, char *namespace, int maxsize)
-{
- strncpy (namespace, strerror (error), maxsize);
- return namespace;
-}
-
-/* Wrapper function around free */
-void
-ices_util_free (void *ptr)
-{
- if (ptr)
- free (ptr);
-}
-
-/* Verify that file exists, and is readable */
-int
-ices_util_verify_file (const char *filename)
-{
- FILE *fp;
-
- if (!filename || !filename[0])
- return 0;
-
- if (!(fp = ices_util_fopen_for_reading (filename)))
- return 0;
-
- ices_util_fclose (fp);
-
- return 1;
-}
Copied: icecast/tags/ices0/ices-0_4/src/util.c (from rev 7407, icecast/trunk/ices0/src/util.c)
Deleted: icecast/tags/ices0/ices-0_4/src/util.h
===================================================================
--- icecast/trunk/ices0/src/util.h 2004-07-29 01:17:26 UTC (rev 7409)
+++ icecast/tags/ices0/ices-0_4/src/util.h 2004-08-28 18:55:23 UTC (rev 7653)
@@ -1,44 +0,0 @@
-/* util.h
- * - utility function declarations for ices
- * Copyright (c) 2000 Alexander Haväng
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-/* Public function declarations */
-char **ices_util_get_argv (void);
-int ices_util_get_argc (void);
-char *ices_util_strdup (const char *string);
-void ices_util_set_args (int argc, char **argv);
-int ices_util_open_for_reading (const char *file);
-int ices_util_valid_fd (int fd);
-FILE *ices_util_fopen_for_writing (const char *file);
-FILE *ices_util_fopen_for_reading (const char *file);
-void ices_util_fclose (FILE *fp);
-char *ices_util_read_line (FILE *fp);
-char *ices_util_get_random_filename (char *namespace, char *type);
-int ices_util_remove (const char *filename);
-int ices_util_get_random (void);
-int ices_util_is_regular_file (int fd);
-int ices_util_directory_create (const char *filename);
-int ices_util_directory_exists (const char *filename);
-const char *ices_util_nullcheck (const char *string);
-double ices_util_percent (int this, int of_that);
-char *ices_util_file_time (unsigned int bitrate, unsigned int filesize,
- char *namespace);
-const char *ices_util_strerror (int error, char *namespace, int maxsize);
-void ices_util_free (void *ptr);
-int ices_util_verify_file (const char *filename);
Copied: icecast/tags/ices0/ices-0_4/src/util.h (from rev 7407, icecast/trunk/ices0/src/util.h)
More information about the commits
mailing list