cddb_disc.h File Reference

#include <cddb/cddb_track.h>

Go to the source code of this file.

Defines

#define CDDB_DISC_H   1
#define FRAMES_PER_SECOND   75
 The number of frames that fit into one second.
#define FRAMES_TO_SECONDS(f)   ((f) / FRAMES_PER_SECOND)
 This macro converts an amount of frames into an amount of seconds.
#define SECONDS_TO_FRAMES(s)   ((s) * FRAMES_PER_SECOND)
 This macro converts an amount of seconds into an amount of frames.

Typedefs

typedef cddb_disc_s cddb_disc_t
 The CDDB disc structure.

Enumerations

enum  cddb_cat_t {
  CDDB_CAT_DATA = 0, CDDB_CAT_FOLK, CDDB_CAT_JAZZ, CDDB_CAT_MISC,
  CDDB_CAT_ROCK, CDDB_CAT_COUNTRY, CDDB_CAT_BLUES, CDDB_CAT_NEWAGE,
  CDDB_CAT_REGGAE, CDDB_CAT_CLASSICAL, CDDB_CAT_SOUNDTRACK, CDDB_CAT_INVALID,
  CDDB_CAT_LAST
}
 The different CDDB categories. More...

Functions

cddb_disc_tcddb_disc_new (void)
 Creates a new CDDB disc structure.
void cddb_disc_destroy (cddb_disc_t *disc)
 Free all resources associated with the given CDDB disc structure.
cddb_disc_tcddb_disc_clone (const cddb_disc_t *disc)
 Creates a clone of the given disc.
void cddb_disc_add_track (cddb_disc_t *disc, cddb_track_t *track)
 Add a new track to a disc.
cddb_track_tcddb_disc_get_track (const cddb_disc_t *disc, int track_no)
 Retrieves a numbered track from the disc.
cddb_track_tcddb_disc_get_track_first (cddb_disc_t *disc)
 Returns the first track of the disc.
cddb_track_tcddb_disc_get_track_next (cddb_disc_t *disc)
 Returns the next track on the disc and advances the internal track iterator.
unsigned int cddb_disc_get_discid (const cddb_disc_t *disc)
 Get the ID of the disc.
void cddb_disc_set_discid (cddb_disc_t *disc, unsigned int id)
 Set the ID of the disc.
cddb_cat_t cddb_disc_get_category (const cddb_disc_t *disc)
 Get the disc CDDB category ID.
void cddb_disc_set_category (cddb_disc_t *disc, cddb_cat_t cat)
 Set the disc CDDB category ID.
const char * cddb_disc_get_category_str (cddb_disc_t *disc)
 Get the disc CDDB category as a string.
void cddb_disc_set_category_str (cddb_disc_t *disc, const char *cat)
 Sets the category of the disc.
const char * cddb_disc_get_genre (const cddb_disc_t *disc)
 Get the disc genre.
void cddb_disc_set_genre (cddb_disc_t *disc, const char *genre)
 Set the disc genre.
unsigned int cddb_disc_get_length (const cddb_disc_t *disc)
 Get the disc length.
void cddb_disc_set_length (cddb_disc_t *disc, unsigned int l)
 Set the disc length.
unsigned int cddb_disc_get_year (const cddb_disc_t *disc)
 Get the year of publication for this disc.
void cddb_disc_set_year (cddb_disc_t *disc, unsigned int y)
 Set the year of publication for this disc.
int cddb_disc_get_track_count (const cddb_disc_t *disc)
 Get the number of tracks on the disc.
const char * cddb_disc_get_title (const cddb_disc_t *disc)
 Get the disc title.
void cddb_disc_set_title (cddb_disc_t *disc, const char *title)
 Set the disc title.
void cddb_disc_append_title (cddb_disc_t *disc, const char *title)
 Append to the disc title.
const char * cddb_disc_get_artist (const cddb_disc_t *disc)
 Get the disc artist name.
void cddb_disc_set_artist (cddb_disc_t *disc, const char *artist)
 Set the disc artist name.
void cddb_disc_append_artist (cddb_disc_t *disc, const char *artist)
 Append to the disc artist.
const char * cddb_disc_get_ext_data (const cddb_disc_t *disc)
 Get the extended disc data.
void cddb_disc_set_ext_data (cddb_disc_t *disc, const char *ext_data)
 Set the extended data for the disc.
void cddb_disc_append_ext_data (cddb_disc_t *disc, const char *ext_data)
 Append to the extended disc data.
void cddb_disc_copy (cddb_disc_t *dst, cddb_disc_t *src)
 Copy all data from one disc to another.
int cddb_disc_calc_discid (cddb_disc_t *disc)
 Calculate the CDDB disc ID.
void cddb_disc_print (cddb_disc_t *disc)
 Prints information about the disc on stdout.

Variables

const char * CDDB_CATEGORY [CDDB_CAT_LAST]
 String values for the CDDB categories.


Define Documentation

#define CDDB_DISC_H   1
 

#define FRAMES_PER_SECOND   75
 

The number of frames that fit into one second.

#define FRAMES_TO_SECONDS  )     ((f) / FRAMES_PER_SECOND)
 

This macro converts an amount of frames into an amount of seconds.

#define SECONDS_TO_FRAMES  )     ((s) * FRAMES_PER_SECOND)
 

This macro converts an amount of seconds into an amount of frames.


Typedef Documentation

typedef struct cddb_disc_s cddb_disc_t
 

The CDDB disc structure.

Contains all information associated with a full CD.


Enumeration Type Documentation

enum cddb_cat_t
 

The different CDDB categories.

Enumerator:
CDDB_CAT_DATA  data disc
CDDB_CAT_FOLK  folk music
CDDB_CAT_JAZZ  jazz music
CDDB_CAT_MISC  miscellaneous, use if no other category matches
CDDB_CAT_ROCK  rock and pop music
CDDB_CAT_COUNTRY  country music
CDDB_CAT_BLUES  blues music
CDDB_CAT_NEWAGE  new age music
CDDB_CAT_REGGAE  reggae music
CDDB_CAT_CLASSICAL  classical music
CDDB_CAT_SOUNDTRACK  soundtracks
CDDB_CAT_INVALID  (internal) invalid category
CDDB_CAT_LAST  (internal) category counter


Function Documentation

void cddb_disc_add_track cddb_disc_t disc,
cddb_track_t track
 

Add a new track to a disc.

The track is added to the end of the existing list of tracks.

Parameters:
disc The CDDB disc structure.
track The CDDB track structure.

void cddb_disc_append_artist cddb_disc_t disc,
const char *  artist
 

Append to the disc artist.

If the disc does not have an artist yet, then a new one will be created from the given string, otherwise that string will be appended to the existing artist.

Parameters:
disc The CDDB disc structure.
artist Part of the artist name.

void cddb_disc_append_ext_data cddb_disc_t disc,
const char *  ext_data
 

Append to the extended disc data.

If the disc does not have an extended data section yet, then a new one will be created from the given string, otherwise that string will be appended to the existing data.

Parameters:
disc The CDDB disc structure.
ext_data Part of the extended disc data.

void cddb_disc_append_title cddb_disc_t disc,
const char *  title
 

Append to the disc title.

If the disc does not have a title yet, then a new one will be created from the given string, otherwise that string will be appended to the existing title.

Parameters:
disc The CDDB disc structure.
title Part of the disc title.

int cddb_disc_calc_discid cddb_disc_t disc  ) 
 

Calculate the CDDB disc ID.

To calculate a disc ID the provided disc needs to have its length set, and every track in the disc structure needs to have its frame offset initialized. The disc ID field will be set in the disc structure.

Parameters:
disc The CDDB disc structure.
Returns:
A non-zero value if the calculation succeeded, zero otherwise.

cddb_disc_t* cddb_disc_clone const cddb_disc_t disc  ) 
 

Creates a clone of the given disc.

Parameters:
disc The CDDB disc structure.

void cddb_disc_copy cddb_disc_t dst,
cddb_disc_t src
 

Copy all data from one disc to another.

Any fields that are unavailable in the source disc structure will not result in a reset of the same field in the destination disc structure; e.g. if there is no title in the source disc, but there is one in the destination disc, then the destination's title will remain unchanged.

Parameters:
dst The destination CDDB disc structure.
src The source CDDB disc structure.

void cddb_disc_destroy cddb_disc_t disc  ) 
 

Free all resources associated with the given CDDB disc structure.

The tracks will also be freed automatically.

Parameters:
disc The CDDB disc structure.

const char* cddb_disc_get_artist const cddb_disc_t disc  ) 
 

Get the disc artist name.

If the disc is invalid or no artist is set then NULL will be returned.

Parameters:
disc The CDDB disc structure.
Returns:
The disc artist name.

cddb_cat_t cddb_disc_get_category const cddb_disc_t disc  ) 
 

Get the disc CDDB category ID.

If the disc is invalid or no category is set then CDDB_CAT_INVALID will be returned. If you want a string representation of the category use the cddb_disc_get_category_str function.

See also:
cddb_disc_set_category

cddb_disc_get_category_str

cddb_disc_set_category_str

cddb_cat_t

CDDB_CATEGORY

Parameters:
disc The CDDB disc structure.
Returns:
The CDDB category ID.

const char* cddb_disc_get_category_str cddb_disc_t disc  ) 
 

Get the disc CDDB category as a string.

If no category is set for this disc then 'invalid' will be returned. If the disc structure is invalid NULL is returned. If you only want the ID of the category use the cddb_disc_get_category function.

See also:
cddb_disc_get_category

cddb_disc_set_category

cddb_disc_set_category_str

Parameters:
disc The CDDB disc structure.
Returns:
The CDDB category ID.

unsigned int cddb_disc_get_discid const cddb_disc_t disc  ) 
 

Get the ID of the disc.

If the disc is invalid or the disc ID is not yet initialized 0 will be returned.

Parameters:
disc The CDDB disc structure.

const char* cddb_disc_get_ext_data const cddb_disc_t disc  ) 
 

Get the extended disc data.

If the disc is invalid or no extended data is set then NULL will be returned.

Parameters:
disc The CDDB disc structure.
Returns:
The extended data.

const char* cddb_disc_get_genre const cddb_disc_t disc  ) 
 

Get the disc genre.

If no genre is set for this disc then NULL will be returned. As opposed to the disc category, this field is not limited to a predefined set.

Parameters:
disc The CDDB disc structure.
Returns:
The disc genre.

unsigned int cddb_disc_get_length const cddb_disc_t disc  ) 
 

Get the disc length.

If no length is set for this disc then 0 will be returned.

Parameters:
disc The CDDB disc structure.
Returns:
The disc length in seconds.

const char* cddb_disc_get_title const cddb_disc_t disc  ) 
 

Get the disc title.

If the disc is invalid or no title is set then NULL will be returned.

Parameters:
disc The CDDB disc structure.
Returns:
The disc title.

cddb_track_t* cddb_disc_get_track const cddb_disc_t disc,
int  track_no
 

Retrieves a numbered track from the disc.

If there is no track with the given number, then NULL will be returned.

Parameters:
disc The CDDB disc structure.
track_no The track number; starting at 0.

int cddb_disc_get_track_count const cddb_disc_t disc  ) 
 

Get the number of tracks on the disc.

If the disc is invalid -1 is returned.

Parameters:
disc The CDDB disc structure.
Returns:
The number of tracks.

cddb_track_t* cddb_disc_get_track_first cddb_disc_t disc  ) 
 

Returns the first track of the disc.

If there is no such track then NULL will be returned. The internal track iterator will also be reset. This function should be called before the first call to cddb_disc_get_track_next.

See also:
cddb_disc_get_track_next
Parameters:
disc The CDDB disc structure.

cddb_track_t* cddb_disc_get_track_next cddb_disc_t disc  ) 
 

Returns the next track on the disc and advances the internal track iterator.

If there is no such track then NULL will be returned. This function should be called after calling cddb_disc_get_track_first.

See also:
cddb_disc_get_track_first
Parameters:
disc The CDDB disc structure.

unsigned int cddb_disc_get_year const cddb_disc_t disc  ) 
 

Get the year of publication for this disc.

If no year is defined 0 is returned.

Parameters:
disc The CDDB disc structure.
Returns:
The disc year.

cddb_disc_t* cddb_disc_new void   ) 
 

Creates a new CDDB disc structure.

Returns:
The CDDB disc structure or NULL if memory allocation failed.

void cddb_disc_print cddb_disc_t disc  ) 
 

Prints information about the disc on stdout.

This is just a debugging routine to display the structure's content.

Parameters:
disc The CDDB disc structure.

void cddb_disc_set_artist cddb_disc_t disc,
const char *  artist
 

Set the disc artist name.

If the disc already had an artist name, then the memory for that string will be freed. The new artist name will be copied into a new chunk of memory. If the given artist name is NULL, then the artist name of the disc will be deleted.

Parameters:
disc The CDDB disc structure.
artist The new disc artist name.

void cddb_disc_set_category cddb_disc_t disc,
cddb_cat_t  cat
 

Set the disc CDDB category ID.

See also:
cddb_disc_get_category

cddb_disc_get_category_str

cddb_disc_set_category_str

cddb_cat_t

CDDB_CATEGORY

Parameters:
disc The CDDB disc structure.
cat The CDDB category ID.

void cddb_disc_set_category_str cddb_disc_t disc,
const char *  cat
 

Sets the category of the disc.

If the specified category is an invalid CDDB category, then CDDB_CAT_MISC will be used.

See also:
cddb_disc_get_category

cddb_disc_set_category

cddb_disc_get_category_str

CDDB_CATEGORY

Parameters:
disc The CDDB disc structure.
cat The category string.

void cddb_disc_set_discid cddb_disc_t disc,
unsigned int  id
 

Set the ID of the disc.

When the disc ID is not known yet, then it can be calculated with the cddb_disc_calc_discid function (which will automatically initialize the correct field in the disc structure).

See also:
cddb_disc_calc_discid
Parameters:
disc The CDDB disc structure.
id The disc ID.

void cddb_disc_set_ext_data cddb_disc_t disc,
const char *  ext_data
 

Set the extended data for the disc.

If the disc already had extended data, then the memory for that string will be freed. The new extended data will be copied into a new chunk of memory. If the given extended data is NULL, then the existing data will be deleted.

Parameters:
disc The CDDB disc structure.
ext_data The new extended data.

void cddb_disc_set_genre cddb_disc_t disc,
const char *  genre
 

Set the disc genre.

As opposed to the disc category, this field is not limited to a predefined set. If the disc already had a genre, then the memory for that string will be freed. The new genre will be copied into a new chunk of memory.

See also:
cddb_disc_get_category_str
Parameters:
disc The CDDB disc structure.
genre The disc genre.

void cddb_disc_set_length cddb_disc_t disc,
unsigned int  l
 

Set the disc length.

Parameters:
disc The CDDB disc structure.
l The disc length in seconds.

void cddb_disc_set_title cddb_disc_t disc,
const char *  title
 

Set the disc title.

If the disc already had a title, then the memory for that string will be freed. The new title will be copied into a new chunk of memory. If the given title is NULL, then the title of the disc will be deleted.

Parameters:
disc The CDDB disc structure.
title The new disc title.

void cddb_disc_set_year cddb_disc_t disc,
unsigned int  y
 

Set the year of publication for this disc.

Parameters:
disc The CDDB disc structure.
y The disc year.


Variable Documentation

const char* CDDB_CATEGORY[CDDB_CAT_LAST]
 

String values for the CDDB categories.


Generated on Sun Oct 15 14:49:15 2006 for libcddb by  doxygen 1.4.6