Linus Walleij | 6d6d8f6 | 2006-02-13 13:21:57 +0000 | [diff] [blame] | 1 | #include "common.h" |
| 2 | |
| 3 | static void dump_trackinfo(LIBMTP_track_t *track) |
| 4 | { |
Linus Walleij | 64ad9ae | 2006-11-27 11:23:26 +0000 | [diff] [blame^] | 5 | printf("Track ID: %u\n", track->item_id); |
Linus Walleij | 6d6d8f6 | 2006-02-13 13:21:57 +0000 | [diff] [blame] | 6 | 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 Walleij | 16c51f0 | 2006-05-04 13:20:22 +0000 | [diff] [blame] | 21 | printf(" Filetype: %s\n", LIBMTP_Get_Filetype_Description(track->filetype)); |
Linus Walleij | cf223e6 | 2006-06-19 09:31:53 +0000 | [diff] [blame] | 22 | 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 Walleij | 6d6d8f6 | 2006-02-13 13:21:57 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | int main (int argc, char **argv) |
| 54 | { |
| 55 | LIBMTP_mtpdevice_t *device; |
| 56 | LIBMTP_track_t *tracks; |
Linus Walleij | 6d6d8f6 | 2006-02-13 13:21:57 +0000 | [diff] [blame] | 57 | |
| 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 Low | e1ab264 | 2006-11-14 08:34:49 +0000 | [diff] [blame] | 66 | tracks = LIBMTP_Get_Tracklisting_With_Callback(device, NULL, NULL); |
Linus Walleij | 6d6d8f6 | 2006-02-13 13:21:57 +0000 | [diff] [blame] | 67 | 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 | |