00001 #include "common.h"
00002
00003 static void dump_trackinfo(LIBMTP_track_t *track)
00004 {
00005 printf("Track ID: %d\n", track->item_id);
00006 if (track->title != NULL)
00007 printf(" Title: %s\n", track->title);
00008 if (track->artist != NULL)
00009 printf(" Artist: %s\n", track->artist);
00010 if (track->genre != NULL)
00011 printf(" Genre: %s\n", track->genre);
00012 if (track->album != NULL)
00013 printf(" Album: %s\n", track->album);
00014 if (track->date != NULL)
00015 printf(" Date: %s\n", track->date);
00016 if (track->filename != NULL)
00017 printf(" Origfilename: %s\n", track->filename);
00018 printf(" Track number: %d\n", track->tracknumber);
00019 printf(" Duration: %d milliseconds\n", track->duration);
00020 printf(" File size %llu bytes\n", track->filesize);
00021 printf(" Filetype: %s\n", LIBMTP_Get_Filetype_Description(track->filetype));
00022 if (track->samplerate != 0) {
00023 printf(" Sample rate: %u Hz\n", track->samplerate);
00024 }
00025 if (track->nochannels != 0) {
00026 printf(" Number of channels: %u\n", track->nochannels);
00027 }
00028 if (track->wavecodec != 0) {
00029 printf(" WAVE fourCC code: 0x%08X\n", track->wavecodec);
00030 }
00031 if (track->bitrate != 0) {
00032 printf(" Bitrate: %u bits/s\n", track->bitrate);
00033 }
00034 if (track->bitratetype != 0) {
00035 if (track->bitratetype == 1) {
00036 printf(" Bitrate type: Constant\n");
00037 } else if (track->bitratetype == 2) {
00038 printf(" Bitrate type: Variable (VBR)\n");
00039 } else if (track->bitratetype == 3) {
00040 printf(" Bitrate type: Free\n");
00041 } else {
00042 printf(" Bitrate type: Unknown/Erroneous value\n");
00043 }
00044 }
00045 if (track->rating != 0) {
00046 printf(" User rating: %u (out of 100)\n", track->rating);
00047 }
00048 if (track->usecount != 0) {
00049 printf(" Use count: %u times\n", track->usecount);
00050 }
00051 }
00052
00053 int main (int argc, char **argv)
00054 {
00055 LIBMTP_mtpdevice_t *device;
00056 LIBMTP_track_t *tracks;
00057
00058 LIBMTP_Init();
00059 device = LIBMTP_Get_First_Device();
00060 if (device == NULL) {
00061 printf("No devices.\n");
00062 exit (0);
00063 }
00064
00065
00066 tracks = LIBMTP_Get_Tracklisting(device);
00067 if (tracks == NULL) {
00068 printf("No tracks.\n");
00069 } else {
00070 LIBMTP_track_t *track, *tmp;
00071 track = tracks;
00072 while (track != NULL) {
00073 dump_trackinfo(track);
00074 tmp = track;
00075 track = track->next;
00076 LIBMTP_destroy_track_t(tmp);
00077 }
00078 }
00079
00080 LIBMTP_Release_Device(device);
00081 printf("OK.\n");
00082 exit (0);
00083 }
00084