libgpod Reference Manual | ||||
---|---|---|---|---|
Itdb_Track; enum Itdb_Mediatype; #define ITDB_RATING_STEP Itdb_Track* itdb_track_new (void); void itdb_track_free (Itdb_Track *track); void itdb_track_add (Itdb_iTunesDB *itdb, Itdb_Track *track, gint32 pos); void itdb_track_remove (Itdb_Track *track); void itdb_track_unlink (Itdb_Track *track); Itdb_Track* itdb_track_duplicate (Itdb_Track *tr); Itdb_Track* itdb_track_by_id (Itdb_iTunesDB *itdb, guint32 id); GTree* itdb_track_id_tree_create (Itdb_iTunesDB *itdb); void itdb_track_id_tree_destroy (GTree *idtree); Itdb_Track* itdb_track_id_tree_by_id (GTree *idtree, guint32 id); gpointer itdb_track_get_thumbnail (Itdb_Track *track, gint width, gint height); gboolean itdb_track_has_thumbnails (Itdb_Track *track); gboolean itdb_track_set_thumbnails (Itdb_Track *track, const gchar *filename); gboolean itdb_track_set_thumbnails_from_data (Itdb_Track *track, const guchar *image_data, gsize image_data_len); gboolean itdb_track_set_thumbnails_from_pixbuf (Itdb_Track *track, gpointer pixbuf); void itdb_track_remove_thumbnails (Itdb_Track *track);
These functions and structures are for storing and retrieving information about an iPod track.
typedef struct { Itdb_iTunesDB *itdb; gchar *title; gchar *ipod_path; gchar *album; gchar *artist; gchar *genre; gchar *filetype; gchar *comment; gchar *category; gchar *composer; gchar *grouping; gchar *description; gchar *podcasturl; gchar *podcastrss; Itdb_Chapterdata *chapterdata; gchar *subtitle; /* the following 5 are new in libgpod 0.4.2... */ gchar *tvshow; gchar *tvepisode; gchar *tvnetwork; gchar *albumartist; gchar *keywords; /* the following 6 are new in libgpod 0.5.0... */ /* You can set these strings to override the standard sortorder. When set they take precedence over the default 'artist', 'album'... fields. For example, in the case of an artist name like "The Artist", iTunes will set sort_artist to "Artist, The" followed by five 0x01 characters. Why five 0x01 characters are added is not completely understood. If you do not set the sort_artist field, libgpod will pre-sort the lists displayed by the iPod according to "Artist, The", without setting the field. */ gchar *sort_artist; gchar *sort_title; gchar *sort_album; gchar *sort_albumartist; gchar *sort_composer; gchar *sort_tvshow; /* end of new fields in libgpod 0.5.0 */ guint32 id; gint32 size; gint32 tracklen; gint32 cd_nr; gint32 cds; gint32 track_nr; gint32 tracks; gint32 bitrate; guint16 samplerate; guint16 samplerate_low; gint32 year; gint32 volume; guint32 soundcheck; time_t time_added; time_t time_modified; time_t time_played; guint32 bookmark_time; guint32 rating; guint32 playcount; guint32 playcount2; guint32 recent_playcount; gboolean transferred; gint16 BPM; guint8 app_rating; guint8 type1; guint8 type2; guint8 compilation; guint32 starttime; guint32 stoptime; guint8 checked; guint64 dbid; guint32 drm_userid; guint32 visible; guint32 filetype_marker; guint16 artwork_count; guint32 artwork_size; float samplerate2; guint16 unk126; guint32 unk132; time_t time_released; guint16 unk144; guint16 explicit_flag; guint32 unk148; guint32 unk152; guint32 skipcount; guint32 recent_skipcount; guint32 last_skipped; guint8 has_artwork; guint8 skip_when_shuffling; guint8 remember_playback_position; guint8 flag4; guint64 dbid2; guint8 lyrics_flag; guint8 movie_flag; guint8 mark_unplayed; guint8 unk179; guint32 unk180; guint32 pregap; guint64 samplecount; guint32 unk196; guint32 postgap; guint32 unk204; guint32 mediatype; guint32 season_nr; guint32 episode_nr; guint32 unk220; guint32 unk224; guint32 unk228, unk232, unk236, unk240, unk244; guint32 gapless_data; guint32 unk252; guint16 gapless_track_flag; guint16 gapless_album_flag; guint16 album_id; /* This is for Cover Art support */ struct _Itdb_Artwork *artwork; /* This is for sparse artwork support, new in libgpod-0.7.0 */ guint32 mhii_link; /* reserved for future use */ gint32 reserved_int1; gint32 reserved_int2; gint32 reserved_int3; gint32 reserved_int4; gint32 reserved_int5; gint32 reserved_int6; gpointer reserved1; gpointer reserved2; gpointer reserved3; gpointer reserved4; gpointer reserved5; gpointer reserved6; /* +++***+++***+++***+++***+++***+++***+++***+++***+++***+++*** When adding string fields don't forget to add them in itdb_track_duplicate as well +++***+++***+++***+++***+++***+++***+++***+++***+++***+++*** */ /* below is for use by application */ guint64 usertype; gpointer userdata; /* functions called to duplicate/free userdata */ ItdbUserDataDuplicateFunc userdata_duplicate; ItdbUserDataDestroyFunc userdata_destroy; } Itdb_Track;
Structure representing a track in an iTunesDB
When adding string fields don't forget to add them in
itdb_track_duplicate()
as well.
Many of the parameter descriptions are copied verbatim from http://ipodlinux.org/ITunesDB, which is the best source for information about the iTunesDB and related files.
Itdb_iTunesDB * |
A pointer to the Itdb_iTunesDB (for convenience) |
gchar * |
The title of the track in UTF8 |
gchar * |
The file path on the iPod. Directories are separated with ":" instead of "/". The path is relative to the iPod mountpoint. |
gchar * |
The album name in UTF8 |
gchar * |
The artist name in UTF8 |
gchar * |
The genre in UTF8 |
gchar * |
A UTF8 string describing the file type. E.g. "MP3-File". |
gchar * |
A comment in UTF8 |
gchar * |
The category ("Technology", "Music", etc.) where the podcast was located. (Added in dbversion 0x0d) |
gchar * |
The composer name in UTF8 |
gchar * |
??? (UTF8) |
gchar * |
Description text (such as podcast show notes). (Added in dbversion 0x0d) |
gchar * |
Podcast Enclosure URL in UTF-8 or ASCII. (Added in dbversion 0x0d) |
gchar * |
Podcast RSS URL in UTF-8 or ASCII. (Added in dbversion 0x0d) |
Itdb_Chapterdata * |
This is an m4a-style entry that is used to display subsongs within a mhit. (Added in dbversion 0x0d) |
gchar * |
Subtitle (usually the same as Description). (Added in dbversion 0x0d) |
gchar * |
Name of the TV show (only used for TV Shows). (Added in dbversion 0x0d?) (Since libgpod-0.4.2) |
gchar * |
The episode number (only used for TV Shows). (Added in dbversion 0x0d?) (Since libgpod-0.4.2) |
gchar * |
The TV network (only used for TV Shows). (Added in dbversion 0x0d?) (Since libgpod-0.4.2) |
gchar * |
The album artist (Added in dbversion 0x13?) (Since libgpod-0.4.2) |
gchar * |
List of keywords pertaining to the track. (Added in dbversion 0x13?) (Since libgpod-0.4.2) |
gchar * |
The artist name used for sorting. Artists with names like "The Artist" would have "Artist, The" here. If you do not set this field, libgpod will pre-sort the lists displayed by the iPod according to "Artist, The", without setting this field. (Added in dbversion 0x13?) (Since libgpod-0.5.0) |
gchar * |
The track title used for sorting. See
sort_artist . (Since libgpod-0.5.0)
|
gchar * |
The album name used for sorting. See
sort_artist . (Since libgpod-0.5.0)
|
gchar * |
The album artist used for sorting. See
sort_artist . (Since libgpod-0.5.0)
|
gchar * |
The composer used for sorting. See
sort_artist . (Since libgpod-0.5.0)
|
gchar * |
The name of the TV show used for sorting. See
sort_artist . (Since libgpod-0.5.0)
|
guint32 |
Unique ID of track |
gint32 |
The size of the file in bytes |
gint32 |
The length of the track in ms |
gint32 |
The CD number the track comes from. |
gint32 |
The total number of CDs. |
gint32 |
The track number. |
gint32 |
The total number of tracks. |
gint32 |
The bitrate at which the file is encoded. |
guint16 |
The samplerate of the track (e.g. CD = 44100) |
guint16 |
In the iTunesDB the samplerate is multiplied by 0x10000 -- these are the lower 16 bit, which are usually 0 |
gint32 |
The year the track was released |
gint32 |
Volume adjustment field. This is a value from -255 to 255 that will be applied to the track on playback. |
guint32 |
The SoundCheck value to apply to the song, when SoundCheck is switched on in the iPod settings. The value for this field can be determined by the equation: X = 1000 * 10 ^ (-.1 * Y) where Y is the adjustment value in dB and X is the value that goes into the SoundCheck field. The value 0 is special, the equation is not used and it is treated as "no Soundcheck" (basically the same as the value 1000). This equation works perfectly well with ReplayGain derived data instead of the iTunes SoundCheck derived information. |
time_t |
The time the track was added. |
time_t |
The time the track was last modified |
time_t |
The time the track was last played |
guint32 |
The time, in milliseconds, that the track will start playing at. This is used for AudioBook filetypes (.aa and .m4b). Note that there is also a bookmark value in the play counts file that will be set by the iPod and can be used instead of this value. |
guint32 |
The track rating (stars * ITDB_RATING_STEP) |
guint32 |
The number of times the track has been played |
guint32 |
This also stores the play count of the
track. It is unclear if this ever differs
from the above value. During sync, this is set
to the same value as playcount .
|
guint32 |
The number of times the track was played since the last sync. |
gboolean |
Whether the file been transferred to iPod. |
gint16 |
BPM (beats per minute) of the track |
guint8 |
The last rating set by an application (e.g.
iTunes). If the rating on the iPod and the
rating field above differ, the original
rating is copied here and the new rating is
stored in rating .
|
guint8 |
CBR MP3s and AAC are 0x00, VBR MP3s are 0x01 |
guint8 |
MP3s are 0x01, AAC are 0x00 |
guint8 |
Flag to mark the track as a compilation. True if set to 0x1, false if set to 0x0. |
guint32 |
The time, in milliseconds, at which the song will start playing. |
guint32 |
The time, in milliseconds, at which the song will stop playing. |
guint8 |
Flag for whether the track is checked. True if set to 0x0, false if set to 0x1 |
guint64 |
Unique database ID that identifies this song across the databases on the iPod. For example, this id joins an iTunesDB mhit with an ArtworkDB mhii. |
guint32 |
Apple Store/Audible User ID (for DRM'ed files only, set to 0 otherwise). |
guint32 |
If this value is 1, the song is visible on the iPod. All other values cause the file to be hidden. |
guint32 |
This appears to always be 0 on hard drive based iPods, but for the iTunesDB that is written to an iPod Shuffle, iTunes 4.7.1 writes out the file's type as an ANSI string(!). For example, a MP3 file has a filetype of 0x4d503320 -> 0x4d = 'M', 0x50 = 'P', 0x33 = '3', 0x20 = <space>. This is set to the filename extension by libgpod when copying the track to the iPod. |
guint16 |
The number of album artwork items associated with this song. libgpod updates this value when syncing. |
guint32 |
The total size of artwork (in bytes) attached to this song, when it is converted to JPEG format. Observed in dbversion 0x0b and with an iPod Photo. libgpod updates this value when syncing. |
float |
The sample rate of the song expressed as an IEEE 32 bit floating point number. It is uncertain why this is here. libgpod will set this when adding a track. |
guint16 |
Unknown, but always seems to be 0xffff for MP3/AAC songs, 0x0 for uncompressed songs (like WAVE format), 0x1 for Audible. libgpod will try to set this when adding a new track. |
guint32 |
Unknown |
time_t |
The date/time the track was added to the iTunes music store? For podcasts this is the release date that is displayed next to the title in the Podcast playlist. |
guint16 |
Unknown, but MP3 songs appear to be always 0x000c, AAC songs are always 0x0033, Audible files are 0x0029, WAV files are 0x0. libgpod will attempt to set this value when adding a track. |
guint16 |
Flag to mark a track as "explicit" in iTunes. True if to 0x1, false if set to 0x0. |
guint32 |
Unknown - used for Apple Store DRM songs (always 0x01010100?), zero otherwise |
guint32 |
Unknown |
guint32 |
The number of times the track has been skipped. (Added in dbversion 0x0c) |
guint32 |
The number of times the track was skipped since the last sync. |
guint32 |
The time the track was last skipped. (Added in dbversion 0x0c) |
guint8 |
Whether the track has artwork. True if set to 0x01, false if set to 0x02. |
guint8 |
Flag to skip the track when shuffling. True if set to 0x01, false if set to 0x00. Audiobooks (.aa and .m4b) always seem to be skipped when shuffling, regardless of this flag. |
guint8 |
Flag to remember playback position. True when set to 0x01, false when set to 0x00. Audiobooks (.aa and .m4b) always seem to remember the playback position, regardless of this flag. |
guint8 |
Used for podcasts, 0x00 otherwise. If set to 0x01 the "Now Playing" page will show Title/Album, when set to 0x00 it will also show the Artist. When set to 0x02 a sub-page (middle button) with further information about the track will be shown. |
guint64 |
The purpose of the field is unclear. If not
set, libgpod will set this to the same value as
dbid when adding a track. (With iTunes, since
dbversion 0x12, this field value differs from
dbid .)
|
guint8 |
Whether the track has lyrics (e.g. it has a
USLT ID3 tag in an MP3 or a lyr atom in an
MP4). True if set to 0x01, false if set to
0x00.
|
guint8 |
Whether the track is a movie. True if set to 0x01, false if set to 0x00. |
guint8 |
A value of 0x02 marks a podcast as unplayed on the iPod, with a bullet. Once played it is set to 0x01. Non-podcasts have this set to 0x01. (Added in dbversion 0x0c) |
guint8 |
Unknown, always 0x00 so far. (Added in dbversion 0x0c) |
guint32 |
Unknown. (Added in dbversion 0x0c) |
guint32 |
The number of samples of silence before the track starts (for gapless playback). |
guint64 |
The number of samples in the track (for gapless playback). |
guint32 |
Unknown. (Added in dbversion 0x0c) |
guint32 |
The number of samples of silence at the end of the track (for gapless playback). |
guint32 |
Unknown. Appears to be 0x1 for files encoded using the MP3 encoder, 0x0 otherwise. (Added in dbversion 0x0c, first values observed in 0x0d.) |
guint32 |
The type of file. It must be set to 0x00000001
for audio files, and set to 0x00000002 for
video files. If set to 0x00, the files show up
in both, the audio menus ("Songs", "Artists",
etc.) and the video menus ("Movies", "Music
Videos", etc.). It appears to be set to 0x20
for music videos, and if set to 0x60 the file
shows up in "TV Shows" rather than "Movies".
The following list summarizes all observed types:
|
guint32 |
The season number of the track (only used for TV Shows). |
guint32 |
The episode number of the track (only used for TV Shows). Although this is not displayed on the iPod, the episodes are sorted by episode number. |
guint32 |
Unknown. This has something to do with protected files. It is set to 0x0 for non-protected files. |
guint32 |
Unknown. (Added in dbversion 0x0c) |
guint32 |
Unknown. (Added in dbversion 0x0c) |
guint32 |
Unknown. (Added in dbversion 0x0c) |
guint32 |
Unknown. (Added in dbversion 0x0c) |
guint32 |
Unknown. (Added in dbversion 0x0c) |
guint32 |
Unknown. (Added in dbversion 0x13) |
guint32 |
The size in bytes from first Synch Frame (which is usually the XING frame that includes the LAME tag) until the 8th before the last frame. The gapless playback does not work for MP3 files if this is set to zero. For AAC tracks, this may be zero. (Added in dbversion 0x13) |
guint32 |
Unknown. (Added in dbversion 0x0c) |
guint16 |
If set to 1, this track has gapless playback data. (Added in dbversion 0x13) |
guint16 |
If set to 1, this track does not use crossfading in iTunes. (Added in dbversion 0x13) |
guint16 |
The Album ID from the album list (currently unused by libgpod) |
struct _Itdb_Artwork * |
An Itdb_Artwork for cover art |
guint32 |
This is set to the id of the corresponding ArtworkDB mhii, used for sparse artwork support. (Since libgpod-0.7.0) |
gint32 |
Reserved for future use |
gint32 |
Reserved for future use |
gint32 |
Reserved for future use |
gint32 |
Reserved for future use |
gint32 |
Reserved for future use |
gint32 |
Reserved for future use |
gpointer |
Reserved for future use |
gpointer |
Reserved for future use |
gpointer |
Reserved for future use |
gpointer |
Reserved for future use |
gpointer |
Reserved for future use |
gpointer |
Reserved for future use |
guint64 |
For use by application |
gpointer |
For use by application |
ItdbUserDataDuplicateFunc |
A function to duplicate userdata |
ItdbUserDataDestroyFunc |
A function to free userdata |
typedef enum { ITDB_MEDIATYPE_AUDIO = 0x0001, ITDB_MEDIATYPE_MOVIE = 0x0002, ITDB_MEDIATYPE_PODCAST = 0x0004, ITDB_MEDIATYPE_AUDIOBOOK = 0x0008, ITDB_MEDIATYPE_MUSICVIDEO = 0x0020, ITDB_MEDIATYPE_TVSHOW = 0x0040, } Itdb_Mediatype;
Mediatype definitions
The mediatype is used to determine what menu a track appears under. For example, setting the mediatype to ITDB_MEDIATYPE_PODCAST makes the track appear on the Podcast menu.
Audio files | |
Movies | |
Podcasts | |
Audio books | |
Music videos | |
TV Shows |
Since 0.5.0
Itdb_Track* itdb_track_new (void);
Creates an empty Itdb_Track
Returns : |
the new Itdb_Track, free it with itdb_track_free() when no
longer needed
|
void itdb_track_free (Itdb_Track *track);
Frees the memory used by track
|
an Itdb_Track |
void itdb_track_add (Itdb_iTunesDB *itdb, Itdb_Track *track, gint32 pos);
Adds track
to itdb->tracks
at position pos
(or at the end if pos
is -1). The application is responsible to also add it to the master
playlist. The itdb
gets ownership of the track
and will take care of
freeing the memory it uses when it's no longer necessary.
|
an Itdb_iTunesDB |
|
an Itdb_Track |
|
position of the track to add |
void itdb_track_remove (Itdb_Track *track);
Removes track
from the Itdb_iTunesDB it's associated with, and frees the
memory it uses. It doesn't remove the track from the playlists it may have
been added to, in particular it won't be removed from the master playlist.
|
an Itdb_Track |
void itdb_track_unlink (Itdb_Track *track);
Removes track
from the Itdb_iTunesDB it's associated with, but do not free
memory. It doesn't remove the track from the playlists it may have been
added to, in particular it won't be removed from the master playlist.
track->itdb
is set to NULL.
|
an Itdb_Track |
Itdb_Track* itdb_track_duplicate (Itdb_Track *tr);
Duplicates an existing track
|
an Itdb_Track |
Returns : |
a newly allocated Itdb_Track |
Itdb_Track* itdb_track_by_id (Itdb_iTunesDB *itdb, guint32 id);
Looks up a track using its ID in itdb
.
Looking up tracks by ID is not really a good idea because the IDs are created by itdb just before export. The functions are here because they are needed during import of the iTunesDB which is referencing tracks by IDs.
This function is very slow (linear in the number of tracks
contained in the database). If you need to lookup many IDs use
itdb_track_id_tree_create()
, itdb_track_id_tree_destroy()
, and
itdb_track_id_tree_by_id()
.
|
an Itdb_iTunesDB |
|
ID of the track to look for |
Returns : |
Itdb_Track with the ID id or NULL if the ID cannot be
found.
|
GTree* itdb_track_id_tree_create (Itdb_iTunesDB *itdb);
Creates a balanced-binary tree for quick ID lookup that is used in
itdb_track_by_id_tree()
|
an Itdb_iTunesDB |
Returns : |
a GTree indexed by track IDs to be freed with
itdb_track_id_tree_destroy() when no longer used
|
void itdb_track_id_tree_destroy (GTree *idtree);
Frees the memory used by idtree
|
a GTree |
Itdb_Track* itdb_track_id_tree_by_id (GTree *idtree, guint32 id);
Lookup an Itdb_Track by id
using idtree
for faster lookup
(compared to itdb_track_by_id()
)
|
a GTree created using itdb_track_id_tree_create()
|
|
the ID of the track to search for |
Returns : |
the Itdb_Track whose ID is id , or NULL if such a track
couldn't be found
|
gpointer itdb_track_get_thumbnail (Itdb_Track *track, gint width, gint height);
Get a thumbnail representing the cover associated with the current track, scaling it if appropriate. If either height or width is -1, then the biggest unscaled thumbnail available will be returned.
|
an Itdb_Track |
|
width of the pixbuf to retrieve, -1 for the biggest possible size (with no scaling) |
|
height of the pixbuf to retrieve, -1 for the biggest possible size (with no scaling) |
Returns : |
a GdkPixbuf that must be unreffed when no longer used, NULL if no artwork could be found or if libgpod is compiled without GdkPixbuf support |
Since 0.7.0
gboolean itdb_track_has_thumbnails (Itdb_Track *track);
Determine if a track
has thumbnails
|
an Itdb_Track |
Returns : |
TRUE if track has artwork available, FALSE otherwise
|
Since 0.7.0
gboolean itdb_track_set_thumbnails (Itdb_Track *track, const gchar *filename);
Uses the image contained in filename
to generate iPod thumbnails. The image
can be in any format supported by gdk-pixbuf. To save memory, the thumbnails
will only be generated when necessary, i.e. when itdb_save()
or a similar
function is called.
|
an Itdb_Track |
|
image file to use as a thumbnail |
Returns : |
TRUE if the thumbnail could be added, FALSE otherwise. |
Since 0.3.0
gboolean itdb_track_set_thumbnails_from_data (Itdb_Track *track, const guchar *image_data, gsize image_data_len);
Uses image_data
to generate iPod thumbnails. The image can be in
any format supported by gdk-pixbuf. To save memory, the thumbnails
will only be generated when necessary, i.e. when itdb_save()
or a
similar function is called.
|
an Itdb_Track |
|
data used to create the thumbnail (the raw contents of an image file) |
|
length of above data block |
Returns : |
TRUE if the thumbnail could be added, FALSE otherwise. |
Since 0.4.0
gboolean itdb_track_set_thumbnails_from_pixbuf (Itdb_Track *track, gpointer pixbuf);
Uses pixbuf
to generate iPod thumbnails. To save memory, the thumbnails
will only be generated when necessary, i.e. when itdb_save()
or a
similar function is called.
|
an Itdb_Track |
|
a GdkPixbuf used to generate the thumbnail |
Returns : |
TRUE if the thumbnail could be added, FALSE otherwise. |
Since 0.5.0
void itdb_track_remove_thumbnails (Itdb_Track *track);
Removes the thumbnails associated with track
|
an Itdb_Track |
Since 0.3.0