*
* Note: this was first written for the initial release of byRequest.
* It was modified a couple of times for later releases.
*
* Initial version was early 2003.
*
* Dave Clemans
*

The current, extremely minimal documentation.

This is a server for responding to audio and photo requests from the
TiVo HMO (Home Media Option) software package.  Compile and start the server
in the background; it can run as a normal user.

Photo support is implemented by recognizing and sending image files.
Image resizing is done by calling the ImageMagick "convert" tool.

Native audio support is implemented by recognizing and sending MP3 encoded
files.  Metadata is picked up from those files using functions merged from
the "mp3info" tool.

Internet MP3 streams are recognized and forwarded to the client.  There is
a restriction on the URL used for the stream; it must lead directly to the
stream.  Redirection isn't handled.

Windows Media files and streams are handled by the "mplayer" tool.  

RealAudio files and streams are handled by the "splay" player from RealAudio's
"Helix" community source project, combined with the "vsound" and "sox" tools.

The Windows Media and RealAudio internet streams from the BBC (BBC radio 4,
BBC radio 7, BBC World) and known to work correctly.

Exported directories are defined by editing a configuration file.

A directory of audio files; typically MPEG encoded music, has a type "audio/*".
A directory of image files, typically JPEG encoded pictures, has a type
"image/*'.  The first string is the name the TiVo will show on the screen.
The second string is the pathname of the directory on the system.

Effectively every audio file and image file underneath the directories you
define are "exported"; e.g. made visible to TiVo. There can be an arbitrary
number of folders (subdirectories) that group the audio or image files.

There is rough support for two types of playlist files; .pls and .m3u.
All metadata from playlists is currently ignored; the server just tries to
pick up the files contained in the playlists.  If there are multiple files
in a playlist, they will be sorted if the TiVo asks for a sorted list of
files.

The server has successfully used MPEG internet streams from Shoutcast servers.
To access an internet MPEG stream, (or any other internet stream)
put the URL in a .pls file.  Note that you have to use a url that
directly accesses the stream; currently redirection isn't handled.

The freely available "mplayer" movie player can use Windows DLL-packaged
codecs, and it can be used to decode audio-only streams.  Using this tool,
assuming you have the appropriate files installed, it's possible to play
"Windows Media", etc. files and internet streams.  The decoded .wav data
from mplayer is sent to lame.  The output of lame goes to TiVo.
mplayer can also be configured to decode some RealAudio streams, but
not all.

Note: I have not yet found a RealAudio stream that mplayer can handle.  I'm
not sure if its a codec problem, or a stream format problem.  I don't have
any RealAudio files floating around to try it.

Note: Using the splay command line RealAudio player from Real's
"Helix DNA" community project (http://www.helixcommunity.org), and the
LD_PRELOAD /usr/lib/vsound/libvsound.so library from the vsound project,
you can play realaudio streams using this server.  To get the splay tool,
you will have to sign up as a developer on their website, agree to the binary
license, and download the developer binary release.

There is support (currently untested) for ogg-vorbis encoded audio files.
ogg123 is used to generate wav data that is passed to lame, and then to
TiVo.

Audio files, images and internet streams are sent to TiVo in a separate
thread; currently everything else runs in the main thread.
