3 * Interface to the Media Transfer Protocol library.
5 * Copyright (C) 2005-2013 Linus Walleij <triad@df.lth.se>
6 * Copyright (C) 2005-2008 Richard A. Low <richard@wentnet.com>
7 * Copyright (C) 2007 Ted Bullock <tbullock@canada.com>
8 * Copyright (C) 2008 Florent Mertens <flomertens@gmail.com>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
29 #ifndef LIBMTP_H_INCLUSION_GUARD
30 #define LIBMTP_H_INCLUSION_GUARD
32 #define LIBMTP_VERSION @VERSION@
33 #define LIBMTP_VERSION_STRING "@VERSION@"
35 /* This handles MSVC pecularities */
39 #define snprintf _snprintf
40 #define ssize_t SSIZE_T
42 * Types that do not exist in Windows
43 * sys/types.h, but they exist in mingw32
47 typedef unsigned char uint8_t;
48 typedef __int16 int16_t;
49 typedef unsigned __int16 uint16_t;
50 typedef __int32 int32_t;
51 typedef unsigned __int32 uint32_t;
52 typedef unsigned __int64 uint64_t;
61 * @defgroup types libmtp global type definitions
66 * The debug flags defined here are the external flags used
67 * by the libmtp library interface.
69 * Please keep this list in sync with libmtp.c.
71 #define LIBMTP_DEBUG_NONE 0x00
72 #define LIBMTP_DEBUG_PTP 0x01
73 #define LIBMTP_DEBUG_PLST 0x02
74 #define LIBMTP_DEBUG_USB 0x04
75 #define LIBMTP_DEBUG_DATA 0x08
76 #define LIBMTP_DEBUG_ALL 0xFF
80 * The filetypes defined here are the external types used
81 * by the libmtp library interface. The types used internally
82 * as PTP-defined enumerator types is something different.
85 LIBMTP_FILETYPE_FOLDER,
90 LIBMTP_FILETYPE_AUDIBLE,
92 LIBMTP_FILETYPE_UNDEF_AUDIO,
98 LIBMTP_FILETYPE_UNDEF_VIDEO,
100 LIBMTP_FILETYPE_JFIF,
101 LIBMTP_FILETYPE_TIFF,
104 LIBMTP_FILETYPE_PICT,
106 LIBMTP_FILETYPE_VCALENDAR1,
107 LIBMTP_FILETYPE_VCALENDAR2,
108 LIBMTP_FILETYPE_VCARD2,
109 LIBMTP_FILETYPE_VCARD3,
110 LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT,
111 LIBMTP_FILETYPE_WINEXEC,
112 LIBMTP_FILETYPE_TEXT,
113 LIBMTP_FILETYPE_HTML,
114 LIBMTP_FILETYPE_FIRMWARE,
116 LIBMTP_FILETYPE_MEDIACARD,
117 LIBMTP_FILETYPE_FLAC,
127 LIBMTP_FILETYPE_ALBUM,
128 LIBMTP_FILETYPE_PLAYLIST,
129 LIBMTP_FILETYPE_UNKNOWN,
133 LIBMTP_FILETYPE_ALL_IMAGE,
134 LIBMTP_FILETYPE_HEIF,
135 #endif /* TIZEN_EXT */
139 * \def LIBMTP_FILETYPE_IS_AUDIO
140 * Audio filetype test.
142 * For filetypes that can be either audio
143 * or video, use LIBMTP_FILETYPE_IS_AUDIOVIDEO
145 #define LIBMTP_FILETYPE_IS_AUDIO(a)\
146 (a == LIBMTP_FILETYPE_WAV ||\
147 a == LIBMTP_FILETYPE_MP3 ||\
148 a == LIBMTP_FILETYPE_MP2 ||\
149 a == LIBMTP_FILETYPE_WMA ||\
150 a == LIBMTP_FILETYPE_OGG ||\
151 a == LIBMTP_FILETYPE_FLAC ||\
152 a == LIBMTP_FILETYPE_AAC ||\
153 a == LIBMTP_FILETYPE_M4A ||\
154 a == LIBMTP_FILETYPE_AUDIBLE ||\
155 a == LIBMTP_FILETYPE_UNDEF_AUDIO)
158 * \def LIBMTP_FILETYPE_IS_VIDEO
159 * Video filetype test.
161 * For filetypes that can be either audio
162 * or video, use LIBMTP_FILETYPE_IS_AUDIOVIDEO
164 #define LIBMTP_FILETYPE_IS_VIDEO(a)\
165 (a == LIBMTP_FILETYPE_WMV ||\
166 a == LIBMTP_FILETYPE_AVI ||\
167 a == LIBMTP_FILETYPE_MPEG ||\
168 a == LIBMTP_FILETYPE_UNDEF_VIDEO)
171 * \def LIBMTP_FILETYPE_IS_AUDIOVIDEO
172 * Audio and&slash;or video filetype test.
174 #define LIBMTP_FILETYPE_IS_AUDIOVIDEO(a)\
175 (a == LIBMTP_FILETYPE_MP4 ||\
176 a == LIBMTP_FILETYPE_ASF ||\
177 a == LIBMTP_FILETYPE_QT)
180 * \def LIBMTP_FILETYPE_IS_TRACK
181 * Test if filetype is a track.
182 * Use this to determine if the File API or Track API
183 * should be used to upload or download an object.
185 #define LIBMTP_FILETYPE_IS_TRACK(a)\
186 (LIBMTP_FILETYPE_IS_AUDIO(a) ||\
187 LIBMTP_FILETYPE_IS_VIDEO(a) ||\
188 LIBMTP_FILETYPE_IS_AUDIOVIDEO(a))
191 * \def LIBMTP_FILETYPE_IS_IMAGE
192 * Image filetype test
194 #define LIBMTP_FILETYPE_IS_IMAGE(a)\
195 (a == LIBMTP_FILETYPE_JPEG ||\
196 a == LIBMTP_FILETYPE_JFIF ||\
197 a == LIBMTP_FILETYPE_TIFF ||\
198 a == LIBMTP_FILETYPE_BMP ||\
199 a == LIBMTP_FILETYPE_GIF ||\
200 a == LIBMTP_FILETYPE_PICT ||\
201 a == LIBMTP_FILETYPE_PNG ||\
202 a == LIBMTP_FILETYPE_JP2 ||\
203 a == LIBMTP_FILETYPE_JPX ||\
204 a == LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT)
207 * \def LIBMTP_FILETYPE_IS_ADDRESSBOOK
208 * Addressbook and Business card filetype test
210 #define LIBMTP_FILETYPE_IS_ADDRESSBOOK(a)\
211 (a == LIBMTP_FILETYPE_VCARD2 ||\
212 a == LIBMTP_FILETYPE_VCARD3)
215 * \def LIBMTP_FILETYPE_IS_CALENDAR
216 * Calendar and Appointment filetype test
218 #define LIBMTP_FILETYPE_IS_CALENDAR(a)\
219 (a == LIBMTP_FILETYPE_VCALENDAR1 ||\
220 a == LIBMTP_FILETYPE_VCALENDAR2)
223 * The properties defined here are the external types used
224 * by the libmtp library interface.
227 LIBMTP_PROPERTY_StorageID,
228 LIBMTP_PROPERTY_ObjectFormat,
229 LIBMTP_PROPERTY_ProtectionStatus,
230 LIBMTP_PROPERTY_ObjectSize,
231 LIBMTP_PROPERTY_AssociationType,
232 LIBMTP_PROPERTY_AssociationDesc,
233 LIBMTP_PROPERTY_ObjectFileName,
234 LIBMTP_PROPERTY_DateCreated,
235 LIBMTP_PROPERTY_DateModified,
236 LIBMTP_PROPERTY_Keywords,
237 LIBMTP_PROPERTY_ParentObject,
238 LIBMTP_PROPERTY_AllowedFolderContents,
239 LIBMTP_PROPERTY_Hidden,
240 LIBMTP_PROPERTY_SystemObject,
241 LIBMTP_PROPERTY_PersistantUniqueObjectIdentifier,
242 LIBMTP_PROPERTY_SyncID,
243 LIBMTP_PROPERTY_PropertyBag,
244 LIBMTP_PROPERTY_Name,
245 LIBMTP_PROPERTY_CreatedBy,
246 LIBMTP_PROPERTY_Artist,
247 LIBMTP_PROPERTY_DateAuthored,
248 LIBMTP_PROPERTY_Description,
249 LIBMTP_PROPERTY_URLReference,
250 LIBMTP_PROPERTY_LanguageLocale,
251 LIBMTP_PROPERTY_CopyrightInformation,
252 LIBMTP_PROPERTY_Source,
253 LIBMTP_PROPERTY_OriginLocation,
254 LIBMTP_PROPERTY_DateAdded,
255 LIBMTP_PROPERTY_NonConsumable,
256 LIBMTP_PROPERTY_CorruptOrUnplayable,
257 LIBMTP_PROPERTY_ProducerSerialNumber,
258 LIBMTP_PROPERTY_RepresentativeSampleFormat,
259 LIBMTP_PROPERTY_RepresentativeSampleSize,
260 LIBMTP_PROPERTY_RepresentativeSampleHeight,
261 LIBMTP_PROPERTY_RepresentativeSampleWidth,
262 LIBMTP_PROPERTY_RepresentativeSampleDuration,
263 LIBMTP_PROPERTY_RepresentativeSampleData,
264 LIBMTP_PROPERTY_Width,
265 LIBMTP_PROPERTY_Height,
266 LIBMTP_PROPERTY_Duration,
267 LIBMTP_PROPERTY_Rating,
268 LIBMTP_PROPERTY_Track,
269 LIBMTP_PROPERTY_Genre,
270 LIBMTP_PROPERTY_Credits,
271 LIBMTP_PROPERTY_Lyrics,
272 LIBMTP_PROPERTY_SubscriptionContentID,
273 LIBMTP_PROPERTY_ProducedBy,
274 LIBMTP_PROPERTY_UseCount,
275 LIBMTP_PROPERTY_SkipCount,
276 LIBMTP_PROPERTY_LastAccessed,
277 LIBMTP_PROPERTY_ParentalRating,
278 LIBMTP_PROPERTY_MetaGenre,
279 LIBMTP_PROPERTY_Composer,
280 LIBMTP_PROPERTY_EffectiveRating,
281 LIBMTP_PROPERTY_Subtitle,
282 LIBMTP_PROPERTY_OriginalReleaseDate,
283 LIBMTP_PROPERTY_AlbumName,
284 LIBMTP_PROPERTY_AlbumArtist,
285 LIBMTP_PROPERTY_Mood,
286 LIBMTP_PROPERTY_DRMStatus,
287 LIBMTP_PROPERTY_SubDescription,
288 LIBMTP_PROPERTY_IsCropped,
289 LIBMTP_PROPERTY_IsColorCorrected,
290 LIBMTP_PROPERTY_ImageBitDepth,
291 LIBMTP_PROPERTY_Fnumber,
292 LIBMTP_PROPERTY_ExposureTime,
293 LIBMTP_PROPERTY_ExposureIndex,
294 LIBMTP_PROPERTY_DisplayName,
295 LIBMTP_PROPERTY_BodyText,
296 LIBMTP_PROPERTY_Subject,
297 LIBMTP_PROPERTY_Priority,
298 LIBMTP_PROPERTY_GivenName,
299 LIBMTP_PROPERTY_MiddleNames,
300 LIBMTP_PROPERTY_FamilyName,
301 LIBMTP_PROPERTY_Prefix,
302 LIBMTP_PROPERTY_Suffix,
303 LIBMTP_PROPERTY_PhoneticGivenName,
304 LIBMTP_PROPERTY_PhoneticFamilyName,
305 LIBMTP_PROPERTY_EmailPrimary,
306 LIBMTP_PROPERTY_EmailPersonal1,
307 LIBMTP_PROPERTY_EmailPersonal2,
308 LIBMTP_PROPERTY_EmailBusiness1,
309 LIBMTP_PROPERTY_EmailBusiness2,
310 LIBMTP_PROPERTY_EmailOthers,
311 LIBMTP_PROPERTY_PhoneNumberPrimary,
312 LIBMTP_PROPERTY_PhoneNumberPersonal,
313 LIBMTP_PROPERTY_PhoneNumberPersonal2,
314 LIBMTP_PROPERTY_PhoneNumberBusiness,
315 LIBMTP_PROPERTY_PhoneNumberBusiness2,
316 LIBMTP_PROPERTY_PhoneNumberMobile,
317 LIBMTP_PROPERTY_PhoneNumberMobile2,
318 LIBMTP_PROPERTY_FaxNumberPrimary,
319 LIBMTP_PROPERTY_FaxNumberPersonal,
320 LIBMTP_PROPERTY_FaxNumberBusiness,
321 LIBMTP_PROPERTY_PagerNumber,
322 LIBMTP_PROPERTY_PhoneNumberOthers,
323 LIBMTP_PROPERTY_PrimaryWebAddress,
324 LIBMTP_PROPERTY_PersonalWebAddress,
325 LIBMTP_PROPERTY_BusinessWebAddress,
326 LIBMTP_PROPERTY_InstantMessengerAddress,
327 LIBMTP_PROPERTY_InstantMessengerAddress2,
328 LIBMTP_PROPERTY_InstantMessengerAddress3,
329 LIBMTP_PROPERTY_PostalAddressPersonalFull,
330 LIBMTP_PROPERTY_PostalAddressPersonalFullLine1,
331 LIBMTP_PROPERTY_PostalAddressPersonalFullLine2,
332 LIBMTP_PROPERTY_PostalAddressPersonalFullCity,
333 LIBMTP_PROPERTY_PostalAddressPersonalFullRegion,
334 LIBMTP_PROPERTY_PostalAddressPersonalFullPostalCode,
335 LIBMTP_PROPERTY_PostalAddressPersonalFullCountry,
336 LIBMTP_PROPERTY_PostalAddressBusinessFull,
337 LIBMTP_PROPERTY_PostalAddressBusinessLine1,
338 LIBMTP_PROPERTY_PostalAddressBusinessLine2,
339 LIBMTP_PROPERTY_PostalAddressBusinessCity,
340 LIBMTP_PROPERTY_PostalAddressBusinessRegion,
341 LIBMTP_PROPERTY_PostalAddressBusinessPostalCode,
342 LIBMTP_PROPERTY_PostalAddressBusinessCountry,
343 LIBMTP_PROPERTY_PostalAddressOtherFull,
344 LIBMTP_PROPERTY_PostalAddressOtherLine1,
345 LIBMTP_PROPERTY_PostalAddressOtherLine2,
346 LIBMTP_PROPERTY_PostalAddressOtherCity,
347 LIBMTP_PROPERTY_PostalAddressOtherRegion,
348 LIBMTP_PROPERTY_PostalAddressOtherPostalCode,
349 LIBMTP_PROPERTY_PostalAddressOtherCountry,
350 LIBMTP_PROPERTY_OrganizationName,
351 LIBMTP_PROPERTY_PhoneticOrganizationName,
352 LIBMTP_PROPERTY_Role,
353 LIBMTP_PROPERTY_Birthdate,
354 LIBMTP_PROPERTY_MessageTo,
355 LIBMTP_PROPERTY_MessageCC,
356 LIBMTP_PROPERTY_MessageBCC,
357 LIBMTP_PROPERTY_MessageRead,
358 LIBMTP_PROPERTY_MessageReceivedTime,
359 LIBMTP_PROPERTY_MessageSender,
360 LIBMTP_PROPERTY_ActivityBeginTime,
361 LIBMTP_PROPERTY_ActivityEndTime,
362 LIBMTP_PROPERTY_ActivityLocation,
363 LIBMTP_PROPERTY_ActivityRequiredAttendees,
364 LIBMTP_PROPERTY_ActivityOptionalAttendees,
365 LIBMTP_PROPERTY_ActivityResources,
366 LIBMTP_PROPERTY_ActivityAccepted,
367 LIBMTP_PROPERTY_Owner,
368 LIBMTP_PROPERTY_Editor,
369 LIBMTP_PROPERTY_Webmaster,
370 LIBMTP_PROPERTY_URLSource,
371 LIBMTP_PROPERTY_URLDestination,
372 LIBMTP_PROPERTY_TimeBookmark,
373 LIBMTP_PROPERTY_ObjectBookmark,
374 LIBMTP_PROPERTY_ByteBookmark,
375 LIBMTP_PROPERTY_LastBuildDate,
376 LIBMTP_PROPERTY_TimetoLive,
377 LIBMTP_PROPERTY_MediaGUID,
378 LIBMTP_PROPERTY_TotalBitRate,
379 LIBMTP_PROPERTY_BitRateType,
380 LIBMTP_PROPERTY_SampleRate,
381 LIBMTP_PROPERTY_NumberOfChannels,
382 LIBMTP_PROPERTY_AudioBitDepth,
383 LIBMTP_PROPERTY_ScanDepth,
384 LIBMTP_PROPERTY_AudioWAVECodec,
385 LIBMTP_PROPERTY_AudioBitRate,
386 LIBMTP_PROPERTY_VideoFourCCCodec,
387 LIBMTP_PROPERTY_VideoBitRate,
388 LIBMTP_PROPERTY_FramesPerThousandSeconds,
389 LIBMTP_PROPERTY_KeyFrameDistance,
390 LIBMTP_PROPERTY_BufferSize,
391 LIBMTP_PROPERTY_EncodingQuality,
392 LIBMTP_PROPERTY_EncodingProfile,
393 LIBMTP_PROPERTY_BuyFlag,
394 LIBMTP_PROPERTY_UNKNOWN
398 * These are the data types
401 LIBMTP_DATATYPE_INT8,
402 LIBMTP_DATATYPE_UINT8,
403 LIBMTP_DATATYPE_INT16,
404 LIBMTP_DATATYPE_UINT16,
405 LIBMTP_DATATYPE_INT32,
406 LIBMTP_DATATYPE_UINT32,
407 LIBMTP_DATATYPE_INT64,
408 LIBMTP_DATATYPE_UINT64,
412 * These are device capabilities
416 * This capability tells whether you can call the funcion getting
417 * partial objects, @see LIBMTP_GetPartialObject()
419 LIBMTP_DEVICECAP_GetPartialObject,
421 * This capability tells whether you can call the function sending
422 * partial objects. @see LIBMTP_SendPartialObject()
424 LIBMTP_DEVICECAP_SendPartialObject,
426 * This capability tells whether you can call the functions editing
427 * objects in-place on a device.
428 * @see LIBMTP_BeginEditObject()
429 * @see LIBMTP_EndEditObject()
430 * @see LIBMTP_TruncateObject()
432 LIBMTP_DEVICECAP_EditObjects,
433 } LIBMTP_devicecap_t;
436 * These are the numbered error codes. You can also
437 * get string representations for errors.
441 LIBMTP_ERROR_GENERAL,
442 LIBMTP_ERROR_PTP_LAYER,
443 LIBMTP_ERROR_USB_LAYER,
444 LIBMTP_ERROR_MEMORY_ALLOCATION,
445 LIBMTP_ERROR_NO_DEVICE_ATTACHED,
446 LIBMTP_ERROR_STORAGE_FULL,
447 LIBMTP_ERROR_CONNECTING,
448 LIBMTP_ERROR_CANCELLED
449 } LIBMTP_error_number_t;
451 typedef struct LIBMTP_device_entry_struct LIBMTP_device_entry_t; /**< @see LIBMTP_device_entry_struct */
452 typedef struct LIBMTP_raw_device_struct LIBMTP_raw_device_t; /**< @see LIBMTP_raw_device_struct */
453 typedef struct LIBMTP_error_struct LIBMTP_error_t; /**< @see LIBMTP_error_struct */
454 typedef struct LIBMTP_allowed_values_struct LIBMTP_allowed_values_t; /**< @see LIBMTP_allowed_values_struct */
455 typedef struct LIBMTP_device_extension_struct LIBMTP_device_extension_t; /** < @see LIBMTP_device_extension_struct */
456 typedef struct LIBMTP_mtpdevice_struct LIBMTP_mtpdevice_t; /**< @see LIBMTP_mtpdevice_struct */
457 typedef struct LIBMTP_file_struct LIBMTP_file_t; /**< @see LIBMTP_file_struct */
458 typedef struct LIBMTP_track_struct LIBMTP_track_t; /**< @see LIBMTP_track_struct */
459 typedef struct LIBMTP_playlist_struct LIBMTP_playlist_t; /**< @see LIBMTP_playlist_struct */
460 typedef struct LIBMTP_album_struct LIBMTP_album_t; /**< @see LIBMTP_album_struct */
461 typedef struct LIBMTP_folder_struct LIBMTP_folder_t; /**< @see LIBMTP_folder_t */
462 typedef struct LIBMTP_object_struct LIBMTP_object_t; /**< @see LIBMTP_object_t */
463 typedef struct LIBMTP_filesampledata_struct LIBMTP_filesampledata_t; /**< @see LIBMTP_filesample_t */
464 typedef struct LIBMTP_devicestorage_struct LIBMTP_devicestorage_t; /**< @see LIBMTP_devicestorage_t */
467 * The callback type definition. Notice that a progress percentage ratio
468 * is easy to calculate by dividing <code>sent</code> by
469 * <code>total</code>.
470 * @param sent the number of bytes sent so far
471 * @param total the total number of bytes to send
472 * @param data a user-defined dereferencable pointer
473 * @return if anything else than 0 is returned, the current transfer will be
474 * interrupted / cancelled.
476 typedef int (* LIBMTP_progressfunc_t) (uint64_t const sent, uint64_t const total,
477 void const * const data);
480 * Callback function for get by handler function
481 * @param params the device parameters
482 * @param priv a user-defined dereferencable pointer
483 * @param wantlen the number of bytes wanted
484 * @param data a buffer to write the data to
485 * @param gotlen pointer to the number of bytes actually written
487 * @return LIBMTP_HANDLER_RETURN_OK if successful,
488 * LIBMTP_HANDLER_RETURN_ERROR on error or
489 * LIBMTP_HANDLER_RETURN_CANCEL to cancel the transfer
491 typedef uint16_t (* MTPDataGetFunc) (void* params, void* priv,
492 uint32_t wantlen, unsigned char *data, uint32_t *gotlen);
495 * Callback function for put by handler function
496 * @param params the device parameters
497 * @param priv a user-defined dereferencable pointer
498 * @param sendlen the number of bytes available
499 * @param data a buffer to read the data from
500 * @param putlen pointer to the number of bytes actually read
502 * @return LIBMTP_HANDLER_RETURN_OK if successful,
503 * LIBMTP_HANDLER_RETURN_ERROR on error or
504 * LIBMTP_HANDLER_RETURN_CANCEL to cancel the transfer
506 typedef uint16_t (* MTPDataPutFunc) (void* params, void* priv,
507 uint32_t sendlen, unsigned char *data, uint32_t *putlen);
510 * The return codes for the get/put functions
512 #define LIBMTP_HANDLER_RETURN_OK 0
513 #define LIBMTP_HANDLER_RETURN_ERROR 1
514 #define LIBMTP_HANDLER_RETURN_CANCEL 2
518 * @defgroup structar libmtp data structures
523 * A data structure to hold MTP device entries.
525 struct LIBMTP_device_entry_struct {
526 char *vendor; /**< The vendor of this device */
527 uint16_t vendor_id; /**< Vendor ID for this device */
528 char *product; /**< The product name of this device */
529 uint16_t product_id; /**< Product ID for this device */
530 uint32_t device_flags; /**< Bugs, device specifics etc */
534 * A data structure to hold a raw MTP device connected
537 struct LIBMTP_raw_device_struct {
538 LIBMTP_device_entry_t device_entry; /**< The device entry for this raw device */
539 uint32_t bus_location; /**< Location of the bus, if device available */
540 uint8_t devnum; /**< Device number on the bus, if device available */
541 uint8_t portnum; /**< Port number on the bus, if device available */
545 * A data structure to hold errors from the library.
547 struct LIBMTP_error_struct {
548 LIBMTP_error_number_t errornumber;
550 LIBMTP_error_t *next;
554 * A data structure to hold allowed ranges of values
556 struct LIBMTP_allowed_values_struct {
590 * Number of entries in the vals array
592 uint16_t num_entries;
594 * The datatype specifying which of the above is used
596 LIBMTP_datatype_t datatype;
598 * Non zero for range, 0 for enum
604 * MTP device extension holder struct
606 struct LIBMTP_device_extension_struct {
608 * Name of extension e.g. "foo.com"
612 * Major revision of extension
616 * Minor revision of extension
620 * Pointer to the next extension or NULL if this is the
623 LIBMTP_device_extension_t *next;
627 * Main MTP device object struct
629 struct LIBMTP_mtpdevice_struct {
631 * Object bitsize, typically 32 or 64.
633 uint8_t object_bitsize;
635 * Parameters for this device, must be cast into
636 * \c (PTPParams*) before internal use.
640 * USB device for this device, must be cast into
641 * \c (PTP_USB*) before internal use.
645 * The storage for this device, do not use strings in here without
646 * copying them first, and beware that this list may be rebuilt at
648 * @see LIBMTP_Get_Storage()
650 LIBMTP_devicestorage_t *storage;
652 * The error stack. This shall be handled using the error getting
653 * and clearing functions, not by dereferencing this list.
655 LIBMTP_error_t *errorstack;
656 /** The maximum battery level for this device */
657 uint8_t maximum_battery_level;
658 /** Default music folder */
659 uint32_t default_music_folder;
660 /** Default playlist folder */
661 uint32_t default_playlist_folder;
662 /** Default picture folder */
663 uint32_t default_picture_folder;
664 /** Default video folder */
665 uint32_t default_video_folder;
666 /** Default organizer folder */
667 uint32_t default_organizer_folder;
668 /** Default ZENcast folder (only Creative devices...) */
669 uint32_t default_zencast_folder;
670 /** Default Album folder */
671 uint32_t default_album_folder;
672 /** Default Text folder */
673 uint32_t default_text_folder;
674 /** Per device iconv() converters, only used internally */
676 /** Extension list */
677 LIBMTP_device_extension_t *extensions;
678 /** Whether the device uses caching, only used internally */
681 /** Pointer to next device in linked list; NULL if this is the last device */
682 LIBMTP_mtpdevice_t *next;
688 struct LIBMTP_file_struct {
689 uint32_t item_id; /**< Unique item ID */
690 uint32_t parent_id; /**< ID of parent folder */
691 uint32_t storage_id; /**< ID of storage holding this file */
692 char *filename; /**< Filename of this file */
693 uint64_t filesize; /**< Size of file in bytes */
694 time_t modificationdate; /**< Date of last alteration of the file */
695 LIBMTP_filetype_t filetype; /**< Filetype used for the current file */
696 LIBMTP_file_t *next; /**< Next file in list or NULL if last file */
702 struct LIBMTP_track_struct {
703 uint32_t item_id; /**< Unique item ID */
704 uint32_t parent_id; /**< ID of parent folder */
705 uint32_t storage_id; /**< ID of storage holding this track */
706 char *title; /**< Track title */
707 char *artist; /**< Name of recording artist */
708 char *composer; /**< Name of recording composer */
709 char *genre; /**< Genre name for track */
710 char *album; /**< Album name for track */
711 char *date; /**< Date of original recording as a string */
712 char *filename; /**< Original filename of this track */
713 uint16_t tracknumber; /**< Track number (in sequence on recording) */
714 uint32_t duration; /**< Duration in milliseconds */
715 uint32_t samplerate; /**< Sample rate of original file, min 0x1f80 max 0xbb80 */
716 uint16_t nochannels; /**< Number of channels in this recording 0 = unknown, 1 or 2 */
717 uint32_t wavecodec; /**< FourCC wave codec name */
718 uint32_t bitrate; /**< (Average) bitrate for this file min=1 max=0x16e360 */
719 uint16_t bitratetype; /**< 0 = unused, 1 = constant, 2 = VBR, 3 = free */
720 uint16_t rating; /**< User rating 0-100 (0x00-0x64) */
721 uint32_t usecount; /**< Number of times used/played */
722 uint64_t filesize; /**< Size of track file in bytes */
723 time_t modificationdate; /**< Date of last alteration of the track */
724 LIBMTP_filetype_t filetype; /**< Filetype used for the current track */
725 LIBMTP_track_t *next; /**< Next track in list or NULL if last track */
729 * MTP Playlist structure
731 struct LIBMTP_playlist_struct {
732 uint32_t playlist_id; /**< Unique playlist ID */
733 uint32_t parent_id; /**< ID of parent folder */
734 uint32_t storage_id; /**< ID of storage holding this playlist */
735 char *name; /**< Name of playlist */
736 uint32_t *tracks; /**< The tracks in this playlist */
737 uint32_t no_tracks; /**< The number of tracks in this playlist */
738 LIBMTP_playlist_t *next; /**< Next playlist or NULL if last playlist */
742 * MTP Album structure
744 struct LIBMTP_album_struct {
745 uint32_t album_id; /**< Unique playlist ID */
746 uint32_t parent_id; /**< ID of parent folder */
747 uint32_t storage_id; /**< ID of storage holding this album */
748 char *name; /**< Name of album */
749 char *artist; /**< Name of album artist */
750 char *composer; /**< Name of recording composer */
751 char *genre; /**< Genre of album */
752 uint32_t *tracks; /**< The tracks in this album */
753 uint32_t no_tracks; /**< The number of tracks in this album */
754 LIBMTP_album_t *next; /**< Next album or NULL if last album */
758 * MTP Folder structure
760 struct LIBMTP_folder_struct {
761 uint32_t folder_id; /**< Unique folder ID */
762 uint32_t parent_id; /**< ID of parent folder */
763 uint32_t storage_id; /**< ID of storage holding this folder */
764 char *name; /**< Name of folder */
765 LIBMTP_folder_t *sibling; /**< Next folder at same level or NULL if no more */
766 LIBMTP_folder_t *child; /**< Child folder or NULL if no children */
770 * LIBMTP Object RepresentativeSampleData Structure
772 struct LIBMTP_filesampledata_struct {
773 uint32_t width; /**< Width of sample if it is an image */
774 uint32_t height; /**< Height of sample if it is an image */
775 uint32_t duration; /**< Duration in milliseconds if it is audio */
776 LIBMTP_filetype_t filetype; /**< Filetype used for the sample */
777 uint64_t size; /**< Size of sample data in bytes */
778 char *data; /**< Sample data */
782 * LIBMTP Device Storage structure
784 struct LIBMTP_devicestorage_struct {
785 uint32_t id; /**< Unique ID for this storage */
786 uint16_t StorageType; /**< Storage type */
787 uint16_t FilesystemType; /**< Filesystem type */
788 uint16_t AccessCapability; /**< Access capability */
789 uint64_t MaxCapacity; /**< Maximum capability */
790 uint64_t FreeSpaceInBytes; /**< Free space in bytes */
791 uint64_t FreeSpaceInObjects; /**< Free space in objects */
792 char *StorageDescription; /**< A brief description of this storage */
793 char *VolumeIdentifier; /**< A volume identifier */
794 LIBMTP_devicestorage_t *next; /**< Next storage, follow this link until NULL */
795 LIBMTP_devicestorage_t *prev; /**< Previous storage */
799 struct _MTPObjectInfo {
801 uint16_t ObjectFormat;
802 uint16_t ProtectionStatus;
803 /* In the regular objectinfo this is 32bit,
804 * but we keep the general object size here
805 * that also arrives via other methods and so
807 uint64_t ObjectCompressedSize;
808 uint16_t ThumbFormat;
809 uint32_t ThumbCompressedSize;
810 uint32_t ThumbPixWidth;
811 uint32_t ThumbPixHeight;
812 uint32_t ImagePixWidth;
813 uint32_t ImagePixHeight;
814 uint32_t ImageBitDepth;
815 uint32_t ParentObject;
816 uint16_t AssociationType;
817 uint32_t AssociationDesc;
818 uint32_t SequenceNumber;
821 time_t ModificationDate;
824 typedef struct _MTPObjectInfo MTPObjectInfo;
825 #endif /* TIZEN_EXT */
828 * LIBMTP Event structure
829 * TODO: add all externally visible events here
831 enum LIBMTP_event_enum {
833 LIBMTP_EVENT_STORE_ADDED,
834 LIBMTP_EVENT_STORE_REMOVED,
835 LIBMTP_EVENT_OBJECT_ADDED,
836 LIBMTP_EVENT_OBJECT_REMOVED,
838 typedef enum LIBMTP_event_enum LIBMTP_event_t;
842 /* Make functions available for C++ */
847 extern int LIBMTP_debug;
850 * @defgroup internals The libmtp internals API.
853 void LIBMTP_Set_Debug(int);
854 void LIBMTP_Init(void);
855 int LIBMTP_Get_Supported_Devices_List(LIBMTP_device_entry_t ** const, int * const);
858 * @defgroup basic The basic device management API.
861 LIBMTP_error_number_t LIBMTP_Detect_Raw_Devices(LIBMTP_raw_device_t **, int *);
862 int LIBMTP_Check_Specific_Device(int busno, int devno);
863 LIBMTP_mtpdevice_t *LIBMTP_Open_Raw_Device(LIBMTP_raw_device_t *);
864 LIBMTP_mtpdevice_t *LIBMTP_Open_Raw_Device_Uncached(LIBMTP_raw_device_t *);
865 /* Begin old, legacy interface */
866 LIBMTP_mtpdevice_t *LIBMTP_Get_First_Device(void);
867 LIBMTP_error_number_t LIBMTP_Get_Connected_Devices(LIBMTP_mtpdevice_t **);
868 uint32_t LIBMTP_Number_Devices_In_List(LIBMTP_mtpdevice_t *);
869 void LIBMTP_Release_Device_List(LIBMTP_mtpdevice_t*);
870 /* End old, legacy interface */
871 void LIBMTP_Release_Device(LIBMTP_mtpdevice_t*);
872 void LIBMTP_Dump_Device_Info(LIBMTP_mtpdevice_t*);
873 int LIBMTP_Reset_Device(LIBMTP_mtpdevice_t*);
874 char *LIBMTP_Get_Manufacturername(LIBMTP_mtpdevice_t*);
875 char *LIBMTP_Get_Modelname(LIBMTP_mtpdevice_t*);
876 char *LIBMTP_Get_Serialnumber(LIBMTP_mtpdevice_t*);
877 char *LIBMTP_Get_Deviceversion(LIBMTP_mtpdevice_t*);
878 char *LIBMTP_Get_Friendlyname(LIBMTP_mtpdevice_t*);
879 int LIBMTP_Set_Friendlyname(LIBMTP_mtpdevice_t*, char const * const);
880 char *LIBMTP_Get_Syncpartner(LIBMTP_mtpdevice_t*);
881 int LIBMTP_Set_Syncpartner(LIBMTP_mtpdevice_t*, char const * const);
882 int LIBMTP_Get_Batterylevel(LIBMTP_mtpdevice_t *,
885 int LIBMTP_Get_Secure_Time(LIBMTP_mtpdevice_t *, char ** const);
886 int LIBMTP_Get_Device_Certificate(LIBMTP_mtpdevice_t *, char ** const);
887 int LIBMTP_Get_Supported_Filetypes(LIBMTP_mtpdevice_t *, uint16_t ** const, uint16_t * const);
888 int LIBMTP_Check_Capability(LIBMTP_mtpdevice_t *, LIBMTP_devicecap_t);
889 LIBMTP_error_t *LIBMTP_Get_Errorstack(LIBMTP_mtpdevice_t*);
890 void LIBMTP_Clear_Errorstack(LIBMTP_mtpdevice_t*);
891 void LIBMTP_Dump_Errorstack(LIBMTP_mtpdevice_t*);
893 #define LIBMTP_STORAGE_SORTBY_NOTSORTED 0
894 #define LIBMTP_STORAGE_SORTBY_FREESPACE 1
895 #define LIBMTP_STORAGE_SORTBY_MAXSPACE 2
897 int LIBMTP_Get_Storage(LIBMTP_mtpdevice_t *, int const);
898 int LIBMTP_Format_Storage(LIBMTP_mtpdevice_t *, LIBMTP_devicestorage_t *);
900 int LIBMTP_Get_Object_Handles(LIBMTP_mtpdevice_t *device, uint32_t storage,
901 uint32_t format, uint32_t parent, uint32_t **object_list, uint32_t *object_num);
902 MTPObjectInfo *LIBMTP_Get_Object_Info(LIBMTP_mtpdevice_t *device, uint32_t object_id);
903 int LIBMTP_Get_Num_Objects(LIBMTP_mtpdevice_t *device, uint32_t format, uint32_t *object_num);
904 #endif /* TIZEN_EXT */
907 * Get/set arbitrary properties. These do not update the cache; should only be used on
908 * properties not stored in structs
910 char *LIBMTP_Get_String_From_Object(LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const);
911 uint64_t LIBMTP_Get_u64_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
912 LIBMTP_property_t const, uint64_t const);
913 uint32_t LIBMTP_Get_u32_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
914 LIBMTP_property_t const, uint32_t const);
915 uint16_t LIBMTP_Get_u16_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
916 LIBMTP_property_t const, uint16_t const);
917 uint8_t LIBMTP_Get_u8_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
918 LIBMTP_property_t const, uint8_t const);
919 int LIBMTP_Set_Object_String(LIBMTP_mtpdevice_t *, uint32_t const,
920 LIBMTP_property_t const, char const * const);
921 int LIBMTP_Set_Object_u32(LIBMTP_mtpdevice_t *, uint32_t const,
922 LIBMTP_property_t const, uint32_t const);
923 int LIBMTP_Set_Object_u16(LIBMTP_mtpdevice_t *, uint32_t const,
924 LIBMTP_property_t const, uint16_t const);
925 int LIBMTP_Set_Object_u8(LIBMTP_mtpdevice_t *, uint32_t const,
926 LIBMTP_property_t const, uint8_t const);
927 char const * LIBMTP_Get_Property_Description(LIBMTP_property_t inproperty);
928 int LIBMTP_Is_Property_Supported(LIBMTP_mtpdevice_t*, LIBMTP_property_t const,
929 LIBMTP_filetype_t const);
930 int LIBMTP_Get_Allowed_Property_Values(LIBMTP_mtpdevice_t*, LIBMTP_property_t const,
931 LIBMTP_filetype_t const, LIBMTP_allowed_values_t*);
932 void LIBMTP_destroy_allowed_values_t(LIBMTP_allowed_values_t*);
936 * @defgroup files The file management API.
939 LIBMTP_file_t *LIBMTP_new_file_t(void);
940 void LIBMTP_destroy_file_t(LIBMTP_file_t*);
941 char const * LIBMTP_Get_Filetype_Description(LIBMTP_filetype_t);
942 LIBMTP_file_t *LIBMTP_Get_Filelisting(LIBMTP_mtpdevice_t *);
943 LIBMTP_file_t *LIBMTP_Get_Filelisting_With_Callback(LIBMTP_mtpdevice_t *,
944 LIBMTP_progressfunc_t const, void const * const);
945 LIBMTP_file_t * LIBMTP_Get_Files_And_Folders(LIBMTP_mtpdevice_t *,
948 LIBMTP_file_t *LIBMTP_Get_Filemetadata(LIBMTP_mtpdevice_t *, uint32_t const);
949 int LIBMTP_Get_File_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
950 LIBMTP_progressfunc_t const, void const * const);
951 int LIBMTP_Get_File_To_File_Descriptor(LIBMTP_mtpdevice_t*,
954 LIBMTP_progressfunc_t const,
956 int LIBMTP_Get_File_To_Handler(LIBMTP_mtpdevice_t *,
960 LIBMTP_progressfunc_t const,
962 int LIBMTP_Send_File_From_File(LIBMTP_mtpdevice_t *,
964 LIBMTP_file_t * const,
965 LIBMTP_progressfunc_t const,
967 int LIBMTP_Send_File_From_File_Descriptor(LIBMTP_mtpdevice_t *,
969 LIBMTP_file_t * const,
970 LIBMTP_progressfunc_t const,
972 int LIBMTP_Send_File_From_Handler(LIBMTP_mtpdevice_t *,
973 MTPDataGetFunc, void *,
974 LIBMTP_file_t * const,
975 LIBMTP_progressfunc_t const,
977 int LIBMTP_Set_File_Name(LIBMTP_mtpdevice_t *,
980 LIBMTP_filesampledata_t *LIBMTP_new_filesampledata_t(void);
981 void LIBMTP_destroy_filesampledata_t(LIBMTP_filesampledata_t *);
982 int LIBMTP_Get_Representative_Sample_Format(LIBMTP_mtpdevice_t *,
983 LIBMTP_filetype_t const,
984 LIBMTP_filesampledata_t **);
985 int LIBMTP_Send_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
986 LIBMTP_filesampledata_t *);
987 int LIBMTP_Get_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
988 LIBMTP_filesampledata_t *);
989 int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *, uint32_t const,
990 unsigned char **data, unsigned int *size);
992 int LIBMTP_Get_Thumbnail_From_Exif_Data(LIBMTP_mtpdevice_t *, uint32_t const,
993 unsigned char **data, unsigned int *size);
994 #endif /* TIZEN_EXT */
998 * @defgroup tracks The track management API.
1001 LIBMTP_track_t *LIBMTP_new_track_t(void);
1002 void LIBMTP_destroy_track_t(LIBMTP_track_t*);
1003 LIBMTP_track_t *LIBMTP_Get_Tracklisting(LIBMTP_mtpdevice_t*);
1004 LIBMTP_track_t *LIBMTP_Get_Tracklisting_With_Callback(LIBMTP_mtpdevice_t*,
1005 LIBMTP_progressfunc_t const, void const * const);
1006 LIBMTP_track_t *LIBMTP_Get_Tracklisting_With_Callback_For_Storage(LIBMTP_mtpdevice_t*, uint32_t const,
1007 LIBMTP_progressfunc_t const, void const * const);
1008 LIBMTP_track_t *LIBMTP_Get_Trackmetadata(LIBMTP_mtpdevice_t*, uint32_t const);
1009 int LIBMTP_Get_Track_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
1010 LIBMTP_progressfunc_t const, void const * const);
1011 int LIBMTP_Get_Track_To_File_Descriptor(LIBMTP_mtpdevice_t*, uint32_t const, int const,
1012 LIBMTP_progressfunc_t const, void const * const);
1013 int LIBMTP_Get_Track_To_Handler(LIBMTP_mtpdevice_t *, uint32_t const, MTPDataPutFunc,
1014 void *, LIBMTP_progressfunc_t const, void const * const);
1015 int LIBMTP_Send_Track_From_File(LIBMTP_mtpdevice_t *,
1016 char const * const, LIBMTP_track_t * const,
1017 LIBMTP_progressfunc_t const,
1018 void const * const);
1019 int LIBMTP_Send_Track_From_File_Descriptor(LIBMTP_mtpdevice_t *,
1020 int const, LIBMTP_track_t * const,
1021 LIBMTP_progressfunc_t const,
1022 void const * const);
1023 int LIBMTP_Send_Track_From_Handler(LIBMTP_mtpdevice_t *,
1024 MTPDataGetFunc, void *, LIBMTP_track_t * const,
1025 LIBMTP_progressfunc_t const,
1026 void const * const);
1027 int LIBMTP_Update_Track_Metadata(LIBMTP_mtpdevice_t *,
1028 LIBMTP_track_t const * const);
1029 int LIBMTP_Track_Exists(LIBMTP_mtpdevice_t *, uint32_t const);
1030 int LIBMTP_Set_Track_Name(LIBMTP_mtpdevice_t *, LIBMTP_track_t *, const char *);
1035 * @defgroup folders The folder management API.
1038 LIBMTP_folder_t *LIBMTP_new_folder_t(void);
1039 void LIBMTP_destroy_folder_t(LIBMTP_folder_t*);
1040 LIBMTP_folder_t *LIBMTP_Get_Folder_List(LIBMTP_mtpdevice_t*);
1041 LIBMTP_folder_t *LIBMTP_Get_Folder_List_For_Storage(LIBMTP_mtpdevice_t*,
1043 LIBMTP_folder_t *LIBMTP_Find_Folder(LIBMTP_folder_t*, uint32_t const);
1044 uint32_t LIBMTP_Create_Folder(LIBMTP_mtpdevice_t*, char *, uint32_t, uint32_t);
1045 int LIBMTP_Set_Folder_Name(LIBMTP_mtpdevice_t *, LIBMTP_folder_t *, const char *);
1051 * @defgroup playlists The audio/video playlist management API.
1054 LIBMTP_playlist_t *LIBMTP_new_playlist_t(void);
1055 void LIBMTP_destroy_playlist_t(LIBMTP_playlist_t *);
1056 LIBMTP_playlist_t *LIBMTP_Get_Playlist_List(LIBMTP_mtpdevice_t *);
1057 LIBMTP_playlist_t *LIBMTP_Get_Playlist(LIBMTP_mtpdevice_t *, uint32_t const);
1058 int LIBMTP_Create_New_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const);
1059 int LIBMTP_Update_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const);
1060 int LIBMTP_Set_Playlist_Name(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *, const char *);
1064 * @defgroup albums The audio/video album management API.
1067 LIBMTP_album_t *LIBMTP_new_album_t(void);
1068 void LIBMTP_destroy_album_t(LIBMTP_album_t *);
1069 LIBMTP_album_t *LIBMTP_Get_Album_List(LIBMTP_mtpdevice_t *);
1070 LIBMTP_album_t *LIBMTP_Get_Album_List_For_Storage(LIBMTP_mtpdevice_t *, uint32_t const);
1071 LIBMTP_album_t *LIBMTP_Get_Album(LIBMTP_mtpdevice_t *, uint32_t const);
1072 int LIBMTP_Create_New_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t * const);
1073 int LIBMTP_Update_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t const * const);
1074 int LIBMTP_Set_Album_Name(LIBMTP_mtpdevice_t *, LIBMTP_album_t *, const char *);
1078 * @defgroup objects The object management API.
1081 int LIBMTP_Delete_Object(LIBMTP_mtpdevice_t *, uint32_t);
1082 int LIBMTP_Set_Object_Filename(LIBMTP_mtpdevice_t *, uint32_t , char *);
1083 int LIBMTP_GetPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
1085 unsigned char **, unsigned int *);
1086 int LIBMTP_SendPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
1087 uint64_t, unsigned char *, unsigned int);
1088 int LIBMTP_BeginEditObject(LIBMTP_mtpdevice_t *, uint32_t const);
1089 int LIBMTP_EndEditObject(LIBMTP_mtpdevice_t *, uint32_t const);
1090 int LIBMTP_TruncateObject(LIBMTP_mtpdevice_t *, uint32_t const, uint64_t);
1094 * @defgroup files The events API.
1097 int LIBMTP_Read_Event(LIBMTP_mtpdevice_t *, LIBMTP_event_t *, uint32_t *);
1101 /* End of C++ exports */
1106 #endif /* LIBMTP_H_INCLUSION_GUARD */