blob: 1191cfa045aab7ee8b3d8baf08b2a6b440049d5f [file] [log] [blame]
Linus Walleij6d6d8f62006-02-13 13:21:57 +00001#include "common.h"
2
3static void dump_trackinfo(LIBMTP_track_t *track)
4{
Linus Walleij64ad9ae2006-11-27 11:23:26 +00005 printf("Track ID: %u\n", track->item_id);
Linus Walleij6d6d8f62006-02-13 13:21:57 +00006 if (track->title != NULL)
7 printf(" Title: %s\n", track->title);
8 if (track->artist != NULL)
9 printf(" Artist: %s\n", track->artist);
10 if (track->genre != NULL)
11 printf(" Genre: %s\n", track->genre);
12 if (track->album != NULL)
13 printf(" Album: %s\n", track->album);
14 if (track->date != NULL)
15 printf(" Date: %s\n", track->date);
16 if (track->filename != NULL)
17 printf(" Origfilename: %s\n", track->filename);
18 printf(" Track number: %d\n", track->tracknumber);
19 printf(" Duration: %d milliseconds\n", track->duration);
20 printf(" File size %llu bytes\n", track->filesize);
Linus Walleij16c51f02006-05-04 13:20:22 +000021 printf(" Filetype: %s\n", LIBMTP_Get_Filetype_Description(track->filetype));
Linus Walleijcf223e62006-06-19 09:31:53 +000022 if (track->samplerate != 0) {
23 printf(" Sample rate: %u Hz\n", track->samplerate);
24 }
25 if (track->nochannels != 0) {
26 printf(" Number of channels: %u\n", track->nochannels);
27 }
28 if (track->wavecodec != 0) {
29 printf(" WAVE fourCC code: 0x%08X\n", track->wavecodec);
30 }
31 if (track->bitrate != 0) {
32 printf(" Bitrate: %u bits/s\n", track->bitrate);
33 }
34 if (track->bitratetype != 0) {
35 if (track->bitratetype == 1) {
36 printf(" Bitrate type: Constant\n");
37 } else if (track->bitratetype == 2) {
38 printf(" Bitrate type: Variable (VBR)\n");
39 } else if (track->bitratetype == 3) {
40 printf(" Bitrate type: Free\n");
41 } else {
42 printf(" Bitrate type: Unknown/Erroneous value\n");
43 }
44 }
45 if (track->rating != 0) {
46 printf(" User rating: %u (out of 100)\n", track->rating);
47 }
48 if (track->usecount != 0) {
49 printf(" Use count: %u times\n", track->usecount);
50 }
Linus Walleij6d6d8f62006-02-13 13:21:57 +000051}
52
53int main (int argc, char **argv)
54{
55 LIBMTP_mtpdevice_t *device;
56 LIBMTP_track_t *tracks;
Linus Walleij6d6d8f62006-02-13 13:21:57 +000057
58 LIBMTP_Init();
59 device = LIBMTP_Get_First_Device();
60 if (device == NULL) {
61 printf("No devices.\n");
62 exit (0);
63 }
64
65 // Get track listing.
Richard Lowe1ab2642006-11-14 08:34:49 +000066 tracks = LIBMTP_Get_Tracklisting_With_Callback(device, NULL, NULL);
Linus Walleij6d6d8f62006-02-13 13:21:57 +000067 if (tracks == NULL) {
68 printf("No tracks.\n");
69 } else {
70 LIBMTP_track_t *track, *tmp;
71 track = tracks;
72 while (track != NULL) {
73 dump_trackinfo(track);
74 tmp = track;
75 track = track->next;
76 LIBMTP_destroy_track_t(tmp);
77 }
78 }
79
80 LIBMTP_Release_Device(device);
81 printf("OK.\n");
82 exit (0);
83}
84