libmtp: /tmp/libmtp-0.1.5/src/libmtp.h Source File

- Main Page
- Modules
- Data Structures
- Files
- Directories
- Examples

- File List
- Globals

# libmtp.h

Go to the documentation of this file.

    00001
    00028 #ifndef LIBMTP_H_INCLUSION_GUARD
    00029 #define LIBMTP_H_INCLUSION_GUARD
    00030
    00031 #define LIBMTP_VERSION 0.1.5
    00032
    00033 /* This handles MSVC pecularities */
    00034 #ifdef _MSC_VER
    00035 #include <windows.h>
    00036 #define __WIN32__
    00037 #define snprintf _snprintf
    00038 #define ssize_t SSIZE_T
    00039 #endif
    00040
    00041 #include <stdio.h>
    00042 #include <usb.h>
    00043 #include <stdint.h>
    00044
    00045 #ifdef __WIN32__
    00046 /*
    00047  * Windows specific code, types that do not exist in Windows
    00048  * sys/types.h
    00049  */
    00050 typedef char int8_t;
    00051 typedef unsigned char uint8_t;
    00052 typedef __int16 int16_t;
    00053 typedef unsigned __int16 uint16_t;
    00054 typedef __int32 int32_t;
    00055 typedef unsigned __int32 uint32_t;
    00056 typedef unsigned __int64 uint64_t;
    00057 #endif
    00058
    00066 typedef enum {
    00067   LIBMTP_FILETYPE_WAV,
    00068   LIBMTP_FILETYPE_MP3,
    00069   LIBMTP_FILETYPE_WMA,
    00070   LIBMTP_FILETYPE_OGG,
    00071   LIBMTP_FILETYPE_AUDIBLE,
    00072   LIBMTP_FILETYPE_MP4,
    00073   LIBMTP_FILETYPE_UNDEF_AUDIO,
    00074   LIBMTP_FILETYPE_WMV,
    00075   LIBMTP_FILETYPE_AVI,
    00076   LIBMTP_FILETYPE_MPEG,
    00077   LIBMTP_FILETYPE_ASF,
    00078   LIBMTP_FILETYPE_QT,
    00079   LIBMTP_FILETYPE_UNDEF_VIDEO,
    00080   LIBMTP_FILETYPE_JPEG,
    00081   LIBMTP_FILETYPE_JFIF,
    00082   LIBMTP_FILETYPE_TIFF,
    00083   LIBMTP_FILETYPE_BMP,
    00084   LIBMTP_FILETYPE_GIF,
    00085   LIBMTP_FILETYPE_PICT,
    00086   LIBMTP_FILETYPE_PNG,
    00087   LIBMTP_FILETYPE_VCALENDAR1,
    00088   LIBMTP_FILETYPE_VCALENDAR2,
    00089   LIBMTP_FILETYPE_VCARD2,
    00090   LIBMTP_FILETYPE_VCARD3,
    00091   LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT,
    00092   LIBMTP_FILETYPE_WINEXEC,
    00093   LIBMTP_FILETYPE_TEXT,
    00094   LIBMTP_FILETYPE_HTML,
    00095   LIBMTP_FILETYPE_FIRMWARE,
    00096   LIBMTP_FILETYPE_AAC,
    00097   LIBMTP_FILETYPE_MEDIACARD,
    00098   LIBMTP_FILETYPE_FLAC,
    00099   LIBMTP_FILETYPE_MP2,
    00100   LIBMTP_FILETYPE_M4A,
    00101   LIBMTP_FILETYPE_DOC,
    00102   LIBMTP_FILETYPE_XML,
    00103   LIBMTP_FILETYPE_XLS,
    00104   LIBMTP_FILETYPE_PPT,
    00105   LIBMTP_FILETYPE_MHT,
    00106   LIBMTP_FILETYPE_JP2,
    00107   LIBMTP_FILETYPE_JPX,
    00108   LIBMTP_FILETYPE_UNKNOWN
    00109 } LIBMTP_filetype_t;
    00114 typedef enum {
    00115   LIBMTP_ERROR_NONE,
    00116   LIBMTP_ERROR_GENERAL,
    00117   LIBMTP_ERROR_PTP_LAYER,
    00118   LIBMTP_ERROR_USB_LAYER,
    00119   LIBMTP_ERROR_MEMORY_ALLOCATION,
    00120   LIBMTP_ERROR_NO_DEVICE_ATTACHED,
    00121   LIBMTP_ERROR_STORAGE_FULL,
    00122   LIBMTP_ERROR_CONNECTING
    00123 } LIBMTP_error_number_t;
    00124 typedef struct LIBMTP_device_entry_struct LIBMTP_device_entry_t;
    00125 typedef struct LIBMTP_error_struct LIBMTP_error_t;
    00126 typedef struct LIBMTP_mtpdevice_struct LIBMTP_mtpdevice_t;
    00127 typedef struct LIBMTP_file_struct LIBMTP_file_t;
    00128 typedef struct LIBMTP_track_struct LIBMTP_track_t;
    00129 typedef struct LIBMTP_playlist_struct LIBMTP_playlist_t;
    00130 typedef struct LIBMTP_album_struct LIBMTP_album_t;
    00131 typedef struct LIBMTP_folder_struct LIBMTP_folder_t;
    00132 typedef struct LIBMTP_object_struct LIBMTP_object_t;
    00133 typedef struct LIBMTP_filesampledata_struct LIBMTP_filesampledata_t;
    00134 typedef struct LIBMTP_devicestorage_struct LIBMTP_devicestorage_t;
    00146 typedef int (* LIBMTP_progressfunc_t) (uint64_t const sent, uint64_t const total,
    00147                                 void const * const data);
    00148
    00158 struct LIBMTP_device_entry_struct {
    00159   char *name;
    00160   uint16_t vendor_id;
    00161   uint16_t product_id;
    00162   uint32_t device_flags;
    00163 };
    00164
    00168 struct LIBMTP_error_struct {
    00169   LIBMTP_error_number_t errornumber;
    00170   char *error_text;
    00171   LIBMTP_error_t *next;
    00172 };
    00173
    00177 struct LIBMTP_mtpdevice_struct {
    00179   uint8_t interface_number;
    00184   void *params;
    00189   void *usbinfo;
    00195   LIBMTP_devicestorage_t *storage;
    00200   LIBMTP_error_t *errorstack;
    00202   uint8_t maximum_battery_level;
    00204   uint32_t default_music_folder;
    00206   uint32_t default_playlist_folder;
    00208   uint32_t default_picture_folder;
    00210   uint32_t default_video_folder;
    00212   uint32_t default_organizer_folder;
    00214   uint32_t default_zencast_folder;
    00216   uint32_t default_album_folder;
    00218   uint32_t default_text_folder;
    00220   void *cd;
    00221
    00223   LIBMTP_mtpdevice_t *next;
    00224 };
    00225
    00229 struct LIBMTP_file_struct {
    00230   uint32_t item_id;
    00231   uint32_t parent_id;
    00232   char *filename;
    00233   uint64_t filesize;
    00234   LIBMTP_filetype_t filetype;
    00235   LIBMTP_file_t *next;
    00236 };
    00237
    00241 struct LIBMTP_track_struct {
    00242   uint32_t item_id;
    00243   uint32_t parent_id;
    00244   char *title;
    00245   char *artist;
    00246   char *genre;
    00247   char *album;
    00248   char *date;
    00249   char *filename;
    00250   uint16_t tracknumber;
    00251   uint32_t duration;
    00252   uint32_t samplerate;
    00253   uint16_t nochannels;
    00254   uint32_t wavecodec;
    00255   uint32_t bitrate;
    00256   uint16_t bitratetype;
    00257   uint16_t rating;
    00258   uint32_t usecount;
    00259   uint64_t filesize;
    00260   LIBMTP_filetype_t filetype;
    00261   LIBMTP_track_t *next;
    00262 };
    00263
    00267 struct LIBMTP_playlist_struct {
    00268   uint32_t playlist_id;
    00269   char *name;
    00270   uint32_t *tracks;
    00271   uint32_t no_tracks;
    00272   LIBMTP_playlist_t *next;
    00273 };
    00274
    00278 struct LIBMTP_album_struct {
    00279   uint32_t album_id;
    00280   char *name;
    00281   uint32_t *tracks;
    00282   uint32_t no_tracks;
    00283   LIBMTP_album_t *next;
    00284 };
    00285
    00289 struct LIBMTP_folder_struct {
    00290   uint32_t folder_id;
    00291   uint32_t parent_id;
    00292   char *name;
    00293   LIBMTP_folder_t *sibling;
    00294   LIBMTP_folder_t *child;
    00295 };
    00296
    00300 struct LIBMTP_filesampledata_struct {
    00301   uint32_t width;
    00302   uint32_t height;
    00303   uint32_t duration;
    00304   LIBMTP_filetype_t filetype;
    00305   uint64_t size;
    00306   char *data;
    00307 };
    00308
    00312 struct LIBMTP_devicestorage_struct {
    00313   uint32_t id;
    00314   uint16_t StorageType;
    00315   uint16_t FilesystemType;
    00316   uint16_t AccessCapability;
    00317   uint64_t MaxCapacity;
    00318   uint64_t FreeSpaceInBytes;
    00319   uint64_t FreeSpaceInObjects;
    00320   char *StorageDescription;
    00321   char *VolumeIdentifier;
    00322   LIBMTP_devicestorage_t *next;
    00323   LIBMTP_devicestorage_t *prev;
    00324 };
    00325
    00326
    00329 /* Make functions available for C++ */
    00330 #ifdef __cplusplus
    00331 extern "C" {
    00332 #endif
    00333
    00338 void LIBMTP_Init(void);
    00339 int LIBMTP_Get_Supported_Devices_List(LIBMTP_device_entry_t ** const, int * const);
    00345 int LIBMTP_Detect_Descriptor(uint16_t*,uint16_t*);
    00346 LIBMTP_mtpdevice_t *LIBMTP_Get_First_Device(void);
    00347 LIBMTP_error_number_t LIBMTP_Get_Connected_Devices(LIBMTP_mtpdevice_t **);
    00348 uint32_t LIBMTP_Number_Devices_In_List(LIBMTP_mtpdevice_t *);
    00349 void LIBMTP_Release_Device_List(LIBMTP_mtpdevice_t*);
    00350 void LIBMTP_Release_Device(LIBMTP_mtpdevice_t*);
    00351 void LIBMTP_Dump_Device_Info(LIBMTP_mtpdevice_t*);
    00352 char *LIBMTP_Get_Modelname(LIBMTP_mtpdevice_t*);
    00353 char *LIBMTP_Get_Serialnumber(LIBMTP_mtpdevice_t*);
    00354 char *LIBMTP_Get_Deviceversion(LIBMTP_mtpdevice_t*);
    00355 char *LIBMTP_Get_Friendlyname(LIBMTP_mtpdevice_t*);
    00356 int LIBMTP_Set_Friendlyname(LIBMTP_mtpdevice_t*, char const * const);
    00357 char *LIBMTP_Get_Syncpartner(LIBMTP_mtpdevice_t*);
    00358 int LIBMTP_Set_Syncpartner(LIBMTP_mtpdevice_t*, char const * const);
    00359 int LIBMTP_Get_Batterylevel(LIBMTP_mtpdevice_t *,
    00360                             uint8_t * const,
    00361                             uint8_t * const);
    00362 int LIBMTP_Get_Secure_Time(LIBMTP_mtpdevice_t *, char ** const);
    00363 int LIBMTP_Get_Device_Certificate(LIBMTP_mtpdevice_t *, char ** const);
    00364 int LIBMTP_Get_Supported_Filetypes(LIBMTP_mtpdevice_t *, uint16_t ** const, uint16_t * const);
    00365 LIBMTP_error_t *LIBMTP_Get_Errorstack(LIBMTP_mtpdevice_t*);
    00366 void LIBMTP_Clear_Errorstack(LIBMTP_mtpdevice_t*);
    00367 void LIBMTP_Dump_Errorstack(LIBMTP_mtpdevice_t*);
    00368
    00369 #define LIBMTP_STORAGE_SORTBY_NOTSORTED 0
    00370 #define LIBMTP_STORAGE_SORTBY_FREESPACE 1
    00371 #define LIBMTP_STORAGE_SORTBY_MAXSPACE  2
    00372
    00373 int LIBMTP_Get_Storage(LIBMTP_mtpdevice_t *, int const);
    00374 int LIBMTP_Format_Storage(LIBMTP_mtpdevice_t *, LIBMTP_devicestorage_t *);
    00375
    00376
    00382 LIBMTP_file_t *LIBMTP_new_file_t(void);
    00383 void LIBMTP_destroy_file_t(LIBMTP_file_t*);
    00384 char const * LIBMTP_Get_Filetype_Description(LIBMTP_filetype_t);
    00385 LIBMTP_file_t *LIBMTP_Get_Filelisting(LIBMTP_mtpdevice_t *);
    00386 LIBMTP_file_t *LIBMTP_Get_Filelisting_With_Callback(LIBMTP_mtpdevice_t *,
    00387       LIBMTP_progressfunc_t const, void const * const);
    00388 LIBMTP_file_t *LIBMTP_Get_Filemetadata(LIBMTP_mtpdevice_t *, uint32_t const);
    00389 int LIBMTP_Get_File_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
    00390                         LIBMTP_progressfunc_t const, void const * const);
    00391 int LIBMTP_Get_File_To_File_Descriptor(LIBMTP_mtpdevice_t*, uint32_t const, int const,
    00392                         LIBMTP_progressfunc_t const, void const * const);
    00393 int LIBMTP_Send_File_From_File(LIBMTP_mtpdevice_t *, char const * const,
    00394                          LIBMTP_file_t * const, LIBMTP_progressfunc_t const,
    00395                          void const * const, uint32_t const);
    00396 int LIBMTP_Send_File_From_File_Descriptor(LIBMTP_mtpdevice_t *, int const,
    00397                         LIBMTP_file_t * const, LIBMTP_progressfunc_t const,
    00398                         void const * const, uint32_t const);
    00399 LIBMTP_filesampledata_t *LIBMTP_new_filesampledata_t(void);
    00400 void LIBMTP_destroy_filesampledata_t(LIBMTP_filesampledata_t *);
    00401 int LIBMTP_Get_Representative_Sample_Format(LIBMTP_mtpdevice_t *,
    00402                         LIBMTP_filetype_t const,
    00403                         LIBMTP_filesampledata_t **);
    00404 int LIBMTP_Send_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
    00405                           LIBMTP_filesampledata_t *);
    00406
    00412 LIBMTP_track_t *LIBMTP_new_track_t(void);
    00413 void LIBMTP_destroy_track_t(LIBMTP_track_t*);
    00414 LIBMTP_track_t *LIBMTP_Get_Tracklisting(LIBMTP_mtpdevice_t*);
    00415 LIBMTP_track_t *LIBMTP_Get_Tracklisting_With_Callback(LIBMTP_mtpdevice_t*,
    00416       LIBMTP_progressfunc_t const, void const * const);
    00417 LIBMTP_track_t *LIBMTP_Get_Trackmetadata(LIBMTP_mtpdevice_t*, uint32_t const);
    00418 int LIBMTP_Get_Track_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
    00419                         LIBMTP_progressfunc_t const, void const * const);
    00420 int LIBMTP_Get_Track_To_File_Descriptor(LIBMTP_mtpdevice_t*, uint32_t const, int const,
    00421                         LIBMTP_progressfunc_t const, void const * const);
    00422 int LIBMTP_Send_Track_From_File(LIBMTP_mtpdevice_t *,
    00423                          char const * const, LIBMTP_track_t * const,
    00424                          LIBMTP_progressfunc_t const,
    00425                          void const * const, uint32_t const);
    00426 int LIBMTP_Send_Track_From_File_Descriptor(LIBMTP_mtpdevice_t *,
    00427                          int const, LIBMTP_track_t * const,
    00428                          LIBMTP_progressfunc_t const,
    00429                          void const * const, uint32_t const);
    00430 int LIBMTP_Update_Track_Metadata(LIBMTP_mtpdevice_t *,
    00431                         LIBMTP_track_t const * const);
    00432 int LIBMTP_Track_Exists(LIBMTP_mtpdevice_t *, uint32_t);
    00440 LIBMTP_folder_t *LIBMTP_new_folder_t(void);
    00441 void LIBMTP_destroy_folder_t(LIBMTP_folder_t*);
    00442 LIBMTP_folder_t *LIBMTP_Get_Folder_List(LIBMTP_mtpdevice_t*);
    00443 LIBMTP_folder_t *LIBMTP_Find_Folder(LIBMTP_folder_t*, uint32_t const);
    00444 uint32_t LIBMTP_Create_Folder(LIBMTP_mtpdevice_t*, char *, uint32_t);
    00453 LIBMTP_playlist_t *LIBMTP_new_playlist_t(void);
    00454 void LIBMTP_destroy_playlist_t(LIBMTP_playlist_t *);
    00455 LIBMTP_playlist_t *LIBMTP_Get_Playlist_List(LIBMTP_mtpdevice_t *);
    00456 LIBMTP_playlist_t *LIBMTP_Get_Playlist(LIBMTP_mtpdevice_t *, uint32_t const);
    00457 int LIBMTP_Create_New_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const, uint32_t const);
    00458 int LIBMTP_Update_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t const * const);
    00459
    00465 LIBMTP_album_t *LIBMTP_new_album_t(void);
    00466 void LIBMTP_destroy_album_t(LIBMTP_album_t *);
    00467 LIBMTP_album_t *LIBMTP_Get_Album_List(LIBMTP_mtpdevice_t *);
    00468 LIBMTP_album_t *LIBMTP_Get_Album(LIBMTP_mtpdevice_t *, uint32_t const);
    00469 int LIBMTP_Create_New_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t * const, uint32_t const);
    00470 int LIBMTP_Update_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t const * const);
    00471
    00477 int LIBMTP_Delete_Object(LIBMTP_mtpdevice_t *, uint32_t);
    00478
    00481 /* End of C++ exports */
    00482 #ifdef __cplusplus
    00483 }
    00484 #endif
    00485
    00486 #endif /* LIBMTP_H_INCLUSION_GUARD */
    00487