libmtp: /tmp/libmtp-0.1.3/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
    00010 #ifndef LIBMTP_H_INCLUSION_GUARD
    00011 #define LIBMTP_H_INCLUSION_GUARD
    00012
    00013 #define LIBMTP_VERSION 0.1.3
    00014
    00015 /* This handles MSVC pecularities */
    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  * Windows specific code, types that do not exist in Windows
    00030  * sys/types.h
    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_FIRMWARE,
    00078   LIBMTP_FILETYPE_AAC,
    00079   LIBMTP_FILETYPE_MEDIACARD,
    00080   LIBMTP_FILETYPE_FLAC,
    00081   LIBMTP_FILETYPE_MP2,
    00082   LIBMTP_FILETYPE_M4A,
    00083   LIBMTP_FILETYPE_DOC,
    00084   LIBMTP_FILETYPE_XML,
    00085   LIBMTP_FILETYPE_XLS,
    00086   LIBMTP_FILETYPE_PPT,
    00087   LIBMTP_FILETYPE_MHT,
    00088   LIBMTP_FILETYPE_JP2,
    00089   LIBMTP_FILETYPE_JPX,
    00090   LIBMTP_FILETYPE_UNKNOWN
    00091 } LIBMTP_filetype_t;
    00092 typedef struct LIBMTP_device_entry_struct LIBMTP_device_entry_t;
    00093 typedef struct LIBMTP_mtpdevice_struct LIBMTP_mtpdevice_t;
    00094 typedef struct LIBMTP_file_struct LIBMTP_file_t;
    00095 typedef struct LIBMTP_track_struct LIBMTP_track_t;
    00096 typedef struct LIBMTP_playlist_struct LIBMTP_playlist_t;
    00097 typedef struct LIBMTP_album_struct LIBMTP_album_t;
    00098 typedef struct LIBMTP_folder_struct LIBMTP_folder_t;
    00099 typedef struct LIBMTP_object_struct LIBMTP_object_t;
    00100 typedef struct LIBMTP_filesampledata_struct LIBMTP_filesampledata_t;
    00101 typedef struct LIBMTP_devicestorage_struct LIBMTP_devicestorage_t;
    00113 typedef int (* LIBMTP_progressfunc_t) (uint64_t const sent, uint64_t const total,
    00114                                 void const * const data);
    00115
    00125 struct LIBMTP_device_entry_struct {
    00126   char *name;
    00127   uint16_t vendor_id;
    00128   uint16_t product_id;
    00129   uint32_t device_flags;
    00130 };
    00131
    00135 struct LIBMTP_mtpdevice_struct {
    00137   uint8_t interface_number;
    00142   void *params;
    00147   void *usbinfo;
    00153   LIBMTP_devicestorage_t *storage;
    00155   uint8_t maximum_battery_level;
    00157   uint32_t default_music_folder;
    00159   uint32_t default_playlist_folder;
    00161   uint32_t default_picture_folder;
    00163   uint32_t default_video_folder;
    00165   uint32_t default_organizer_folder;
    00167   uint32_t default_zencast_folder;
    00169   uint32_t default_album_folder;
    00171   uint32_t default_text_folder;
    00173   void *cd;
    00174 };
    00175
    00179 struct LIBMTP_file_struct {
    00180   uint32_t item_id;
    00181   uint32_t parent_id;
    00182   char *filename;
    00183   uint64_t filesize;
    00184   LIBMTP_filetype_t filetype;
    00185   LIBMTP_file_t *next;
    00186 };
    00187
    00191 struct LIBMTP_track_struct {
    00192   uint32_t item_id;
    00193   uint32_t parent_id;
    00194   char *title;
    00195   char *artist;
    00196   char *genre;
    00197   char *album;
    00198   char *date;
    00199   char *filename;
    00200   uint16_t tracknumber;
    00201   uint32_t duration;
    00202   uint32_t samplerate;
    00203   uint16_t nochannels;
    00204   uint32_t wavecodec;
    00205   uint32_t bitrate;
    00206   uint16_t bitratetype;
    00207   uint16_t rating;
    00208   uint32_t usecount;
    00209   uint64_t filesize;
    00210   LIBMTP_filetype_t filetype;
    00211   LIBMTP_track_t *next;
    00212 };
    00213
    00217 struct LIBMTP_playlist_struct {
    00218   uint32_t playlist_id;
    00219   char *name;
    00220   uint32_t *tracks;
    00221   uint32_t no_tracks;
    00222   LIBMTP_playlist_t *next;
    00223 };
    00224
    00228 struct LIBMTP_album_struct {
    00229   uint32_t album_id;
    00230   char *name;
    00231   uint32_t *tracks;
    00232   uint32_t no_tracks;
    00233   LIBMTP_album_t *next;
    00234 };
    00235
    00239 struct LIBMTP_folder_struct {
    00240   uint32_t folder_id;
    00241   uint32_t parent_id;
    00242   char *name;
    00243   LIBMTP_folder_t *sibling;
    00244   LIBMTP_folder_t *child;
    00245 };
    00246
    00250 struct LIBMTP_filesampledata_struct {
    00251   uint32_t width;
    00252   uint32_t height;
    00253   uint32_t duration;
    00254   LIBMTP_filetype_t filetype;
    00255   uint64_t size;
    00256   char *data;
    00257 };
    00258
    00262 struct LIBMTP_devicestorage_struct {
    00263   uint32_t id;
    00264   uint16_t StorageType;
    00265   uint16_t FilesystemType;
    00266   uint16_t AccessCapability;
    00267   uint64_t MaxCapacity;
    00268   uint64_t FreeSpaceInBytes;
    00269   uint64_t FreeSpaceInObjects;
    00270   char *StorageDescription;
    00271   char *VolumeIdentifier;
    00272   LIBMTP_devicestorage_t *next;
    00273   LIBMTP_devicestorage_t *prev;
    00274 };
    00275
    00276
    00279 /* Make functions available for C++ */
    00280 #ifdef __cplusplus
    00281 extern "C" {
    00282 #endif
    00283
    00288 void LIBMTP_Init(void);
    00289 int LIBMTP_Get_Supported_Devices_List(LIBMTP_device_entry_t ** const, int * const);
    00295 int LIBMTP_Detect_Descriptor(uint16_t*,uint16_t*);
    00296 LIBMTP_mtpdevice_t *LIBMTP_Get_First_Device(void);
    00297 void LIBMTP_Release_Device(LIBMTP_mtpdevice_t*);
    00298 void LIBMTP_Dump_Device_Info(LIBMTP_mtpdevice_t*);
    00299 char *LIBMTP_Get_Modelname(LIBMTP_mtpdevice_t*);
    00300 char *LIBMTP_Get_Serialnumber(LIBMTP_mtpdevice_t*);
    00301 char *LIBMTP_Get_Deviceversion(LIBMTP_mtpdevice_t*);
    00302 char *LIBMTP_Get_Friendlyname(LIBMTP_mtpdevice_t*);
    00303 int LIBMTP_Set_Friendlyname(LIBMTP_mtpdevice_t*, char const * const);
    00304 char *LIBMTP_Get_Syncpartner(LIBMTP_mtpdevice_t*);
    00305 int LIBMTP_Set_Syncpartner(LIBMTP_mtpdevice_t*, char const * const);
    00306 int LIBMTP_Get_Batterylevel(LIBMTP_mtpdevice_t *,
    00307                             uint8_t * const,
    00308                             uint8_t * const);
    00309 int LIBMTP_Get_Secure_Time(LIBMTP_mtpdevice_t *, char ** const);
    00310 int LIBMTP_Get_Device_Certificate(LIBMTP_mtpdevice_t *, char ** const);
    00311 int LIBMTP_Get_Supported_Filetypes(LIBMTP_mtpdevice_t *, uint16_t ** const, uint16_t * const);
    00312
    00313 #define LIBMTP_STORAGE_SORTBY_NOTSORTED 0
    00314 #define LIBMTP_STORAGE_SORTBY_FREESPACE 1
    00315 #define LIBMTP_STORAGE_SORTBY_MAXSPACE  2
    00316
    00317 int LIBMTP_Get_Storage(LIBMTP_mtpdevice_t *, int const);
    00318 int LIBMTP_Format_Storage(LIBMTP_mtpdevice_t *, LIBMTP_devicestorage_t *);
    00319
    00320
    00326 LIBMTP_file_t *LIBMTP_new_file_t(void);
    00327 void LIBMTP_destroy_file_t(LIBMTP_file_t*);
    00328 char const * LIBMTP_Get_Filetype_Description(LIBMTP_filetype_t);
    00329 LIBMTP_file_t *LIBMTP_Get_Filelisting(LIBMTP_mtpdevice_t *);
    00330 LIBMTP_file_t *LIBMTP_Get_Filelisting_With_Callback(LIBMTP_mtpdevice_t *,
    00331       LIBMTP_progressfunc_t const, void const * const);
    00332 LIBMTP_file_t *LIBMTP_Get_Filemetadata(LIBMTP_mtpdevice_t *, uint32_t const);
    00333 int LIBMTP_Get_File_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
    00334                         LIBMTP_progressfunc_t const, void const * const);
    00335 int LIBMTP_Get_File_To_File_Descriptor(LIBMTP_mtpdevice_t*, uint32_t const, int const,
    00336                         LIBMTP_progressfunc_t const, void const * const);
    00337 int LIBMTP_Send_File_From_File(LIBMTP_mtpdevice_t *, char const * const,
    00338                          LIBMTP_file_t * const, LIBMTP_progressfunc_t const,
    00339                          void const * const, uint32_t const);
    00340 int LIBMTP_Send_File_From_File_Descriptor(LIBMTP_mtpdevice_t *, int const,
    00341                         LIBMTP_file_t * const, LIBMTP_progressfunc_t const,
    00342                         void const * const, uint32_t const);
    00343 LIBMTP_filesampledata_t *LIBMTP_new_filesampledata_t(void);
    00344 void LIBMTP_destroy_filesampledata_t(LIBMTP_filesampledata_t *);
    00345 int LIBMTP_Get_Representative_Sample_Format(LIBMTP_mtpdevice_t *,
    00346                         LIBMTP_filetype_t const,
    00347                         LIBMTP_filesampledata_t **);
    00348 int LIBMTP_Send_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
    00349                           LIBMTP_filesampledata_t *);
    00350
    00356 LIBMTP_track_t *LIBMTP_new_track_t(void);
    00357 void LIBMTP_destroy_track_t(LIBMTP_track_t*);
    00358 LIBMTP_track_t *LIBMTP_Get_Tracklisting(LIBMTP_mtpdevice_t*);
    00359 LIBMTP_track_t *LIBMTP_Get_Tracklisting_With_Callback(LIBMTP_mtpdevice_t*,
    00360       LIBMTP_progressfunc_t const, void const * const);
    00361 LIBMTP_track_t *LIBMTP_Get_Trackmetadata(LIBMTP_mtpdevice_t*, uint32_t const);
    00362 int LIBMTP_Get_Track_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
    00363                         LIBMTP_progressfunc_t const, void const * const);
    00364 int LIBMTP_Get_Track_To_File_Descriptor(LIBMTP_mtpdevice_t*, uint32_t const, int const,
    00365                         LIBMTP_progressfunc_t const, void const * const);
    00366 int LIBMTP_Send_Track_From_File(LIBMTP_mtpdevice_t *,
    00367                          char const * const, LIBMTP_track_t * const,
    00368                          LIBMTP_progressfunc_t const,
    00369                          void const * const, uint32_t const);
    00370 int LIBMTP_Send_Track_From_File_Descriptor(LIBMTP_mtpdevice_t *,
    00371                          int const, LIBMTP_track_t * const,
    00372                          LIBMTP_progressfunc_t const,
    00373                          void const * const, uint32_t const);
    00374 int LIBMTP_Update_Track_Metadata(LIBMTP_mtpdevice_t *,
    00375                         LIBMTP_track_t const * const);
    00376 int LIBMTP_Track_Exists(LIBMTP_mtpdevice_t *, uint32_t);
    00384 LIBMTP_folder_t *LIBMTP_new_folder_t(void);
    00385 void LIBMTP_destroy_folder_t(LIBMTP_folder_t*);
    00386 LIBMTP_folder_t *LIBMTP_Get_Folder_List(LIBMTP_mtpdevice_t*);
    00387 LIBMTP_folder_t *LIBMTP_Find_Folder(LIBMTP_folder_t*, uint32_t const);
    00388 uint32_t LIBMTP_Create_Folder(LIBMTP_mtpdevice_t*, char *, uint32_t);
    00397 LIBMTP_playlist_t *LIBMTP_new_playlist_t(void);
    00398 void LIBMTP_destroy_playlist_t(LIBMTP_playlist_t *);
    00399 LIBMTP_playlist_t *LIBMTP_Get_Playlist_List(LIBMTP_mtpdevice_t *);
    00400 LIBMTP_playlist_t *LIBMTP_Get_Playlist(LIBMTP_mtpdevice_t *, uint32_t const);
    00401 int LIBMTP_Create_New_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const, uint32_t const);
    00402 int LIBMTP_Update_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t const * const);
    00403
    00409 LIBMTP_album_t *LIBMTP_new_album_t(void);
    00410 void LIBMTP_destroy_album_t(LIBMTP_album_t *);
    00411 LIBMTP_album_t *LIBMTP_Get_Album_List(LIBMTP_mtpdevice_t *);
    00412 LIBMTP_album_t *LIBMTP_Get_Album(LIBMTP_mtpdevice_t *, uint32_t const);
    00413 int LIBMTP_Create_New_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t * const, uint32_t const);
    00414 int LIBMTP_Update_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t const * const);
    00415
    00421 int LIBMTP_Delete_Object(LIBMTP_mtpdevice_t *, uint32_t);
    00422
    00425 /* End of C++ exports */
    00426 #ifdef __cplusplus
    00427 }
    00428 #endif
    00429
    00430 #endif /* LIBMTP_H_INCLUSION_GUARD */
    00431