• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

bindings/H03-May-2022-9,9828,050

docs/H03-May-2022-5,9144,321

m4/H03-May-2022-9,8358,847

po/H07-May-2022-9,3667,585

src/H03-May-2022-35,35125,360

tests/H03-May-2022-2,6212,010

tools/H03-May-2022-4,0863,340

AUTHORSH A D15-Apr-2011127 32

COPYINGH A D15-Apr-201124.7 KiB483400

ChangeLogH A D15-Apr-2011141 KiB4,3543,012

INSTALLH A D15-Apr-20119 KiB230175

Makefile.amH A D24-Jul-2011757 3021

Makefile.inH A D03-May-202230.3 KiB968866

NEWSH A D02-Sep-201312.9 KiB340244

READMEH A D15-Apr-20116.5 KiB152111

README.SysInfoH A D15-Apr-20113 KiB6647

README.overviewH A D15-Apr-20114.7 KiB10374

README.sqliteH A D15-Apr-20113.9 KiB8263

TROUBLESHOOTINGH A D15-Apr-20113.7 KiB11068

aclocal.m4H A D02-Sep-201372.1 KiB2,0691,879

compileH A D09-Jul-20137.2 KiB348258

config.guessH A D09-Jul-201344.2 KiB1,5591,352

config.h.inH A D02-Sep-20134.5 KiB175123

config.subH A D09-Jul-201334.7 KiB1,7891,651

configureH A D03-May-2022698.4 KiB23,39619,720

configure.acH A D10-Jul-201315.9 KiB445393

depcompH A D09-Jul-201323 KiB792502

gtk-doc.makeH A D02-Sep-20139.5 KiB303255

install-shH A D09-Jul-201313.7 KiB528351

libgpod-1.0.pc.inH A D15-Apr-2011328 1210

ltmain.shH A D02-Sep-2013276.8 KiB9,6567,304

missingH A D09-Jul-20136.7 KiB216143

py-compileH A D09-Jul-20134.6 KiB171124

README

1libgpod is a library meant to abstract access to an iPod content. It
2provides an easy to use API to retrieve the list of files and playlist
3stored on an iPod, to modify them and to save them back to the iPod.
4
5This code was originally part of gtkpod (www.gtkpod.org). When the iPod
6content parsing code was made to be self-contained with gtkpod 0.93,
7we chose to put this code in a separate library so that other project
8can benefit from it without duplicating code.
9
10Currently (2010-03-23) libgpod supports writing to all "classic" iPod models,
11all iPod Nanos, iPod Minis and iPhones and iPod Touch. iPod Nano 5th Gen. and
12iPhone/iPod Touch support is "partial" in the sense that a database with at
13least one song written by iTunes is needed the first time you use the iPod
14with libgpod. For these models, it's also highly recommended to get the
15provided udev/hal callout to work for proper support. Older iPod Shuffle models
16are supported, but the new button-less ones (3rd and 4th Gen.) are not. Please
17get in touch if you want to hack on adding support for that.
18
19For supported models, covert art and photos are supported in addition to
20manipulating the music database.
21
22If you decide to make improvements,  or have bug fixes to report or contribute,
23just drop a mail to Gtkpod-devel@lists.sourceforge.net (due to too much spam,
24the mailing list is unfortunately subscriber-only).
25
26----------------------------------------------------------------------
27
28Quick HOWTO use libgpod for audio
29
30itdb_parse(): read the iTunesDB and ArtworkDB
31itdb_write(): write the iTunesDB and ArtworkDB
32
33itdb_parse() will return a Itdb_iTunesDB structure with GLists
34containing all tracks (each track is represented by a Itdb_Track
35structure) and the playlists (each playlist is represented by a
36Itdb_Playlist structure).
37
38A number of functions for adding, removing, duplicating tracks are
39available. Please see itdb.h for details (itdb_track_*()).
40
41In each Itdb_Playlist structure you can find a GList called 'members'
42with listing all member tracks. Each track referenced in a playlist
43must also be present in the tracks GList of the iTunesDB.
44
45The iPod must contain one master playlist (MPL) containing all tracks
46accessible on the iPod through the
47Music->Tracks/Albums/Artists... menu. Besides the MPL there can be a
48number of normal playlists accessible through the Music->Playlists
49menu on the iPod. Tracks that are a member of one of these normal
50playlists must also be a member of the MPL.
51
52The Podcasts playlist is just another playlist with some internal
53flags set differently. Also, member tracks in the Podcasts playlist
54are not normally members of the MPL (so on the iPod they will only
55show up under the Podcasts menu). All tracks referenced must be in the
56tracklist of the Itdb_iTunesDB, however.
57
58A number of functions to add/remove playlists, or add/remove tracks
59are available. Please see itdb.h for details (itdb_playlist_*()).
60
61Each track can have a thumbnail associated with it. You can retrieve a
62GdkPixmap of the thumbnail using itdb_artwork_get_pixbuf().  You can
63remove a thumbnail with itdb_track_remove_thumbnails(). And finally,
64you can set a new thumbnail using itdb_track_set_thumbnails().
65
66Please note that iTunes additionally stores the artwork as tags in the
67original music file. That's also from where the data is read when
68artwork is displayed in iTunes, and there can be more than one piece
69of artwork. libgpod does not store the artwork as tags in the original
70music file. As a consequence, if iTunes attempts to access the
71artwork, it will find none, and remove libgpod's artwork. Luckily,
72iTunes will only attempt to access the artwork if you select a track
73in iTunes. (To work around this, gtkpod keeps a list of the original
74filename of all artwork and silently adds the thumbnails if they were
75'lost'. Your application might want to do something similar, or you
76can supply patches for (optionally!) adding tags to the original music
77files.)
78
79The Itdb_iTunesDB, Itdb_Playlist and Itdb_Track structures each have a
80userdata and a usertype field that can be used by the application to
81store application-specific additional data. If userdata is a pointer
82to an external structure, you can supply a ItdbUserDataDuplicateFunc
83and a ItdbUserDataDestroyFunc so that this data can be duplicated
84or freed automatically with a call to the library _duplicate()/_free()
85functions.
86
87For more information I would advice to have a look at gtkpod's source
88code. You can also ask questions on the developer's mailing list:
89gtkpod-devel at lists dot sourceforge dot net
90
91
92Jörg Schuler (jcsjcs at users dot sourceforge dot net)
93
94----------------------------------------------------------------------
95
96Quick HOWTO use libgpod for photos
97
98   itdb_photodb_parse():
99       Read an existing PhotoDB.
100
101   itdb_photodb_create():
102       Create a new Itdb_PhotoDB structure. The Photo Library Album is
103       (first album) is created automatically.
104
105   itdb_photodb_add_photo(), itdb_photodb_add_photo_from_data():
106       Add a photo to the PhotoDB (from file or from a chunk of
107       memory). It is automatically added to the Photo Library Album
108       (first album), which is created if it does not exist already.
109
110   itdb_photodb_photoalbum_create():
111       Create and add a new photoalbum.
112
113   itdb_photodb_photoalbum_add_photo():
114       Add a photo (Itdb_Artwork) to an existing photoalbum.
115
116   itdb_photodb_photoalbum_remove():
117       Remove an existing photoalbum. Pictures can be kept in the
118       Photo Library or automatically removed as well.
119
120   itdb_photodb_remove_photo():
121       Remove a photo either from a photoalbum or completely from the database.
122
123   itdb_photodb_write():
124       Write out your PhotoDB.
125
126   itdb_photodb_free():
127       Free all memory taken by the PhotoDB.
128
129   itdb_photodb_photoalbum_by_name():
130       Find the first photoalbum with a given name or the Photo
131       Library Album if called with no name.
132
133
134If you cannot add photos because your iPod is not recognized, you may
135have to set the iPod model by calling
136
137itdb_device_set_sysinfo (db->device, "ModelNumStr", model);
138
139For example, "MA450" would stand for an 80 GB 6th generation iPod
140Video. See itdb_device.c for a list of supported models.
141
142This information will be written to the iPod when the PhotoDB is saved
143(itdb_device_write_sysinfo() is called).
144
145Have a look at the following test-photos test program in the tests/
146subdirectory for an example of how to use the interface.
147
148
149Jörg Schuler (jcsjcs at users dot sourceforge dot net)
150
151----------------------------------------------------------------------
152

README.SysInfo

1Starting with the iPod Classics and the Video Nanos, libgpod needs an
2additional configuration step to correctly modify the iPod content. libgpod
3needs to know the so-called iPod "firewire id", otherwise the iPod won't
4recognize what libgpod wrote to it and will behave as if it's empty.
5
6There are several ways to set up an iPod so libgpod can find its firewire id.
7
8The preferred method is automatic. Make sure you have hal and libsgutils
9installed before running configure/autogen.sh. If you built libgpod without
10them, run configure/make/make install after you install them.
11
12A hal callout and .fdi file will be built and installed. This will query an
13iPod when it is plugged in and save the SysInfoExtended file in the proper
14place. This should be entirely automatic. If you have trouble with this, see
15the TROUBLESHOOTING file for some hints.
16
17If you build with libsgutils but without hal, the next best method is mostly
18automatic. You should have an ipod-read-sysinfo-extended tool available. Run
19it with the iPod device path and the iPod mount point /mnt/ipod) as arguments.
20For example:
21
22    $ ipod-read-sysinfo-extended /dev/sda /mnt/ipod
23
24This may require root privileges. It reads an XML file from the iPod and
25writes it as /mnt/ipod/iPod_Control/Device/SysInfoExtended. More details on
26this method can be found at http://ipodlinux.org/Device_Information.
27
28Having the SysInfoExtended file created by ipod-read-sysinfo-extended or the
29hal callout is enough for libgpod to figure out the iPod firewire id.
30
31The last method requires more manual intervention. First, you need to
32determine the firewire id of the iPod. To do that on Linux, plug in the iPod
33in and run (with root privileges):
34
35    $ lsusb -v | grep -i Serial
36
37This should print a 16 character long string like 00A1234567891231. For an
38iPod Touch, this number will be much longer than 16 characters, the firewire
39ID is constituted by the first 16 characters.
40
41On FreeBSD, there is a tool to get the serial number at:
42
43    http://50hz.ws/dev/getserial.c
44
45Once you have the serial number, edit /mnt/ipod/iPod_Control/Device/SysInfo,
46creating the file if it does not exist. (Replace /mnt/ipod with the path to
47where the iPod is mounted). Add a line like this to the SysInfo file:
48
49FirewireGuid: 0xffffffffffffffff
50
51Replace ffffffffffffffff with the serial number you obtained in the previous
52step. Don't forget the 0x before the string. After you add the FirewireGuid to
53the SysInfo file you need to rewrite the iTunesDB for the change to take
54effect. For example, add a new song or adjust the playcount of an existing
55song and save the changes in gtkpod.
56
57Be careful when using applications which let you manually specify the iPod
58model. They may overwrite the SysInfo file and undo the changes.
59
60Finally, if you compiled libgpod from source, you can test that libgpod can
61find the firewire ID on the iPod using the test-firewire-id program in the
62tests/ dir of the libgpod source. For example:
63
64    $ cd ~/src/libgpod/tests
65    $ ./test-firewire-id /ipod/mount/point
66

README.overview

1Introduction:
2
3The goal of this document is to provide an overview of the various parts/files
4involved when libgpod interacts with a device. Ideally it will be helpful to
5help application writers/distributors/... figure out what's going wrong when
6trying to interact with an iPod-like device.
7
8Please note that not all devices need all these steps (especially the
9hash58/hash72 stuff and the sqlite databases), see the table at the end for
10more details
11
12
13Overview:
14
15* device is plugged in
16
17HAL/udev detects the insertion and runs a callout. This callout sends the
18appropriate commands (raw SCSI/USB commands or special AFC command) to the
19device to get an XML file describing the device capabilities (artwork formats
20supported, serial number, ...) and dumps this XML file to
21iPod_Control/Device/SysInfoExtended for future use by libgpod. libgpod doesn't
22do it directly because sending these SCSI/USB commands might need elevated
23priviledges.
24
25* the application uses libgpod to read the device content
26
27iPod_Control/iTunes/iTunesDB is accessed as well as a few other files. If
28the device needs an hash72 (either in its iTunesDB or because it's using sqlite
29databases), then the necessary information is extracted from the existing
30iTunesDB to generate an iPod_Control/Device/HashInfo file (if it doesn't
31exist) which will be useful to generate any hash72 we need for this device.
32
33* the application uses libgpod to write to the device
34
35libgpod generates an iPod_Control/iTunes/iTunesDB file. If an hash58 is needed
36then the device FirewireID is used to generate it. If an hash72 is needed
37then the HashInfo file is used to generate it. If the device uses sqlite
38databases, they are generated as well. Post process SQL commands are then
39extracted from the device (either by getting them from SysInfoExtended or by
40getting them through AFC) and executed after the sqlite database generation.
41These post process commands are useful to make sure the sqlite databases layout
42matches what the current device firmware expects.
43
44
45Glossary:
46
47iTunesDB: binary file containing information about all the songs, playlists, ...
48stored on the device. On recent devices (iPhoneOS 3.x, Nano 5g), it's replaced
49by iTunesCDB which is a compressed version of iTunesDB.
50
51sqlite: recent devices (iPhoneOS 3.x, Nano5g) use sqlite databases instead
52of an iTunesDB to store song information, playlists, ... More accurately, they
53have both an iTunesCDB (compressed iTunesDB) used by iTunes to know the device
54content and sqlite databases used by the device. Along with these sqlite
55databases, there's a .cbk file which contains checksum information and a hash72
56for the sqlite data.
57
58iPhoneOS: umbrella for iPhone-like devices, ie iPhones, iPod Touch and (likely)
59iPad. On these devices, what matters is the firmware version, not the device
60type.
61
62hash58: first iTunesDB hashing scheme introduced by Apple. It appeared in the
63iPod Nano Video (3g)  and iPod Classic and was used by iPhoneOS 1.x. It's fully
64reverse-engineered and uses the iPod FirewireID (called this way even on USB
65devices) as part of the calculation.
66
67hash72: hashing scheme that was first introduced in iPhoneOS 2.x and has then
68been used on the iPod Nano with a camera (5g). It was much more complicated to
69reverse engineer and is not yet 100% known. However, given a file with a valid
70hash72, we can extract some hashing data to be able to generate valid hash72
71hashes for any file.
72
73
74
75iPod feature matrix:
76
77		SysInfoExtended   hash58   hash72   sqlite   iTunesCDB
78iPod 1G	                     no       no       no       no          no
79iPod 2G	                     no       no       no       no          no
80iPod 3G	                     no       no       no       no          no
81Mini 1G	                     no       no       no       no          no
82Mini 2G	                     no       no       no       no          no
83
84iPod 4G                     yes       no       no       no          no
85iPod 5G                     yes       no       no       no          no
86Nano 1G                     yes       no       no       no          no
87Nano 2G                     yes       no       no       no          no
88
89iPod Classic                yes      yes       no       no          no
90Nano3G                      yes      yes       no       no          no
91Nano4G                      yes      yes       no       no          no
92iPhoneOS 1.x                yes      yes       no       no          no
93
94iPhoneOS 2.x                yes       no      yes       no          no
95
96Nano5G                      yes   yes[1]      yes      yes         yes
97iPhoneOS 3.x                yes       no      yes      yes         yes
98
99
100[1] surprisingly, the Nano5G uses a hash58 for its iTunesCDB and a hash72
101for its sqlite cbk file. iPhoneOS 3.x uses hash72 everywhere.
102
103

README.sqlite

1* Summary
2
3For things to work with an iPod Nano 5G or an iPhone/iTouch, you need
4  - an iPod_Control/Device/SysInfoExtended file (Nano5G) or
5  - an iTunes_Control/Device/SysInfoExtended file
6This file should be created when the device is plugged in. If not, you can
7generate it manually using ipod-read-sysinfo-extended (passing the device UUID
8as an argument for an iPhone/iPod Touch and the USB bus and device number for
9a Nano 5G). On a Nano5G, passing the device node (/dev/sdb) to
10ipod-read-sysinfo-extended won't work. On a Nano5G, SysInfoExtended should be
11a few dozen kilobytes in size.
12
13You also need a database generated by iTunes on your iPod when you first plug
14it in. When libgpod reads this database, it will generate
15  - an iPod_Control/Device/HashInfo file (Nano5G) or
16  - an iTunes_Control/Device/HashInfo file (iPhone/iPod Touch)
17which is required to write to the device.
18
19
20
21* sqlite
22
23New iPod models (iPhone/iPod Touch on the one hand, Nano 5G on the other hand)
24contain both a compressed version of the usual iTunesDB (the iTunesCDB file)
25and sqlite databases. The iTunesCDB file is used by iTunes while the sqlite
26databases are used by the device. The sqlite databases use the .itdb extension
27and can be found in iPod_Control/iTunes/iTunes Library/
28(iTunes_Control/iTunes/iTunes Library/ on devices using the iPhone OS). Both
29use some kind of checksum.
30
31The iTunesCDB file is checksummed either with a hash58 (old hash introduced
32with the first iPod Classic and the Nano 3g) or a hash72 (new hash introduced
33with iPhone OS 2.x). The hash58 is used on the Nano 5G while the hash72 is
34used on the iPhone/iPod Touch.
35
36The sqlite databases are checksummed through the use of a .cbk file. This file
37only checksums the content of the Location.itdb sqlite database and uses the
38hash72 on the iPhone/iPod Touch and the Nano 5G.
39
40
41* HashInfo
42
43The HashInfo file can be found in iPod_Control/Device/HashInfo
44(iTunes_Control/Device/HashInfo for an iPhone/iPod Touch). At the moment,
45it's not known how to generate a checksum for the iPod database from scratch.
46However, for a given iPod, we can extract the necessary data from a database
47generated by iTunes to be able to generate a checksum for any other database
48for this iPod.
49libgpod extracts this data the first time it reads a database on an iPod (so
50it assumes this database was generated by iTunes) and dumps it to the HashInfo
51file (very simple format, see the struct Hash78Info in src/itdb_hash72.c).
52Then libgpod can reuse the information from that file to write valid databases
53for the iPod the HashInfo was generated on.
54
55
56* SysInfoExtended
57
58The SysInfoExtended file is stored in iPod_Control/Device/SysInfoExtended
59(iTunes_Control/Device/SysInfoExtended on iPhone/iPod Touch). This file isn't
60a standard iPod file, it's generated using some data available on the iPod
61and dumped there because it's more convenient for libgpod. It's an XML file
62containing lots of data about the iPod (serial number, support image and video
63formats, ...). libgpod installs a HAL/udev callout to automatically generate
64this file when an iPod is plugged in, but it can also be done manually by
65using the ipod-read-sysinfo-extended tool.
66This file is required on the Nano 5G because it contains SQL commands that
67have to be run to generate sqlite databases that the device will be able to
68handle.
69The iPhone/iPod Touch need similar SQL commands to be run, but they are not
70stored in SysInfoExtended, they are extracted from the device when needed.
71
72
73On the iPhone/iPod Touch, the data for the SysInfoExtended file can be
74obtained by asking for the right lockdown key through the usbmux daemon.
75On the Nano5G, things are a bit more tricky. Older iPods models used to
76make that data available through a SCSI inquiry command. This command works
77on the Nano5G too, but it returns really partial data (no SQL post-process
78commands, no artwork format information, ...). The full data can be obtained
79through an USB Control command (see tools/ipod-usb.c for more details).
80
81
82