mp3reader

Name

mp3reader -- MP3 Read / Write / Info functions

Synopsis



#define     MAX_TAG_SIZE
#define     MP3TAG_ID3V1
#define     MP3TAG_ID3V2
#define     MP3READER_ERR_FORMAT
#define     MP3READER_ERR_VBR
#define     MP3READER_ERR_LAYER
#define     MP3READER_ERR_MALFORMED
#define     MP3READER_ERR_OPEN
#define     MP3READER_ERR_UNSUPPORTED
struct      MP3READER;
MP3READER*  MP3Create                       (void);
void        MP3Destroy                      (MP3READER *rdr);
int         MP3NewFile                      (MP3READER *rdr,
                                             char *filename);
int         MP3Open                         (MP3READER *rdr,
                                             char *filename,
                                             int noparse,
                                             long *offsets,
                                             int num_offsets);
void        MP3Close                        (MP3READER *rdr);
int         MP3Read                         (MP3READER *rdr,
                                             u8 *buf,
                                             int length);
int         MP3Write                        (MP3READER *rdr,
                                             unsigned char *buf,
                                             int length);
int         MP3ParseMP3                     (MP3READER *rdr,
                                             long *offsets,
                                             int num_offsets);
#define     MP3IsVBR                        (rdr)
#define     MP3GetBitRate                   (rdr)
#define     MP3GetPlayTime                  (rdr)
#define     MP3GetPlayTime75                (rdr)
#define     MP3GetFileLength                (rdr)
#define     MP3GetTag                       (rdr)
#define     MP3IsTagged                     (rdr)
#define     MP3GetID3Tag                    (rdr)
#define     MP3GetGenre                     (rdr)
#define     MP3GetAlbum                     (rdr)
#define     MP3GetArtist                    (rdr)
#define     MP3GetTitle                     (rdr)
#define     MP3GetTrack                     (rdr)
#define     MP3GetYear                      (rdr)
#define     MP3GetComment                   (rdr)

Description

This library file contains routines to walk through MP3 files and extract key information such as ID3 tags, bitrate, etc.

Details

MAX_TAG_SIZE

#define MAX_TAG_SIZE 128


MP3TAG_ID3V1

#define MP3TAG_ID3V1	1


MP3TAG_ID3V2

#define MP3TAG_ID3V2	2


MP3READER_ERR_FORMAT

#define MP3READER_ERR_FORMAT		60


MP3READER_ERR_VBR

#define MP3READER_ERR_VBR			61


MP3READER_ERR_LAYER

#define MP3READER_ERR_LAYER		62


MP3READER_ERR_MALFORMED

#define MP3READER_ERR_MALFORMED	63


MP3READER_ERR_OPEN

#define MP3READER_ERR_OPEN	64


MP3READER_ERR_UNSUPPORTED

#define MP3READER_ERR_UNSUPPORTED	65


struct MP3READER

struct MP3READER
{
    u8 id3v1tag[129];
    char *tag_genre;
    char *tag_album;
    char *tag_artist;
    char *tag_title;
    char *tag_year;
    char *tag_track;
    char *tag_comment;
    int filehandle;
    u8 *membase;
    int open;
    unsigned long filelength;

    u8 *mp3start;
    u8 *mp3end;
    unsigned long mp3length;
    u8 *mp3ptr;

    unsigned int tagtypes;

    unsigned long playtime75;
    unsigned long totalframes;
    int bitRate;
    int vbr;
};


MP3Create ()

MP3READER*  MP3Create                       (void);

Constructs a Reader object

Returns : Pointer to the created reader


MP3Destroy ()

void        MP3Destroy                      (MP3READER *rdr);

Destroys the Reader

rdr : Reader to be destroyed


MP3NewFile ()

int         MP3NewFile                      (MP3READER *rdr,
                                             char *filename);

Used to create a brand new MP3 file that will contain data that is likely to be read from the PJB

rdr : MP3READER
filename : Name of mp3 to open
Returns : 0 if OK, otherwise error number


MP3Open ()

int         MP3Open                         (MP3READER *rdr,
                                             char *filename,
                                             int noparse,
                                             long *offsets,
                                             int num_offsets);

Opens an MP3 file. This routine maps the file into memory and attempts to parse it. It also extracts the tags from both ID3V1 and ID3V2/3 formats.

rdr : Already opened MP3READER.
filename : name of mp3 to open.
noparse : skip the file scan (tags will still work).
offsets : ???
num_offsets : ???
Returns : 0 if ok else error code


MP3Close ()

void        MP3Close                        (MP3READER *rdr);

close the MP3 file

rdr : Open MP3READER


MP3Read ()

int         MP3Read                         (MP3READER *rdr,
                                             u8 *buf,
                                             int length);

Read data from the mp3 file

rdr : Reader
buf : dest buffer
length : size of dest buffer
Returns : number of bytes read, or 0 if no bytes available


MP3Write ()

int         MP3Write                        (MP3READER *rdr,
                                             unsigned char *buf,
                                             int length);

Write data to an MP3 File

rdr : Reader
buf : source buffer
length : size of source buffer
Returns : number of bytes written, or -1 if a problem


MP3ParseMP3 ()

int         MP3ParseMP3                     (MP3READER *rdr,
                                             long *offsets,
                                             int num_offsets);

Walk through frames in the mp3 file to make sure we can play it in the Jukebox

rdr : Reader
offsets : ??
num_offsets :??
Returns : 0 if ok else error code


MP3IsVBR()

#define MP3IsVBR(rdr) ((rdr)->vbr)

Determines whether the MP3 is VBR

rdr : Opened MP3READER


MP3GetBitRate()

#define MP3GetBitRate(rdr) ((rdr)->bitRate*1000)

Determines the bitrate of the MP3

rdr : Opened MP3READER


MP3GetPlayTime()

#define MP3GetPlayTime(rdr) ((rdr)->playtime75/75)

Determines the playing time of the MP3

rdr : Opened MP3READER


MP3GetPlayTime75()

#define MP3GetPlayTime75(rdr) ((rdr)->playtime75)

Determines the raw playing time of the MP3

rdr : Opened MP3READER


MP3GetFileLength()

#define MP3GetFileLength(rdr) ((rdr)->mp3length)

Determines the file length of the MP3

rdr : Opened MP3READER


MP3GetTag()

#define MP3GetTag(rdr) ((rdr)->id3v1tag)

Gets the id3v1 tag

rdr : Opened MP3READER


MP3IsTagged()

#define MP3IsTagged(rdr) ((rdr)->tagtypes)

Determines whether the MP3 is tagged or not

rdr : Opened MP3READER


MP3GetID3Tag()

#define MP3GetID3Tag(rdr) ((rdr)->id3v1tag)

Gets the ID3v1 from the Mp3

rdr : Opened MP3READER


MP3GetGenre()

#define MP3GetGenre(rdr) ((rdr)->tag_genre)

Gets the genre tag from the Mp3

rdr :Opened MP3READER


MP3GetAlbum()

#define MP3GetAlbum(rdr) ((rdr)->tag_album)

Gets the album tag from the Mp3

rdr : Opened MP3READER


MP3GetArtist()

#define MP3GetArtist(rdr) ((rdr)->tag_artist)

Gets the artist tag from the Mp3

rdr : Opened MP3READER


MP3GetTitle()

#define MP3GetTitle(rdr) ((rdr)->tag_title)

Gets the title from the Mp3

rdr : Opened MP3READER


MP3GetTrack()

#define MP3GetTrack(rdr) ((rdr)->tag_track)

Gets the track name from the Mp3

rdr : Opened MP3READER


MP3GetYear()

#define MP3GetYear(rdr) ((rdr)->tag_year)

Gets the year tag from the Mp3

rdr : Opened MP3READER


MP3GetComment()

#define MP3GetComment(rdr) ((rdr)->tag_comment)

Gets the tag_comment from the Mp3

rdr : Opened MP3READER