The tag-reader library, libmetatag, consists of the files located in tags/
and is licensed under the LGPL, along with the rest of the XMMS plugin
(see COPYING).

---

Developer Information:

libmetatag is a portable C library designed specifically for the reading of
music metadata (specifically ID3v1, ID3v2, APE1 (untested), APE2, Vorbis, and
FLAC tags) and the querying of MusicBrainz to determine the metadata for an
audio CD.

It should theoretically compile under all platforms, with only one dependancy on
libmusicbrainz.

---

For plugin developers:

You need to include tags.h, and you need to add a metadata variable in your song
detection function. As a result it will require some retooling of your code.

Also, make sure to always run clean_meta(&<meta_variable_name>) immediately
after defining the variable.  This will help keep your plugin from segfaulting.
Also make sure to run free_meta(&<meta_variable_name>) after all work with the
current set of metadata is done.  This calls the free() function for each
field in the metadata struct so as to prevent memory leakage.  You will need to
run clean_meta(&<meta_variable_name>) sometime after
free_meta(&<meta_variable_name>) if you intend to use the metadata variable
again.

As for the actual tag detection and reading functions, it's quite simple:

char *tag_exists(char *filename);
metadata get_tag_metadata(char *filename, char *tags);

The first function returns a char array of size two based off of what tags exist
in the file specified by the char *filename.

It will return the bytes as follows (also listed in tags.h):

0xab000000 0x000cdefg

a: There was an error reading the file.
b: It is a CD Audio file (Note: this only works if the filename passed ends in
				*.cda. If your OS/Media Player will not return
				a *.cda filename for an audio CD, you will need
				to detect it separately.)
c: There is a FLAC tag
d: There is an APE tag
e: There is a Vorbis tag
f: There is an ID3v2 tag
g: There is an ID3v1 tag

The zeroes are currently reserved for future use.

The second function returns the appropriate metadata for the filename, when
also given the char array returned by tag_exists().

If multiple tags exist in a file, the top-most tag-type present in the following
list is read:

1. APE tag
2. Vorbis/FLAC tag
3. ID3v2 tag
4. ID3v1 tag

If the metadata for a currently playing CD is desired, the device name for
the CD-ROM that is playing must be passed instead of any other filename. Also,
the two-byte char array must have the audio CD marker set, and have the second
byte equal the track number for which data is desired.

---

I hope this little README helps prospective developers, and that you don't have
too much trouble working with the code.  Remember that you can always use the
current code as a template for your own code.

Now I know that it probably isn't completely bug-free, but I've tried my best to
weed them out.

If you find any, report bugs with the library to Pipian <pipian@pipian.com>.
