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

# libmtp.h

Go to the documentation of this file.

    00001
    00029 #ifndef LIBMTP_H_INCLUSION_GUARD
    00030 #define LIBMTP_H_INCLUSION_GUARD
    00031
    00032 #define LIBMTP_VERSION 0.2.6.1
    00033 #define LIBMTP_VERSION_STRING "0.2.6.1"
    00034
    00035 /* This handles MSVC pecularities */
    00036 #ifdef _MSC_VER
    00037 #include <windows.h>
    00038 #define __WIN32__
    00039 #define snprintf _snprintf
    00040 #define ssize_t SSIZE_T
    00041 #endif
    00042
    00043 #include <stdio.h>
    00044 #include <usb.h>
    00045 #include <stdint.h>
    00046
    00047 #ifdef __WIN32__
    00048 /*
    00049  * Windows specific code, types that do not exist in Windows
    00050  * sys/types.h
    00051  */
    00052 typedef char int8_t;
    00053 typedef unsigned char uint8_t;
    00054 typedef __int16 int16_t;
    00055 typedef unsigned __int16 uint16_t;
    00056 typedef __int32 int32_t;
    00057 typedef unsigned __int32 uint32_t;
    00058 typedef unsigned __int64 uint64_t;
    00059 #endif
    00060
    00068 typedef enum {
    00069   LIBMTP_FILETYPE_WAV,
    00070   LIBMTP_FILETYPE_MP3,
    00071   LIBMTP_FILETYPE_WMA,
    00072   LIBMTP_FILETYPE_OGG,
    00073   LIBMTP_FILETYPE_AUDIBLE,
    00074   LIBMTP_FILETYPE_MP4,
    00075   LIBMTP_FILETYPE_UNDEF_AUDIO,
    00076   LIBMTP_FILETYPE_WMV,
    00077   LIBMTP_FILETYPE_AVI,
    00078   LIBMTP_FILETYPE_MPEG,
    00079   LIBMTP_FILETYPE_ASF,
    00080   LIBMTP_FILETYPE_QT,
    00081   LIBMTP_FILETYPE_UNDEF_VIDEO,
    00082   LIBMTP_FILETYPE_JPEG,
    00083   LIBMTP_FILETYPE_JFIF,
    00084   LIBMTP_FILETYPE_TIFF,
    00085   LIBMTP_FILETYPE_BMP,
    00086   LIBMTP_FILETYPE_GIF,
    00087   LIBMTP_FILETYPE_PICT,
    00088   LIBMTP_FILETYPE_PNG,
    00089   LIBMTP_FILETYPE_VCALENDAR1,
    00090   LIBMTP_FILETYPE_VCALENDAR2,
    00091   LIBMTP_FILETYPE_VCARD2,
    00092   LIBMTP_FILETYPE_VCARD3,
    00093   LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT,
    00094   LIBMTP_FILETYPE_WINEXEC,
    00095   LIBMTP_FILETYPE_TEXT,
    00096   LIBMTP_FILETYPE_HTML,
    00097   LIBMTP_FILETYPE_FIRMWARE,
    00098   LIBMTP_FILETYPE_AAC,
    00099   LIBMTP_FILETYPE_MEDIACARD,
    00100   LIBMTP_FILETYPE_FLAC,
    00101   LIBMTP_FILETYPE_MP2,
    00102   LIBMTP_FILETYPE_M4A,
    00103   LIBMTP_FILETYPE_DOC,
    00104   LIBMTP_FILETYPE_XML,
    00105   LIBMTP_FILETYPE_XLS,
    00106   LIBMTP_FILETYPE_PPT,
    00107   LIBMTP_FILETYPE_MHT,
    00108   LIBMTP_FILETYPE_JP2,
    00109   LIBMTP_FILETYPE_JPX,
    00110   LIBMTP_FILETYPE_UNKNOWN
    00111 } LIBMTP_filetype_t;
    00116 typedef enum {
    00117   LIBMTP_ERROR_NONE,
    00118   LIBMTP_ERROR_GENERAL,
    00119   LIBMTP_ERROR_PTP_LAYER,
    00120   LIBMTP_ERROR_USB_LAYER,
    00121   LIBMTP_ERROR_MEMORY_ALLOCATION,
    00122   LIBMTP_ERROR_NO_DEVICE_ATTACHED,
    00123   LIBMTP_ERROR_STORAGE_FULL,
    00124   LIBMTP_ERROR_CONNECTING,
    00125   LIBMTP_ERROR_CANCELLED
    00126 } LIBMTP_error_number_t;
    00127 typedef struct LIBMTP_device_entry_struct LIBMTP_device_entry_t;
    00128 typedef struct LIBMTP_error_struct LIBMTP_error_t;
    00129 typedef struct LIBMTP_mtpdevice_struct LIBMTP_mtpdevice_t;
    00130 typedef struct LIBMTP_file_struct LIBMTP_file_t;
    00131 typedef struct LIBMTP_track_struct LIBMTP_track_t;
    00132 typedef struct LIBMTP_playlist_struct LIBMTP_playlist_t;
    00133 typedef struct LIBMTP_album_struct LIBMTP_album_t;
    00134 typedef struct LIBMTP_folder_struct LIBMTP_folder_t;
    00135 typedef struct LIBMTP_object_struct LIBMTP_object_t;
    00136 typedef struct LIBMTP_filesampledata_struct LIBMTP_filesampledata_t;
    00137 typedef struct LIBMTP_devicestorage_struct LIBMTP_devicestorage_t;
    00149 typedef int (* LIBMTP_progressfunc_t) (uint64_t const sent, uint64_t const total,
    00150                                 void const * const data);
    00151
    00161 struct LIBMTP_device_entry_struct {
    00162   char *vendor;
    00163   uint16_t vendor_id;
    00164   char *product;
    00165   uint16_t product_id;
    00166   uint32_t device_flags;
    00167 };
    00168
    00172 struct LIBMTP_error_struct {
    00173   LIBMTP_error_number_t errornumber;
    00174   char *error_text;
    00175   LIBMTP_error_t *next;
    00176 };
    00177
    00181 struct LIBMTP_mtpdevice_struct {
    00185   uint8_t object_bitsize;
    00190   void *params;
    00195   void *usbinfo;
    00201   LIBMTP_devicestorage_t *storage;
    00206   LIBMTP_error_t *errorstack;
    00208   uint8_t maximum_battery_level;
    00210   uint32_t default_music_folder;
    00212   uint32_t default_playlist_folder;
    00214   uint32_t default_picture_folder;
    00216   uint32_t default_video_folder;
    00218   uint32_t default_organizer_folder;
    00220   uint32_t default_zencast_folder;
    00222   uint32_t default_album_folder;
    00224   uint32_t default_text_folder;
    00226   void *cd;
    00227
    00229   LIBMTP_mtpdevice_t *next;
    00230 };
    00231
    00235 struct LIBMTP_file_struct {
    00236   uint32_t item_id;
    00237   uint32_t parent_id;
    00238   char *filename;
    00239   uint64_t filesize;
    00240   LIBMTP_filetype_t filetype;
    00241   LIBMTP_file_t *next;
    00242 };
    00243
    00247 struct LIBMTP_track_struct {
    00248   uint32_t item_id;
    00249   uint32_t parent_id;
    00250   char *title;
    00251   char *artist;
    00252   char *genre;
    00253   char *album;
    00254   char *date;
    00255   char *filename;
    00256   uint16_t tracknumber;
    00257   uint32_t duration;
    00258   uint32_t samplerate;
    00259   uint16_t nochannels;
    00260   uint32_t wavecodec;
    00261   uint32_t bitrate;
    00262   uint16_t bitratetype;
    00263   uint16_t rating;
    00264   uint32_t usecount;
    00265   uint64_t filesize;
    00266   LIBMTP_filetype_t filetype;
    00267   LIBMTP_track_t *next;
    00268 };
    00269
    00273 struct LIBMTP_playlist_struct {
    00274   uint32_t playlist_id;
    00275   char *name;
    00276   uint32_t *tracks;
    00277   uint32_t no_tracks;
    00278   LIBMTP_playlist_t *next;
    00279 };
    00280
    00284 struct LIBMTP_album_struct {
    00285   uint32_t album_id;
    00286   char *name;
    00287   char *artist;
    00288   char *genre;
    00289   uint32_t *tracks;
    00290   uint32_t no_tracks;
    00291   LIBMTP_album_t *next;
    00292 };
    00293
    00297 struct LIBMTP_folder_struct {
    00298   uint32_t folder_id;
    00299   uint32_t parent_id;
    00300   char *name;
    00301   LIBMTP_folder_t *sibling;
    00302   LIBMTP_folder_t *child;
    00303 };
    00304
    00308 struct LIBMTP_filesampledata_struct {
    00309   uint32_t width;
    00310   uint32_t height;
    00311   uint32_t duration;
    00312   LIBMTP_filetype_t filetype;
    00313   uint64_t size;
    00314   char *data;
    00315 };
    00316
    00320 struct LIBMTP_devicestorage_struct {
    00321   uint32_t id;
    00322   uint16_t StorageType;
    00323   uint16_t FilesystemType;
    00324   uint16_t AccessCapability;
    00325   uint64_t MaxCapacity;
    00326   uint64_t FreeSpaceInBytes;
    00327   uint64_t FreeSpaceInObjects;
    00328   char *StorageDescription;
    00329   char *VolumeIdentifier;
    00330   LIBMTP_devicestorage_t *next;
    00331   LIBMTP_devicestorage_t *prev;
    00332 };
    00333
    00334
    00337 /* Make functions available for C++ */
    00338 #ifdef __cplusplus
    00339 extern "C" {
    00340 #endif
    00341
    00346 void LIBMTP_Init(void);
    00347 int LIBMTP_Get_Supported_Devices_List(LIBMTP_device_entry_t ** const, int * const);
    00353 int LIBMTP_Detect_Descriptor(uint16_t*,uint16_t*);
    00354 LIBMTP_mtpdevice_t *LIBMTP_Get_First_Device(void);
    00355 LIBMTP_error_number_t LIBMTP_Get_Connected_Devices(LIBMTP_mtpdevice_t **);
    00356 uint32_t LIBMTP_Number_Devices_In_List(LIBMTP_mtpdevice_t *);
    00357 void LIBMTP_Release_Device_List(LIBMTP_mtpdevice_t*);
    00358 void LIBMTP_Release_Device(LIBMTP_mtpdevice_t*);
    00359 void LIBMTP_Dump_Device_Info(LIBMTP_mtpdevice_t*);
    00360 int LIBMTP_Reset_Device(LIBMTP_mtpdevice_t*);
    00361 char *LIBMTP_Get_Manufacturername(LIBMTP_mtpdevice_t*);
    00362 char *LIBMTP_Get_Modelname(LIBMTP_mtpdevice_t*);
    00363 char *LIBMTP_Get_Serialnumber(LIBMTP_mtpdevice_t*);
    00364 char *LIBMTP_Get_Deviceversion(LIBMTP_mtpdevice_t*);
    00365 char *LIBMTP_Get_Friendlyname(LIBMTP_mtpdevice_t*);
    00366 int LIBMTP_Set_Friendlyname(LIBMTP_mtpdevice_t*, char const * const);
    00367 char *LIBMTP_Get_Syncpartner(LIBMTP_mtpdevice_t*);
    00368 int LIBMTP_Set_Syncpartner(LIBMTP_mtpdevice_t*, char const * const);
    00369 int LIBMTP_Get_Batterylevel(LIBMTP_mtpdevice_t *,
    00370                             uint8_t * const,
    00371                             uint8_t * const);
    00372 int LIBMTP_Get_Secure_Time(LIBMTP_mtpdevice_t *, char ** const);
    00373 int LIBMTP_Get_Device_Certificate(LIBMTP_mtpdevice_t *, char ** const);
    00374 int LIBMTP_Get_Supported_Filetypes(LIBMTP_mtpdevice_t *, uint16_t ** const, uint16_t * const);
    00375 LIBMTP_error_t *LIBMTP_Get_Errorstack(LIBMTP_mtpdevice_t*);
    00376 void LIBMTP_Clear_Errorstack(LIBMTP_mtpdevice_t*);
    00377 void LIBMTP_Dump_Errorstack(LIBMTP_mtpdevice_t*);
    00378
    00379 #define LIBMTP_STORAGE_SORTBY_NOTSORTED 0
    00380 #define LIBMTP_STORAGE_SORTBY_FREESPACE 1
    00381 #define LIBMTP_STORAGE_SORTBY_MAXSPACE  2
    00382
    00383 int LIBMTP_Get_Storage(LIBMTP_mtpdevice_t *, int const);
    00384 int LIBMTP_Format_Storage(LIBMTP_mtpdevice_t *, LIBMTP_devicestorage_t *);
    00385
    00386
    00392 LIBMTP_file_t *LIBMTP_new_file_t(void);
    00393 void LIBMTP_destroy_file_t(LIBMTP_file_t*);
    00394 char const * LIBMTP_Get_Filetype_Description(LIBMTP_filetype_t);
    00395 LIBMTP_file_t *LIBMTP_Get_Filelisting(LIBMTP_mtpdevice_t *);
    00396 LIBMTP_file_t *LIBMTP_Get_Filelisting_With_Callback(LIBMTP_mtpdevice_t *,
    00397       LIBMTP_progressfunc_t const, void const * const);
    00398 LIBMTP_file_t *LIBMTP_Get_Filemetadata(LIBMTP_mtpdevice_t *, uint32_t const);
    00399 int LIBMTP_Get_File_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
    00400                         LIBMTP_progressfunc_t const, void const * const);
    00401 int LIBMTP_Get_File_To_File_Descriptor(LIBMTP_mtpdevice_t*, uint32_t const, int const,
    00402                         LIBMTP_progressfunc_t const, void const * const);
    00403 int LIBMTP_Send_File_From_File(LIBMTP_mtpdevice_t *, char const * const,
    00404                          LIBMTP_file_t * const, LIBMTP_progressfunc_t const,
    00405                          void const * const, uint32_t const);
    00406 int LIBMTP_Send_File_From_File_Descriptor(LIBMTP_mtpdevice_t *, int const,
    00407                         LIBMTP_file_t * const, LIBMTP_progressfunc_t const,
    00408                         void const * const, uint32_t const);
    00409 LIBMTP_filesampledata_t *LIBMTP_new_filesampledata_t(void);
    00410 void LIBMTP_destroy_filesampledata_t(LIBMTP_filesampledata_t *);
    00411 int LIBMTP_Get_Representative_Sample_Format(LIBMTP_mtpdevice_t *,
    00412                         LIBMTP_filetype_t const,
    00413                         LIBMTP_filesampledata_t **);
    00414 int LIBMTP_Send_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
    00415                           LIBMTP_filesampledata_t *);
    00416 int LIBMTP_Get_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
    00417                           LIBMTP_filesampledata_t *);
    00418
    00424 LIBMTP_track_t *LIBMTP_new_track_t(void);
    00425 void LIBMTP_destroy_track_t(LIBMTP_track_t*);
    00426 LIBMTP_track_t *LIBMTP_Get_Tracklisting(LIBMTP_mtpdevice_t*);
    00427 LIBMTP_track_t *LIBMTP_Get_Tracklisting_With_Callback(LIBMTP_mtpdevice_t*,
    00428       LIBMTP_progressfunc_t const, void const * const);
    00429 LIBMTP_track_t *LIBMTP_Get_Trackmetadata(LIBMTP_mtpdevice_t*, uint32_t const);
    00430 int LIBMTP_Get_Track_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
    00431                         LIBMTP_progressfunc_t const, void const * const);
    00432 int LIBMTP_Get_Track_To_File_Descriptor(LIBMTP_mtpdevice_t*, uint32_t const, int const,
    00433                         LIBMTP_progressfunc_t const, void const * const);
    00434 int LIBMTP_Send_Track_From_File(LIBMTP_mtpdevice_t *,
    00435                          char const * const, LIBMTP_track_t * const,
    00436                          LIBMTP_progressfunc_t const,
    00437                          void const * const, uint32_t const);
    00438 int LIBMTP_Send_Track_From_File_Descriptor(LIBMTP_mtpdevice_t *,
    00439                          int const, LIBMTP_track_t * const,
    00440                          LIBMTP_progressfunc_t const,
    00441                          void const * const, uint32_t const);
    00442 int LIBMTP_Update_Track_Metadata(LIBMTP_mtpdevice_t *,
    00443                         LIBMTP_track_t const * const);
    00444 int LIBMTP_Track_Exists(LIBMTP_mtpdevice_t *, uint32_t);
    00452 LIBMTP_folder_t *LIBMTP_new_folder_t(void);
    00453 void LIBMTP_destroy_folder_t(LIBMTP_folder_t*);
    00454 LIBMTP_folder_t *LIBMTP_Get_Folder_List(LIBMTP_mtpdevice_t*);
    00455 LIBMTP_folder_t *LIBMTP_Find_Folder(LIBMTP_folder_t*, uint32_t const);
    00456 uint32_t LIBMTP_Create_Folder(LIBMTP_mtpdevice_t*, char *, uint32_t);
    00465 LIBMTP_playlist_t *LIBMTP_new_playlist_t(void);
    00466 void LIBMTP_destroy_playlist_t(LIBMTP_playlist_t *);
    00467 LIBMTP_playlist_t *LIBMTP_Get_Playlist_List(LIBMTP_mtpdevice_t *);
    00468 LIBMTP_playlist_t *LIBMTP_Get_Playlist(LIBMTP_mtpdevice_t *, uint32_t const);
    00469 int LIBMTP_Create_New_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const, uint32_t const);
    00470 int LIBMTP_Update_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t const * const);
    00471
    00477 LIBMTP_album_t *LIBMTP_new_album_t(void);
    00478 void LIBMTP_destroy_album_t(LIBMTP_album_t *);
    00479 LIBMTP_album_t *LIBMTP_Get_Album_List(LIBMTP_mtpdevice_t *);
    00480 LIBMTP_album_t *LIBMTP_Get_Album(LIBMTP_mtpdevice_t *, uint32_t const);
    00481 int LIBMTP_Create_New_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t * const, uint32_t const);
    00482 int LIBMTP_Update_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t const * const);
    00483
    00489 int LIBMTP_Delete_Object(LIBMTP_mtpdevice_t *, uint32_t);
    00490 int LIBMTP_Set_Object_Filename(LIBMTP_mtpdevice_t *, uint32_t , char *);
    00491
    00494 /* End of C++ exports */
    00495 #ifdef __cplusplus
    00496 }
    00497 #endif
    00498
    00499 #endif /* LIBMTP_H_INCLUSION_GUARD */
    00500