00001
00010 #ifndef LIBMTP_H_INCLUSION_GUARD
00011 #define LIBMTP_H_INCLUSION_GUARD
00012
00013 #define LIBMTP_VERSION 0.0.18
00014
00015
00016 #ifdef _MSC_VER
00017 #include <windows.h>
00018 #define __WIN32__
00019 #define snprintf _snprintf
00020 #define ssize_t SSIZE_T
00021 #endif
00022
00023 #include <stdio.h>
00024 #include <usb.h>
00025 #include <stdint.h>
00026
00027 #ifdef __WIN32__
00028
00029
00030
00031
00032 typedef char int8_t;
00033 typedef unsigned char uint8_t;
00034 typedef __int16 int16_t;
00035 typedef unsigned __int16 uint16_t;
00036 typedef __int32 int32_t;
00037 typedef unsigned __int32 uint32_t;
00038 typedef unsigned __int64 uint64_t;
00039 #endif
00040
00048 typedef enum {
00049 LIBMTP_FILETYPE_WAV,
00050 LIBMTP_FILETYPE_MP3,
00051 LIBMTP_FILETYPE_WMA,
00052 LIBMTP_FILETYPE_OGG,
00053 LIBMTP_FILETYPE_AUDIBLE,
00054 LIBMTP_FILETYPE_MP4,
00055 LIBMTP_FILETYPE_UNDEF_AUDIO,
00056 LIBMTP_FILETYPE_WMV,
00057 LIBMTP_FILETYPE_AVI,
00058 LIBMTP_FILETYPE_MPEG,
00059 LIBMTP_FILETYPE_ASF,
00060 LIBMTP_FILETYPE_QT,
00061 LIBMTP_FILETYPE_UNDEF_VIDEO,
00062 LIBMTP_FILETYPE_JPEG,
00063 LIBMTP_FILETYPE_JFIF,
00064 LIBMTP_FILETYPE_TIFF,
00065 LIBMTP_FILETYPE_BMP,
00066 LIBMTP_FILETYPE_GIF,
00067 LIBMTP_FILETYPE_PICT,
00068 LIBMTP_FILETYPE_PNG,
00069 LIBMTP_FILETYPE_VCALENDAR1,
00070 LIBMTP_FILETYPE_VCALENDAR2,
00071 LIBMTP_FILETYPE_VCARD2,
00072 LIBMTP_FILETYPE_VCARD3,
00073 LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT,
00074 LIBMTP_FILETYPE_WINEXEC,
00075 LIBMTP_FILETYPE_TEXT,
00076 LIBMTP_FILETYPE_HTML,
00077 LIBMTP_FILETYPE_UNKNOWN
00078 } LIBMTP_filetype_t;
00079 typedef struct LIBMTP_device_entry_struct LIBMTP_device_entry_t;
00080 typedef struct LIBMTP_mtpdevice_struct LIBMTP_mtpdevice_t;
00081 typedef struct LIBMTP_file_struct LIBMTP_file_t;
00082 typedef struct LIBMTP_track_struct LIBMTP_track_t;
00083 typedef struct LIBMTP_playlist_struct LIBMTP_playlist_t;
00084 typedef struct LIBMTP_folder_struct LIBMTP_folder_t;
00085 typedef struct LIBMTP_object_struct LIBMTP_object_t;
00097 typedef int (* LIBMTP_progressfunc_t) (uint64_t const sent, uint64_t const total,
00098 void const * const data);
00099
00109 struct LIBMTP_device_entry_struct {
00110 char *name;
00111 uint16_t vendor_id;
00112 uint16_t product_id;
00113 uint32_t device_flags;
00114 };
00115
00119 struct LIBMTP_mtpdevice_struct {
00121 uint8_t interface_number;
00126 void *params;
00131 void *usbinfo;
00133 unsigned storage_id;
00135 uint8_t maximum_battery_level;
00137 uint32_t default_music_folder;
00139 uint32_t default_playlist_folder;
00141 uint32_t default_picture_folder;
00143 uint32_t default_video_folder;
00145 uint32_t default_organizer_folder;
00147 uint32_t default_zencast_folder;
00149 void *cd;
00150 };
00151
00155 struct LIBMTP_file_struct {
00156 uint32_t item_id;
00157 uint32_t parent_id;
00158 char *filename;
00159 uint64_t filesize;
00160 LIBMTP_filetype_t filetype;
00161 LIBMTP_file_t *next;
00162 };
00163
00167 struct LIBMTP_track_struct {
00168 uint32_t item_id;
00169 char *title;
00170 char *artist;
00171 char *genre;
00172 char *album;
00173 char *date;
00174 char *filename;
00175 uint16_t tracknumber;
00176 uint32_t duration;
00177 uint32_t samplerate;
00178 uint16_t nochannels;
00179 uint32_t wavecodec;
00180 uint32_t bitrate;
00181 uint16_t bitratetype;
00182 uint16_t rating;
00183 uint32_t usecount;
00184 uint64_t filesize;
00185 LIBMTP_filetype_t filetype;
00186 LIBMTP_track_t *next;
00187 };
00188
00192 struct LIBMTP_playlist_struct {
00193 uint32_t playlist_id;
00194 char *name;
00195 uint32_t *tracks;
00196 uint32_t no_tracks;
00197 LIBMTP_playlist_t *next;
00198 };
00199
00203 struct LIBMTP_folder_struct {
00204 uint32_t folder_id;
00205 uint32_t parent_id;
00206 char *name;
00207 LIBMTP_folder_t *sibling;
00208 LIBMTP_folder_t *child;
00209 };
00210
00214 struct LIBMTP_object_struct {
00215 uint32_t id;
00216 uint32_t parent;
00217 uint32_t type;
00218 uint32_t size;
00219 char *name;
00220 void *data;
00221 LIBMTP_object_t *sibling;
00222 LIBMTP_object_t *child;
00223 };
00224
00227
00228 #ifdef __cplusplus
00229 extern "C" {
00230 #endif
00231
00236 void LIBMTP_Init(void);
00237 int LIBMTP_Get_Supported_Devices_List(LIBMTP_device_entry_t ** const, int * const);
00243 int LIBMTP_Detect_Descriptor(uint16_t*,uint16_t*);
00244 LIBMTP_mtpdevice_t *LIBMTP_Get_First_Device(void);
00245 void LIBMTP_Release_Device(LIBMTP_mtpdevice_t*);
00246 void LIBMTP_Dump_Device_Info(LIBMTP_mtpdevice_t*);
00247 char *LIBMTP_Get_Modelname(LIBMTP_mtpdevice_t*);
00248 char *LIBMTP_Get_Serialnumber(LIBMTP_mtpdevice_t*);
00249 char *LIBMTP_Get_Deviceversion(LIBMTP_mtpdevice_t*);
00250 char *LIBMTP_Get_Friendlyname(LIBMTP_mtpdevice_t*);
00251 int LIBMTP_Set_Friendlyname(LIBMTP_mtpdevice_t*, char const * const);
00252 char *LIBMTP_Get_Syncpartner(LIBMTP_mtpdevice_t*);
00253 int LIBMTP_Set_Syncpartner(LIBMTP_mtpdevice_t*, char const * const);
00254 int LIBMTP_Get_Storageinfo(LIBMTP_mtpdevice_t *, uint64_t * const,
00255 uint64_t * const, char ** const storage_description,
00256 char ** const volume_label);
00257 int LIBMTP_Get_Batterylevel(LIBMTP_mtpdevice_t *,
00258 uint8_t * const,
00259 uint8_t * const);
00260 int LIBMTP_Get_Secure_Time(LIBMTP_mtpdevice_t *, char ** const);
00261 int LIBMTP_Get_Device_Certificate(LIBMTP_mtpdevice_t *, char ** const);
00262 int LIBMTP_Get_Supported_Filetypes(LIBMTP_mtpdevice_t *, uint16_t ** const, uint16_t * const);
00263
00269 LIBMTP_file_t *LIBMTP_new_file_t(void);
00270 void LIBMTP_destroy_file_t(LIBMTP_file_t*);
00271 char const * LIBMTP_Get_Filetype_Description(LIBMTP_filetype_t);
00272 LIBMTP_file_t *LIBMTP_Get_Filelisting(LIBMTP_mtpdevice_t *);
00273 LIBMTP_file_t *LIBMTP_Get_Filemetadata(LIBMTP_mtpdevice_t *, uint32_t const);
00274 int LIBMTP_Get_File_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
00275 LIBMTP_progressfunc_t const, void const * const);
00276 int LIBMTP_Get_File_To_File_Descriptor(LIBMTP_mtpdevice_t*, uint32_t const, int const,
00277 LIBMTP_progressfunc_t const, void const * const);
00278 int LIBMTP_Send_File_From_File(LIBMTP_mtpdevice_t *, char const * const,
00279 LIBMTP_file_t * const, LIBMTP_progressfunc_t const,
00280 void const * const, uint32_t const);
00281 int LIBMTP_Send_File_From_File_Descriptor(LIBMTP_mtpdevice_t *, int const,
00282 LIBMTP_file_t * const, LIBMTP_progressfunc_t const,
00283 void const * const, uint32_t const);
00289 LIBMTP_track_t *LIBMTP_new_track_t(void);
00290 void LIBMTP_destroy_track_t(LIBMTP_track_t*);
00291 LIBMTP_track_t *LIBMTP_Get_Tracklisting(LIBMTP_mtpdevice_t*);
00292 LIBMTP_track_t *LIBMTP_Get_Trackmetadata(LIBMTP_mtpdevice_t*, uint32_t const);
00293 int LIBMTP_Get_Track_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
00294 LIBMTP_progressfunc_t const, void const * const);
00295 int LIBMTP_Get_Track_To_File_Descriptor(LIBMTP_mtpdevice_t*, uint32_t const, int const,
00296 LIBMTP_progressfunc_t const, void const * const);
00297 int LIBMTP_Send_Track_From_File(LIBMTP_mtpdevice_t *,
00298 char const * const, LIBMTP_track_t * const,
00299 LIBMTP_progressfunc_t const,
00300 void const * const, uint32_t const);
00301 int LIBMTP_Send_Track_From_File_Descriptor(LIBMTP_mtpdevice_t *,
00302 int const, LIBMTP_track_t * const,
00303 LIBMTP_progressfunc_t const,
00304 void const * const, uint32_t const);
00305 int LIBMTP_Update_Track_Metadata(LIBMTP_mtpdevice_t *,
00306 LIBMTP_track_t const * const);
00307 int LIBMTP_Track_Exists(LIBMTP_mtpdevice_t *, uint32_t);
00315 LIBMTP_folder_t *LIBMTP_new_folder_t(void);
00316 void LIBMTP_destroy_folder_t(LIBMTP_folder_t*);
00317 LIBMTP_folder_t *LIBMTP_Get_Folder_List(LIBMTP_mtpdevice_t*);
00318 LIBMTP_folder_t *LIBMTP_Find_Folder(LIBMTP_folder_t*, uint32_t const);
00319 uint32_t LIBMTP_Create_Folder(LIBMTP_mtpdevice_t*, char *, uint32_t);
00328 LIBMTP_playlist_t *LIBMTP_new_playlist_t(void);
00329 void LIBMTP_destroy_playlist_t(LIBMTP_playlist_t *);
00330 LIBMTP_playlist_t *LIBMTP_Get_Playlist_List(LIBMTP_mtpdevice_t *);
00331 LIBMTP_playlist_t *LIBMTP_Get_Playlist(LIBMTP_mtpdevice_t *, uint32_t const);
00332 int LIBMTP_Create_New_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const, uint32_t const);
00333 int LIBMTP_Update_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t const * const);
00334
00335
00341 char *LIBMTP_Get_String_From_Object(LIBMTP_mtpdevice_t *,const uint32_t, const uint32_t);
00342 uint32_t LIBMTP_Get_U32_From_Object(LIBMTP_mtpdevice_t *,const uint32_t, const uint32_t, const uint32_t);
00343 uint16_t LIBMTP_Get_U16_From_Object(LIBMTP_mtpdevice_t *,const uint32_t, const uint32_t, const uint16_t);
00344 int LIBMTP_Set_Object_String(LIBMTP_mtpdevice_t *,const uint32_t,const uint32_t,
00345 char const * const);
00346 int LIBMTP_Set_Object_U32(LIBMTP_mtpdevice_t *,const uint32_t, const uint32_t, const uint32_t);
00347 int LIBMTP_Set_Object_U16(LIBMTP_mtpdevice_t *,const uint32_t, const uint32_t, const uint16_t);
00348 int LIBMTP_Get_Object_References(LIBMTP_mtpdevice_t *, const uint32_t, uint32_t **, uint32_t *);
00349 int LIBMTP_Set_Object_References(LIBMTP_mtpdevice_t *, const uint32_t, uint32_t const * const, const uint32_t);
00350 LIBMTP_object_t *LIBMTP_Make_List(LIBMTP_mtpdevice_t *, uint32_t *, uint32_t, uint32_t *, uint32_t);
00351 LIBMTP_object_t *LIBMTP_Find_Object(LIBMTP_object_t *, const uint32_t);
00352 void LIBMTP_Dump_List(LIBMTP_object_t *);
00353 LIBMTP_object_t *LIBMTP_new_object_t(void);
00354 void LIBMTP_destroy_object_t(LIBMTP_object_t *, uint32_t);
00355 int LIBMTP_Delete_Object(LIBMTP_mtpdevice_t *, uint32_t);
00363 int LIBMTP_Register_Filetype(char const * const, LIBMTP_filetype_t const,
00364 uint16_t const, void const * const,
00365 void const * const, void const * const);
00366 int LIBMTP_Set_Filetype_Description(LIBMTP_filetype_t, char const * const);
00367 int LIBMTP_Set_Constructor(LIBMTP_filetype_t, void const * const);
00368 int LIBMTP_Set_Destructor(LIBMTP_filetype_t, void const * const);
00369 int LIBMTP_Set_Datafunc(LIBMTP_filetype_t, void const * const);
00373
00374 #ifdef __cplusplus
00375 }
00376 #endif
00377
00378 #endif
00379