libmtp.h(3)
π libmtp.h π
okay bestie, sit down, hydrate, because this is libmtp.h(3) β a Library Functions Manual page, aka the header of libmtp, the library that lets you talk to MTP devices (yes, like those devices, the music-player-shaped ones, iykyk). It's long, it's got lore, it's got structs, and we're doing it in four parts. Part 1 is the map: the data structures, the macros, and the typedefs. Fr fr, this is the whole cast list before the drama starts. β¨
πΈ NAME πΈ
libmtp β
and that's literally it. The NAME section says libmtp, then a dash, then absolutely nothing. The description said "nah." Respect, honestly. Main character energy. π
π¦ SYNOPSIS π¦
First, the vibes β these are the headers you pull in before you even think about touching this library:
#include <sys/time.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
That's the pregame. Now the actual contents of the header, in three categories. Let's go. π
β¨ Data Structures β¨
Meet the cast. Every single one of these is a struct you're gonna be holding hands with:
struct LIBMTP_device_entry_structstruct LIBMTP_raw_device_structstruct LIBMTP_error_structstruct LIBMTP_allowed_values_structstruct LIBMTP_device_extension_structstruct LIBMTP_mtpdevice_structstruct LIBMTP_file_structstruct LIBMTP_track_structstruct LIBMTP_playlist_structstruct LIBMTP_album_structstruct LIBMTP_folder_structstruct LIBMTP_filesampledata_structstruct LIBMTP_devicestorage_struct
Thirteen structs. Not me counting them. Okay I counted them. π
π Macros π
okay so this is the constants-and-helpers section and it ate. Let's do them in order because alphabetical chaos is not the vibe:
#define LIBMTP_VERSION 1.1.23β the version number, the numbers say what they say.#define LIBMTP_VERSION_STRING '1.1.23'β same energy, but as a string this time.#define LIBMTP_DEBUG_NONE 0x00β no debug output, peace and quiet.#define LIBMTP_DEBUG_PTP 0x01β debug flag for the PTP layer.#define LIBMTP_DEBUG_PLST 0x02β debug flag for the playlist layer.#define LIBMTP_DEBUG_USB 0x04β debug flag for the USB layer.#define LIBMTP_DEBUG_DATA 0x08β debug flag for the data layer.#define LIBMTP_DEBUG_ALL 0xFFβ ALL the debug. everything. no filter.#define LIBMTP_FILETYPE_IS_AUDIO(a)β macro that checks whether a filetype is audio.#define LIBMTP_FILETYPE_IS_VIDEO(a)β checks whether it's video.#define LIBMTP_FILETYPE_IS_AUDIOVIDEO(a)β checks whether it's audiovisual.#define LIBMTP_FILETYPE_IS_TRACK(a)β checks whether it's a track.#define LIBMTP_FILETYPE_IS_IMAGE(a)β checks whether it's an image.#define LIBMTP_FILETYPE_IS_ADDRESSBOOK(a)β checks whether it's an addressbook.#define LIBMTP_FILETYPE_IS_CALENDAR(a)β checks whether it's a calendar.#define LIBMTP_HANDLER_RETURN_OK 0β handler says: all good, slay.#define LIBMTP_HANDLER_RETURN_ERROR 1β handler says: something went wrong. π#define LIBMTP_HANDLER_RETURN_CANCEL 2β handler says: cancel that, we're done here.#define LIBMTP_STORAGE_SORTBY_NOTSORTED 0β don't sort the storage, leave it as-is.#define LIBMTP_STORAGE_SORTBY_FREESPACE 1β sort storage by free space.#define LIBMTP_STORAGE_SORTBY_MAXSPACE 2β sort storage by maximum space.#define LIBMTP_FILES_AND_FOLDERS_ROOT 0xffffffffβ the value that means "the root of files and folders."
π Typedefs π
Now the nicknames, because typing struct Whatever_struct every time is exhausting and we do not have the energy bestie.
Struct typedefs β the glow-ups:
typedef struct LIBMTP_device_entry_struct LIBMTP_device_entry_ttypedef struct LIBMTP_raw_device_struct LIBMTP_raw_device_ttypedef struct LIBMTP_error_struct LIBMTP_error_ttypedef struct LIBMTP_allowed_values_struct LIBMTP_allowed_values_ttypedef struct LIBMTP_device_extension_struct LIBMTP_device_extension_ttypedef struct LIBMTP_mtpdevice_struct LIBMTP_mtpdevice_ttypedef struct LIBMTP_file_struct LIBMTP_file_ttypedef struct LIBMTP_track_struct LIBMTP_track_ttypedef struct LIBMTP_playlist_struct LIBMTP_playlist_ttypedef struct LIBMTP_album_struct LIBMTP_album_ttypedef struct LIBMTP_folder_struct LIBMTP_folder_ttypedef struct LIBMTP_filesampledata_struct LIBMTP_filesampledata_ttypedef struct LIBMTP_devicestorage_struct LIBMTP_devicestorage_t
Function-pointer typedefs β the callback crew (these are the ones you actually gotta get right, no cap):
typedef int(* LIBMTP_progressfunc_t) (uint64_t const sent, uint64_t const total, void const *const data)β a progress callback. it gets handedsentandtotalcounts plus adatapointer, and returns anint.typedef uint16_t(* MTPDataGetFunc) (void *params, void *priv, uint32_t wantlen, unsigned char *data, uint32_t *gotlen)β a get-a-chunk-of-data callback. it takesparams,priv,wantlen, adatabuffer and agotlenout-pointer, and returns auint16_t.typedef uint16_t(* MTPDataPutFunc) (void *params, void *priv, uint32_t sendlen, unsigned char *data, uint32_t *putlen)β the put-a-chunk-of-data twin. it takesparams,priv,sendlen,dataand aputlenout-pointer, and returns auint16_t.typedef enum LIBMTP_event_enum LIBMTP_event_tβ the event enum, wearing its_tname tag.typedef void(* LIBMTP_event_cb_fn) (int, LIBMTP_event_t, uint32_t, void *)β the event callback. it receives anint, anLIBMTP_event_t, auint32_t, and avoid *, and returns nothing. it's giving "I'll just react, not reply" and honestly? iconic. π
lowkey that was just the setup bestie β the structs, macros and typedefs. the rest of this page is coming in part 2, so don't you dare close the tab. π«Ά
πβ¨ Enumerations β¨π
okay bestie, this is the big pile of enums π
β every list of named constants this library hands you. Cute little vibes-only words that stand in for numbers, so you never have to remember what 7 means. iconic honestly.
π enum LIBMTP_filetype_t
enum LIBMTP_filetype_t { LIBMTP_FILETYPE_FOLDER, LIBMTP_FILETYPE_WAV,
LIBMTP_FILETYPE_MP3, LIBMTP_FILETYPE_WMA, LIBMTP_FILETYPE_OGG,
LIBMTP_FILETYPE_AUDIBLE, LIBMTP_FILETYPE_MP4,
LIBMTP_FILETYPE_UNDEF_AUDIO, LIBMTP_FILETYPE_WMV,
LIBMTP_FILETYPE_AVI, LIBMTP_FILETYPE_MPEG, LIBMTP_FILETYPE_ASF,
LIBMTP_FILETYPE_QT, LIBMTP_FILETYPE_UNDEF_VIDEO,
LIBMTP_FILETYPE_JPEG, LIBMTP_FILETYPE_JFIF, LIBMTP_FILETYPE_TIFF,
LIBMTP_FILETYPE_BMP, LIBMTP_FILETYPE_GIF, LIBMTP_FILETYPE_PICT,
LIBMTP_FILETYPE_PNG, LIBMTP_FILETYPE_VCALENDAR1,
LIBMTP_FILETYPE_VCALENDAR2, LIBMTP_FILETYPE_VCARD2,
LIBMTP_FILETYPE_VCARD3, LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT,
LIBMTP_FILETYPE_WINEXEC, LIBMTP_FILETYPE_TEXT, LIBMTP_FILETYPE_HTML,
LIBMTP_FILETYPE_FIRMWARE, LIBMTP_FILETYPE_AAC,
LIBMTP_FILETYPE_MEDIACARD, LIBMTP_FILETYPE_FLAC,
LIBMTP_FILETYPE_MP2, LIBMTP_FILETYPE_M4A, LIBMTP_FILETYPE_DOC,
LIBMTP_FILETYPE_XML, LIBMTP_FILETYPE_XLS, LIBMTP_FILETYPE_PPT,
LIBMTP_FILETYPE_MHT, LIBMTP_FILETYPE_JP2, LIBMTP_FILETYPE_JPX,
LIBMTP_FILETYPE_ALBUM, LIBMTP_FILETYPE_PLAYLIST,
LIBMTP_FILETYPE_UNKNOWN }
this is the β¨what even is this fileβ¨ list. audio coded as LIBMTP_FILETYPE_WAV, LIBMTP_FILETYPE_MP3, LIBMTP_FILETYPE_WMA, LIBMTP_FILETYPE_OGG, LIBMTP_FILETYPE_AUDIBLE, LIBMTP_FILETYPE_MP4, LIBMTP_FILETYPE_AAC, LIBMTP_FILETYPE_FLAC, LIBMTP_FILETYPE_MP2, LIBMTP_FILETYPE_M4A. video coded as LIBMTP_FILETYPE_WMV, LIBMTP_FILETYPE_AVI, LIBMTP_FILETYPE_MPEG, LIBMTP_FILETYPE_ASF, LIBMTP_FILETYPE_QT. pics coded as LIBMTP_FILETYPE_JPEG, LIBMTP_FILETYPE_JFIF, LIBMTP_FILETYPE_TIFF, LIBMTP_FILETYPE_BMP, LIBMTP_FILETYPE_GIF, LIBMTP_FILETYPE_PICT, LIBMTP_FILETYPE_PNG, LIBMTP_FILETYPE_JP2, LIBMTP_FILETYPE_JPX, plus LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT. and then the little miscellaneous icons doing their own thing: LIBMTP_FILETYPE_FOLDER, LIBMTP_FILETYPE_TEXT, LIBMTP_FILETYPE_HTML, LIBMTP_FILETYPE_FIRMWARE, LIBMTP_FILETYPE_WINEXEC, LIBMTP_FILETYPE_MEDIACARD, LIBMTP_FILETYPE_DOC, LIBMTP_FILETYPE_XML, LIBMTP_FILETYPE_XLS, LIBMTP_FILETYPE_PPT, LIBMTP_FILETYPE_MHT, LIBMTP_FILETYPE_ALBUM, LIBMTP_FILETYPE_PLAYLIST.
and the calendar/contact girlies stay booked: LIBMTP_FILETYPE_VCALENDAR1, LIBMTP_FILETYPE_VCALENDAR2, LIBMTP_FILETYPE_VCARD2, LIBMTP_FILETYPE_VCARD3.
then the two "we genuinely don't know her" entries: LIBMTP_FILETYPE_UNDEF_AUDIO, LIBMTP_FILETYPE_UNDEF_VIDEO π and finally LIBMTP_FILETYPE_UNKNOWN, which is exactly what it sounds like bestie.
π¦ enum LIBMTP_property_t
enum LIBMTP_property_t { LIBMTP_PROPERTY_StorageID,
LIBMTP_PROPERTY_ObjectFormat, LIBMTP_PROPERTY_ProtectionStatus,
LIBMTP_PROPERTY_ObjectSize, LIBMTP_PROPERTY_AssociationType,
LIBMTP_PROPERTY_AssociationDesc, LIBMTP_PROPERTY_ObjectFileName,
LIBMTP_PROPERTY_DateCreated, LIBMTP_PROPERTY_DateModified,
LIBMTP_PROPERTY_Keywords, LIBMTP_PROPERTY_ParentObject,
LIBMTP_PROPERTY_AllowedFolderContents, LIBMTP_PROPERTY_Hidden,
LIBMTP_PROPERTY_SystemObject,
LIBMTP_PROPERTY_PersistantUniqueObjectIdentifier,
LIBMTP_PROPERTY_SyncID, LIBMTP_PROPERTY_PropertyBag,
LIBMTP_PROPERTY_Name, LIBMTP_PROPERTY_CreatedBy,
LIBMTP_PROPERTY_Artist, LIBMTP_PROPERTY_DateAuthored,
LIBMTP_PROPERTY_Description, LIBMTP_PROPERTY_URLReference,
LIBMTP_PROPERTY_LanguageLocale,
LIBMTP_PROPERTY_CopyrightInformation, LIBMTP_PROPERTY_Source,
LIBMTP_PROPERTY_OriginLocation, LIBMTP_PROPERTY_DateAdded,
LIBMTP_PROPERTY_NonConsumable, LIBMTP_PROPERTY_CorruptOrUnplayable,
LIBMTP_PROPERTY_ProducerSerialNumber,
LIBMTP_PROPERTY_RepresentativeSampleFormat,
LIBMTP_PROPERTY_RepresentativeSampleSize,
LIBMTP_PROPERTY_RepresentativeSampleHeight,
LIBMTP_PROPERTY_RepresentativeSampleWidth,
LIBMTP_PROPERTY_RepresentativeSampleDuration,
LIBMTP_PROPERTY_RepresentativeSampleData, LIBMTP_PROPERTY_Width,
LIBMTP_PROPERTY_Height, LIBMTP_PROPERTY_Duration,
LIBMTP_PROPERTY_Rating, LIBMTP_PROPERTY_Track,
LIBMTP_PROPERTY_Genre, LIBMTP_PROPERTY_Credits,
LIBMTP_PROPERTY_Lyrics, LIBMTP_PROPERTY_SubscriptionContentID,
LIBMTP_PROPERTY_ProducedBy, LIBMTP_PROPERTY_UseCount,
LIBMTP_PROPERTY_SkipCount, LIBMTP_PROPERTY_LastAccessed,
LIBMTP_PROPERTY_ParentalRating, LIBMTP_PROPERTY_MetaGenre,
LIBMTP_PROPERTY_Composer, LIBMTP_PROPERTY_EffectiveRating,
LIBMTP_PROPERTY_Subtitle, LIBMTP_PROPERTY_OriginalReleaseDate,
LIBMTP_PROPERTY_AlbumName, LIBMTP_PROPERTY_AlbumArtist,
LIBMTP_PROPERTY_Mood, LIBMTP_PROPERTY_DRMStatus,
LIBMTP_PROPERTY_SubDescription, LIBMTP_PROPERTY_IsCropped,
LIBMTP_PROPERTY_IsColorCorrected, LIBMTP_PROPERTY_ImageBitDepth,
LIBMTP_PROPERTY_Fnumber, LIBMTP_PROPERTY_ExposureTime,
LIBMTP_PROPERTY_ExposureIndex, LIBMTP_PROPERTY_DisplayName,
LIBMTP_PROPERTY_BodyText, LIBMTP_PROPERTY_Subject,
LIBMTP_PROPERTY_Priority, LIBMTP_PROPERTY_GivenName,
LIBMTP_PROPERTY_MiddleNames, LIBMTP_PROPERTY_FamilyName,
LIBMTP_PROPERTY_Prefix, LIBMTP_PROPERTY_Suffix,
LIBMTP_PROPERTY_PhoneticGivenName,
LIBMTP_PROPERTY_PhoneticFamilyName, LIBMTP_PROPERTY_EmailPrimary,
LIBMTP_PROPERTY_EmailPersonal1, LIBMTP_PROPERTY_EmailPersonal2,
LIBMTP_PROPERTY_EmailBusiness1, LIBMTP_PROPERTY_EmailBusiness2,
LIBMTP_PROPERTY_EmailOthers, LIBMTP_PROPERTY_PhoneNumberPrimary,
LIBMTP_PROPERTY_PhoneNumberPersonal,
LIBMTP_PROPERTY_PhoneNumberPersonal2,
LIBMTP_PROPERTY_PhoneNumberBusiness,
LIBMTP_PROPERTY_PhoneNumberBusiness2,
LIBMTP_PROPERTY_PhoneNumberMobile,
LIBMTP_PROPERTY_PhoneNumberMobile2,
LIBMTP_PROPERTY_FaxNumberPrimary, LIBMTP_PROPERTY_FaxNumberPersonal,
LIBMTP_PROPERTY_FaxNumberBusiness, LIBMTP_PROPERTY_PagerNumber,
LIBMTP_PROPERTY_PhoneNumberOthers,
LIBMTP_PROPERTY_PrimaryWebAddress,
LIBMTP_PROPERTY_PersonalWebAddress,
LIBMTP_PROPERTY_BusinessWebAddress,
LIBMTP_PROPERTY_InstantMessengerAddress,
LIBMTP_PROPERTY_InstantMessengerAddress2,
LIBMTP_PROPERTY_InstantMessengerAddress3,
LIBMTP_PROPERTY_PostalAddressPersonalFull,
LIBMTP_PROPERTY_PostalAddressPersonalFullLine1,
LIBMTP_PROPERTY_PostalAddressPersonalFullLine2,
LIBMTP_PROPERTY_PostalAddressPersonalFullCity,
LIBMTP_PROPERTY_PostalAddressPersonalFullRegion,
LIBMTP_PROPERTY_PostalAddressPersonalFullPostalCode,
LIBMTP_PROPERTY_PostalAddressPersonalFullCountry,
LIBMTP_PROPERTY_PostalAddressBusinessFull,
LIBMTP_PROPERTY_PostalAddressBusinessLine1,
LIBMTP_PROPERTY_PostalAddressBusinessLine2,
LIBMTP_PROPERTY_PostalAddressBusinessCity,
LIBMTP_PROPERTY_PostalAddressBusinessRegion,
LIBMTP_PROPERTY_PostalAddressBusinessPostalCode,
LIBMTP_PROPERTY_PostalAddressBusinessCountry,
LIBMTP_PROPERTY_PostalAddressOtherFull,
LIBMTP_PROPERTY_PostalAddressOtherLine1,
LIBMTP_PROPERTY_PostalAddressOtherLine2,
LIBMTP_PROPERTY_PostalAddressOtherCity,
LIBMTP_PROPERTY_PostalAddressOtherRegion,
LIBMTP_PROPERTY_PostalAddressOtherPostalCode,
LIBMTP_PROPERTY_PostalAddressOtherCountry,
LIBMTP_PROPERTY_OrganizationName,
LIBMTP_PROPERTY_PhoneticOrganizationName, LIBMTP_PROPERTY_Role,
LIBMTP_PROPERTY_Birthdate, LIBMTP_PROPERTY_MessageTo,
LIBMTP_PROPERTY_MessageCC, LIBMTP_PROPERTY_MessageBCC,
LIBMTP_PROPERTY_MessageRead, LIBMTP_PROPERTY_MessageReceivedTime,
LIBMTP_PROPERTY_MessageSender, LIBMTP_PROPERTY_ActivityBeginTime,
LIBMTP_PROPERTY_ActivityEndTime, LIBMTP_PROPERTY_ActivityLocation,
LIBMTP_PROPERTY_ActivityRequiredAttendees,
LIBMTP_PROPERTY_ActivityOptionalAttendees,
LIBMTP_PROPERTY_ActivityResources, LIBMTP_PROPERTY_ActivityAccepted,
LIBMTP_PROPERTY_Owner, LIBMTP_PROPERTY_Editor,
LIBMTP_PROPERTY_Webmaster, LIBMTP_PROPERTY_URLSource,
LIBMTP_PROPERTY_URLDestination, LIBMTP_PROPERTY_TimeBookmark,
LIBMTP_PROPERTY_ObjectBookmark, LIBMTP_PROPERTY_ByteBookmark,
LIBMTP_PROPERTY_LastBuildDate, LIBMTP_PROPERTY_TimetoLive,
LIBMTP_PROPERTY_MediaGUID, LIBMTP_PROPERTY_TotalBitRate,
LIBMTP_PROPERTY_BitRateType, LIBMTP_PROPERTY_SampleRate,
LIBMTP_PROPERTY_NumberOfChannels, LIBMTP_PROPERTY_AudioBitDepth,
LIBMTP_PROPERTY_ScanDepth, LIBMTP_PROPERTY_AudioWAVECodec,
LIBMTP_PROPERTY_AudioBitRate, LIBMTP_PROPERTY_VideoFourCCCodec,
LIBMTP_PROPERTY_VideoBitRate,
LIBMTP_PROPERTY_FramesPerThousandSeconds,
LIBMTP_PROPERTY_KeyFrameDistance, LIBMTP_PROPERTY_BufferSize,
LIBMTP_PROPERTY_EncodingQuality, LIBMTP_PROPERTY_EncodingProfile,
LIBMTP_PROPERTY_BuyFlag, LIBMTP_PROPERTY_UNKNOWN }
okay so THIS one, bestie, is the absolute mother of all lists π it's the full catalogue of object properties β every "field" an object on your device could possibly carry around with it. it starts off all structural: LIBMTP_PROPERTY_StorageID, LIBMTP_PROPERTY_ObjectFormat, LIBMTP_PROPERTY_ProtectionStatus, LIBMTP_PROPERTY_ObjectSize, LIBMTP_PROPERTY_AssociationType, LIBMTP_PROPERTY_AssociationDesc, LIBMTP_PROPERTY_ObjectFileName, LIBMTP_PROPERTY_DateCreated, LIBMTP_PROPERTY_DateModified, LIBMTP_PROPERTY_Keywords, LIBMTP_PROPERTY_ParentObject, LIBMTP_PROPERTY_AllowedFolderContents, LIBMTP_PROPERTY_Hidden, LIBMTP_PROPERTY_SystemObject, LIBMTP_PROPERTY_PersistantUniqueObjectIdentifier, LIBMTP_PROPERTY_SyncID, LIBMTP_PROPERTY_PropertyBag.
then it goes full music-critic: LIBMTP_PROPERTY_Name, LIBMTP_PROPERTY_CreatedBy, LIBMTP_PROPERTY_Artist, LIBMTP_PROPERTY_DateAuthored, LIBMTP_PROPERTY_Description, LIBMTP_PROPERTY_URLReference, LIBMTP_PROPERTY_LanguageLocale, LIBMTP_PROPERTY_CopyrightInformation, LIBMTP_PROPERTY_Source, LIBMTP_PROPERTY_OriginLocation, LIBMTP_PROPERTY_DateAdded, LIBMTP_PROPERTY_NonConsumable, LIBMTP_PROPERTY_CorruptOrUnplayable, LIBMTP_PROPERTY_ProducerSerialNumber.
and then the representative-sample squad π«Ά: LIBMTP_PROPERTY_RepresentativeSampleFormat, LIBMTP_PROPERTY_RepresentativeSampleSize, LIBMTP_PROPERTY_RepresentativeSampleHeight, LIBMTP_PROPERTY_RepresentativeSampleWidth, LIBMTP_PROPERTY_RepresentativeSampleDuration, LIBMTP_PROPERTY_RepresentativeSampleData β followed by the classic measurements LIBMTP_PROPERTY_Width, LIBMTP_PROPERTY_Height, LIBMTP_PROPERTY_Duration, plus LIBMTP_PROPERTY_Rating, LIBMTP_PROPERTY_Track, LIBMTP_PROPERTY_Genre, LIBMTP_PROPERTY_Credits, LIBMTP_PROPERTY_Lyrics, LIBMTP_PROPERTY_SubscriptionContentID, LIBMTP_PROPERTY_ProducedBy, LIBMTP_PROPERTY_UseCount, LIBMTP_PROPERTY_SkipCount, LIBMTP_PROPERTY_LastAccessed, LIBMTP_PROPERTY_ParentalRating, LIBMTP_PROPERTY_MetaGenre, LIBMTP_PROPERTY_Composer, LIBMTP_PROPERTY_EffectiveRating, LIBMTP_PROPERTY_Subtitle, LIBMTP_PROPERTY_OriginalReleaseDate, LIBMTP_PROPERTY_AlbumName, LIBMTP_PROPERTY_AlbumArtist, LIBMTP_PROPERTY_Mood, LIBMTP_PROPERTY_DRMStatus, LIBMTP_PROPERTY_SubDescription.
photo-girlie corner πΈ: LIBMTP_PROPERTY_IsCropped, LIBMTP_PROPERTY_IsColorCorrected, LIBMTP_PROPERTY_ImageBitDepth, LIBMTP_PROPERTY_Fnumber, LIBMTP_PROPERTY_ExposureTime, LIBMTP_PROPERTY_ExposureIndex.
then it's giving adress-book-core: LIBMTP_PROPERTY_DisplayName, LIBMTP_PROPERTY_BodyText, LIBMTP_PROPERTY_Subject, LIBMTP_PROPERTY_Priority, LIBMTP_PROPERTY_GivenName, LIBMTP_PROPERTY_MiddleNames, LIBMTP_PROPERTY_FamilyName, LIBMTP_PROPERTY_Prefix, LIBMTP_PROPERTY_Suffix, LIBMTP_PROPERTY_PhoneticGivenName, LIBMTP_PROPERTY_PhoneticFamilyName, then ALL the emails LIBMTP_PROPERTY_EmailPrimary, LIBMTP_PROPERTY_EmailPersonal1, LIBMTP_PROPERTY_EmailPersonal2, LIBMTP_PROPERTY_EmailBusiness1, LIBMTP_PROPERTY_EmailBusiness2, LIBMTP_PROPERTY_EmailOthers, then the entire phone roster LIBMTP_PROPERTY_PhoneNumberPrimary, LIBMTP_PROPERTY_PhoneNumberPersonal, LIBMTP_PROPERTY_PhoneNumberPersonal2, LIBMTP_PROPERTY_PhoneNumberBusiness, LIBMTP_PROPERTY_PhoneNumberBusiness2, LIBMTP_PROPERTY_PhoneNumberMobile, LIBMTP_PROPERTY_PhoneNumberMobile2, then fax LIBMTP_PROPERTY_FaxNumberPrimary, LIBMTP_PROPERTY_FaxNumberPersonal, LIBMTP_PROPERTY_FaxNumberBusiness, LIBMTP_PROPERTY_PagerNumber, LIBMTP_PROPERTY_PhoneNumberOthers, then web links LIBMTP_PROPERTY_PrimaryWebAddress, LIBMTP_PROPERTY_PersonalWebAddress, LIBMTP_PROPERTY_BusinessWebAddress, then the IMs LIBMTP_PROPERTY_InstantMessengerAddress, LIBMTP_PROPERTY_InstantMessengerAddress2, LIBMTP_PROPERTY_InstantMessengerAddress3.
and because the contacts section wasn't done terrorising us yet, there's a FULL postal-address trilogy π<br>personal: LIBMTP_PROPERTY_PostalAddressPersonalFull, LIBMTP_PROPERTY_PostalAddressPersonalFullLine1, LIBMTP_PROPERTY_PostalAddressPersonalFullLine2, LIBMTP_PROPERTY_PostalAddressPersonalFullCity, LIBMTP_PROPERTY_PostalAddressPersonalFullRegion, LIBMTP_PROPERTY_PostalAddressPersonalFullPostalCode, LIBMTP_PROPERTY_PostalAddressPersonalFullCountry.<br>business: LIBMTP_PROPERTY_PostalAddressBusinessFull, LIBMTP_PROPERTY_PostalAddressBusinessLine1, LIBMTP_PROPERTY_PostalAddressBusinessLine2, LIBMTP_PROPERTY_PostalAddressBusinessCity, LIBMTP_PROPERTY_PostalAddressBusinessRegion, LIBMTP_PROPERTY_PostalAddressBusinessPostalCode, LIBMTP_PROPERTY_PostalAddressBusinessCountry.<br>other: LIBMTP_PROPERTY_PostalAddressOtherFull, LIBMTP_PROPERTY_PostalAddressOtherLine1, LIBMTP_PROPERTY_PostalAddressOtherLine2, LIBMTP_PROPERTY_PostalAddressOtherCity, LIBMTP_PROPERTY_PostalAddressOtherRegion, LIBMTP_PROPERTY_PostalAddressOtherPostalCode, LIBMTP_PROPERTY_PostalAddressOtherCountry.
then LIBMTP_PROPERTY_OrganizationName, LIBMTP_PROPERTY_PhoneticOrganizationName, LIBMTP_PROPERTY_Role, LIBMTP_PROPERTY_Birthdate, then message stuff LIBMTP_PROPERTY_MessageTo, LIBMTP_PROPERTY_MessageCC, LIBMTP_PROPERTY_MessageBCC, LIBMTP_PROPERTY_MessageRead, LIBMTP_PROPERTY_MessageReceivedTime, LIBMTP_PROPERTY_MessageSender, then activity stuff LIBMTP_PROPERTY_ActivityBeginTime, LIBMTP_PROPERTY_ActivityEndTime, LIBMTP_PROPERTY_ActivityLocation, LIBMTP_PROPERTY_ActivityRequiredAttendees, LIBMTP_PROPERTY_ActivityOptionalAttendees, LIBMTP_PROPERTY_ActivityResources, LIBMTP_PROPERTY_ActivityAccepted.
and it just keeps going fr: LIBMTP_PROPERTY_Owner, LIBMTP_PROPERTY_Editor, LIBMTP_PROPERTY_Webmaster, LIBMTP_PROPERTY_URLSource, LIBMTP_PROPERTY_URLDestination, LIBMTP_PROPERTY_TimeBookmark, LIBMTP_PROPERTY_ObjectBookmark, LIBMTP_PROPERTY_ByteBookmark, LIBMTP_PROPERTY_LastBuildDate, LIBMTP_PROPERTY_TimetoLive, LIBMTP_PROPERTY_MediaGUID, then the bitrate/audio-nerd block LIBMTP_PROPERTY_TotalBitRate, LIBMTP_PROPERTY_BitRateType, LIBMTP_PROPERTY_SampleRate, LIBMTP_PROPERTY_NumberOfChannels, LIBMTP_PROPERTY_AudioBitDepth, LIBMTP_PROPERTY_ScanDepth, LIBMTP_PROPERTY_AudioWAVECodec, LIBMTP_PROPERTY_AudioBitRate, LIBMTP_PROPERTY_VideoFourCCCodec, LIBMTP_PROPERTY_VideoBitRate, LIBMTP_PROPERTY_FramesPerThousandSeconds, LIBMTP_PROPERTY_KeyFrameDistance, LIBMTP_PROPERTY_BufferSize, LIBMTP_PROPERTY_EncodingQuality, LIBMTP_PROPERTY_EncodingProfile, LIBMTP_PROPERTY_BuyFlag.
and she closes the set, as always, with LIBMTP_PROPERTY_UNKNOWN. periodt π
πΈ enum LIBMTP_datatype_t
enum LIBMTP_datatype_t { LIBMTP_DATATYPE_INT8, LIBMTP_DATATYPE_UINT8,
LIBMTP_DATATYPE_INT16, LIBMTP_DATATYPE_UINT16,
LIBMTP_DATATYPE_INT32, LIBMTP_DATATYPE_UINT32,
LIBMTP_DATATYPE_INT64, LIBMTP_DATATYPE_UINT64 }
the little family of data types, from smallest to biggest, tiny baby to big tall: LIBMTP_DATATYPE_INT8, LIBMTP_DATATYPE_UINT8, LIBMTP_DATATYPE_INT16, LIBMTP_DATATYPE_UINT16, LIBMTP_DATATYPE_INT32, LIBMTP_DATATYPE_UINT32, LIBMTP_DATATYPE_INT64, LIBMTP_DATATYPE_UINT64. yes the U ones are unsigned, yes that means no negatives, no we're not elaborating π
π enum LIBMTP_devicecap_t
enum LIBMTP_devicecap_t { LIBMTP_DEVICECAP_GetPartialObject,
LIBMTP_DEVICECAP_SendPartialObject, LIBMTP_DEVICECAP_EditObjects,
LIBMTP_DEVICECAP_MoveObject, LIBMTP_DEVICECAP_CopyObject }
this is the "what can this device actually do though" checklist, aka the capability flags: LIBMTP_DEVICECAP_GetPartialObject, LIBMTP_DEVICECAP_SendPartialObject, LIBMTP_DEVICECAP_EditObjects, LIBMTP_DEVICECAP_MoveObject, LIBMTP_DEVICECAP_CopyObject. five ways to be a capable king π
π enum LIBMTP_error_number_t
enum LIBMTP_error_number_t { LIBMTP_ERROR_NONE, LIBMTP_ERROR_GENERAL,
LIBMTP_ERROR_PTP_LAYER, LIBMTP_ERROR_USB_LAYER,
LIBMTP_ERROR_MEMORY_ALLOCATION, LIBMTP_ERROR_NO_DEVICE_ATTACHED,
LIBMTP_ERROR_STORAGE_FULL, LIBMTP_ERROR_CONNECTING,
LIBMTP_ERROR_CANCELLED }
the error girls π every possible flavour of "something went wrong bestie": LIBMTP_ERROR_NONE (the good one, the slay one, nothing is wrong), LIBMTP_ERROR_GENERAL (vague, mysterious, no notes), LIBMTP_ERROR_PTP_LAYER, LIBMTP_ERROR_USB_LAYER, LIBMTP_ERROR_MEMORY_ALLOCATION, LIBMTP_ERROR_NO_DEVICE_ATTACHED (plug it in π), LIBMTP_ERROR_STORAGE_FULL, LIBMTP_ERROR_CONNECTING, LIBMTP_ERROR_CANCELLED.
β¨ enum LIBMTP_event_enum
enum LIBMTP_event_enum { LIBMTP_EVENT_NONE, LIBMTP_EVENT_STORE_ADDED,
LIBMTP_EVENT_STORE_REMOVED, LIBMTP_EVENT_OBJECT_ADDED,
LIBMTP_EVENT_OBJECT_REMOVED, LIBMTP_EVENT_DEVICE_PROPERTY_CHANGED }
the "drama is happening live" list, for when the device is out here doing things and you want to know: LIBMTP_EVENT_NONE (quiet, peaceful, no chaos rn), LIBMTP_EVENT_STORE_ADDED, LIBMTP_EVENT_STORE_REMOVED, LIBMTP_EVENT_OBJECT_ADDED, LIBMTP_EVENT_OBJECT_REMOVED, LIBMTP_EVENT_DEVICE_PROPERTY_CHANGED. main character energy fr fr π
π«Ά Functions π«Ά
okay bestie, here's the full roster of functions this library hands you, in the exact order the manpage lists them, every signature copied character-for-character (yes, all the consts, yes, even the ones that look like they're just there to vibe). Signatures stay in backticks. My commentary is not the API. Let's go π¦
void LIBMTP_Set_Debug (int)β one lonelyintwalks in, nothing comes back out. The debug dial-turner. πΈvoid LIBMTP_Init (void)β takesvoid, returnsvoid. Literally cannot do less. Iconic minimalism. πint LIBMTP_Get_Supported_Devices_List (LIBMTP_device_entry_t **const, int *const)β two pointer params (aLIBMTP_device_entry_t **constand anint *const),intback. πLIBMTP_error_number_t LIBMTP_Detect_Raw_Devices (LIBMTP_raw_device_t **, int *)βLIBMTP_raw_device_t **and anint *in,LIBMTP_error_number_tout. The raw-device detector πint LIBMTP_Check_Specific_Device (int busno, int devno)β the rare β¨gorgeousβ¨ function whose params actually have names:busnoanddevno, bothint,intback. π
LIBMTP_mtpdevice_t * LIBMTP_Open_Raw_Device (LIBMTP_raw_device_t *)β raw device goes in,LIBMTP_mtpdevice_t *comes out.LIBMTP_mtpdevice_t * LIBMTP_Open_Raw_Device_Uncached (LIBMTP_raw_device_t *)β same shape as its sibling up there, but the name is wearing the Uncached badge. π§LIBMTP_mtpdevice_t * LIBMTP_Get_Device (int)β oneint, one device pointer. no notes.LIBMTP_mtpdevice_t * LIBMTP_Get_First_Device (void)β nothing in, device pointer out. The "first" one. π₯LIBMTP_mtpdevice_t * LIBMTP_Get_Device_By_SerialNumber (char *)β achar *goes in (it's a serial number, per the name), device pointer out. π’LIBMTP_mtpdevice_t * LIBMTP_Get_Device_By_ID (char *)β same deal but thechar *is an ID this time. πLIBMTP_error_number_t LIBMTP_Get_Connected_Devices (LIBMTP_mtpdevice_t **)β oneLIBMTP_mtpdevice_t **param,LIBMTP_error_number_tback. πuint32_t LIBMTP_Number_Devices_In_List (LIBMTP_mtpdevice_t *)β takes a device-list pointer, hands you auint32_t. It counts. That's the whole bit. π’void LIBMTP_Release_Device_List (LIBMTP_mtpdevice_t *)β in goes the list pointer, out goesβ¦ nothing.void. bye bestie π«‘void LIBMTP_Release_Device (LIBMTP_mtpdevice_t *)β the solo version of the above. Stillvoid. Still goodbye. πvoid LIBMTP_Dump_Device_Info (LIBMTP_mtpdevice_t *)β device pointer in,voidout. It dumps info. The name tells you everything and I respect that. ποΈint LIBMTP_Reset_Device (LIBMTP_mtpdevice_t *)βintback. Reset button energy. πchar * LIBMTP_Get_Manufacturername (LIBMTP_mtpdevice_t *)β device in,char *out. Thenameof the manufacturer. Spelling is exactly as the manpage has it, do not @ me. πchar * LIBMTP_Get_Modelname (LIBMTP_mtpdevice_t *)βchar *out again. Model name. π±char * LIBMTP_Get_Serialnumber (LIBMTP_mtpdevice_t *)β yes anotherchar *, this one's the serial number. πchar * LIBMTP_Get_Deviceversion (LIBMTP_mtpdevice_t *)βchar *, device version. βοΈchar * LIBMTP_Get_Friendlyname (LIBMTP_mtpdevice_t *)βchar *, and this one is the friendly name. Precious. π₯°int LIBMTP_Set_Friendlyname (LIBMTP_mtpdevice_t *, char const *const)β device pointer plus achar const *const,intback. The setter to its getter, they're a matched set. πchar * LIBMTP_Get_Syncpartner (LIBMTP_mtpdevice_t *)βchar *back, sync partner. π€int LIBMTP_Set_Syncpartner (LIBMTP_mtpdevice_t *, char const *const)βintback,char const *constin. Same silhouette, different verb. β¨int LIBMTP_Get_Batterylevel (LIBMTP_mtpdevice_t *, uint8_t *const, uint8_t *const)β device pointer plus twouint8_t *consts,intback. Battery levels πint LIBMTP_Get_Secure_Time (LIBMTP_mtpdevice_t *, char **const)βchar **constin,intout. π°οΈint LIBMTP_Get_Device_Certificate (LIBMTP_mtpdevice_t *, char **const)βchar **constin,intout. Certificate π«int LIBMTP_Get_Supported_Filetypes (LIBMTP_mtpdevice_t *, uint16_t **const, uint16_t *const)β auint16_t **constand auint16_t *constin,intback. ποΈint LIBMTP_Check_Capability (LIBMTP_mtpdevice_t *, LIBMTP_devicecap_t)β device pointer and anLIBMTP_devicecap_t,intback. π§
LIBMTP_error_t * LIBMTP_Get_Errorstack (LIBMTP_mtpdevice_t *)β device in,LIBMTP_error_t *out. The error stack πvoid LIBMTP_Clear_Errorstack (LIBMTP_mtpdevice_t *)βvoid. Poof. gone. π§Ήvoid LIBMTP_Dump_Errorstack (LIBMTP_mtpdevice_t *)β alsovoid, but the dumping flavour. ποΈvoid LIBMTP_FreeMemory (void *)β literally just avoid *and avoid. Free your memory, bestie, both kinds. π§int LIBMTP_Get_Storage (LIBMTP_mtpdevice_t *, int const)β device pointer plus anint const,intback. πΎint LIBMTP_Format_Storage (LIBMTP_mtpdevice_t *, LIBMTP_devicestorage_t *)β device pointer plus aLIBMTP_devicestorage_t *,intback. β οΈ it's format β the name said it, not me.char * LIBMTP_Get_String_From_Object (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const)β device pointer,uint32_t const,LIBMTP_property_t constin;char *out. π§΅uint64_t LIBMTP_Get_u64_From_Object (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint64_t const)β same front half, plus auint64_t const, and auint64_tcomes back. 6οΈβ£4οΈβ£uint32_t LIBMTP_Get_u32_From_Object (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint32_t const)β you see the pattern, right?uint32_tin,uint32_tout. πuint16_t LIBMTP_Get_u16_From_Object (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint16_t const)βuint16_tflavour. Same shape. β¨uint8_t LIBMTP_Get_u8_From_Object (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint8_t const)β the smallest one,uint8_tin and out. lil guy πint LIBMTP_Set_Object_String (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, char const *const)β four params,intback. The setter twin. πint LIBMTP_Set_Object_u32 (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint32_t const)β device pointer,uint32_t const,LIBMTP_property_t const,uint32_t const;intback. π’int LIBMTP_Set_Object_u16 (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint16_t const)β same butuint16_t. π’int LIBMTP_Set_Object_u8 (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint8_t const)β and theuint8_tone, stillintback. π’char const * LIBMTP_Get_Property_Description (LIBMTP_property_t inproperty)β one param, adorably namedinproperty, and achar const *comes back. π·οΈint LIBMTP_Is_Property_Supported (LIBMTP_mtpdevice_t *, LIBMTP_property_t const, LIBMTP_filetype_t const)β device pointer, anLIBMTP_property_t const, anLIBMTP_filetype_t const;intback. βint LIBMTP_Get_Allowed_Property_Values (LIBMTP_mtpdevice_t *, LIBMTP_property_t const, LIBMTP_filetype_t const, LIBMTP_allowed_values_t *)β four params ending inLIBMTP_allowed_values_t *,intback. π―void LIBMTP_destroy_allowed_values_t (LIBMTP_allowed_values_t *)βvoid, lowercased, exactly as written. Cleanup crew π§Ό
LIBMTP_file_t * LIBMTP_new_file_t (void)β nothing in,LIBMTP_file_t *out. Thenew-and-destroypattern starts here, lowercase and all. π£void LIBMTP_destroy_file_t (LIBMTP_file_t *)βvoid,LIBMTP_file_t *in.char const * LIBMTP_Get_Filetype_Description (LIBMTP_filetype_t)βLIBMTP_filetype_tin,char const *out. πLIBMTP_file_t * LIBMTP_Get_Filelisting (LIBMTP_mtpdevice_t *)β device in,LIBMTP_file_t *out. πLIBMTP_file_t * LIBMTP_Get_Filelisting_With_Callback (LIBMTP_mtpdevice_t *, LIBMTP_progressfunc_t const, void const *const)β plus aLIBMTP_progressfunc_t constand avoid const *const. ποΈLIBMTP_file_t * LIBMTP_Get_Files_And_Folders (LIBMTP_mtpdevice_t *, uint32_t const, uint32_t const)β device pointer and twouint32_t consts,LIBMTP_file_t *back. πint LIBMTP_Get_Children (LIBMTP_mtpdevice_t *, uint32_t const, uint32_t const, uint32_t **)β device pointer, twouint32_t consts, auint32_t **;intback. πΆLIBMTP_file_t * LIBMTP_Get_Filemetadata (LIBMTP_mtpdevice_t *, uint32_t const)β device pointer and auint32_t const,LIBMTP_file_t *out. πint LIBMTP_Get_File_To_File (LIBMTP_mtpdevice_t *, uint32_t, char const *const, LIBMTP_progressfunc_t const, void const *const)β five params,intback. Note thisuint32_thas noconst, and neither does the one in_Descriptorbelow, and yes that's on purpose, the manpage said so. πint LIBMTP_Get_File_To_File_Descriptor (LIBMTP_mtpdevice_t *, uint32_t const, int const, LIBMTP_progressfunc_t const, void const *const)β here theuint32_tdoes haveconst, plus anint const.intback. π§Ύint LIBMTP_Get_File_To_Handler (LIBMTP_mtpdevice_t *, uint32_t const, MTPDataPutFunc, void *, LIBMTP_progressfunc_t const, void const *const)β includes anMTPDataPutFuncand avoid *.intback. πͺint LIBMTP_Send_File_From_File (LIBMTP_mtpdevice_t *, char const *const, LIBMTP_file_t *const, LIBMTP_progressfunc_t const, void const *const)βchar const *constplusLIBMTP_file_t *constplus the usual progress duo.intback. π€int LIBMTP_Send_File_From_File_Descriptor (LIBMTP_mtpdevice_t *, int const, LIBMTP_file_t *const, LIBMTP_progressfunc_t const, void const *const)β anint constfile descriptor in that second slot.intback. π§Ύint LIBMTP_Send_File_From_Handler (LIBMTP_mtpdevice_t *, MTPDataGetFunc, void *, LIBMTP_file_t *const, LIBMTP_progressfunc_t const, void const *const)βMTPDataGetFuncthis time (Get, not Put, they are different), plusvoid *andLIBMTP_file_t *const.intback. πͺint LIBMTP_Set_File_Name (LIBMTP_mtpdevice_t *, LIBMTP_file_t *, const char *)β note this one writesconst char *the other way round from the setters above. Do not "fix" it, it's canon. πLIBMTP_filesampledata_t * LIBMTP_new_filesampledata_t (void)βvoidin,LIBMTP_filesampledata_t *out. π£void LIBMTP_destroy_filesampledata_t (LIBMTP_filesampledata_t *)βvoidout. π§Όint LIBMTP_Get_Representative_Sample_Format (LIBMTP_mtpdevice_t *, LIBMTP_filetype_t const, LIBMTP_filesampledata_t **)β device pointer,LIBMTP_filetype_t const,LIBMTP_filesampledata_t **;intback. πΌοΈint LIBMTP_Send_Representative_Sample (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_filesampledata_t *)β device pointer,uint32_t const,LIBMTP_filesampledata_t *;intback. βοΈint LIBMTP_Get_Representative_Sample (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_filesampledata_t *)β same shape, opposite direction. πint LIBMTP_Get_Thumbnail (LIBMTP_mtpdevice_t *, uint32_t const, unsigned char **data, unsigned int *size)β named params!!dataandsize, and they'reunsigned.intback. πΌοΈ
LIBMTP_track_t * LIBMTP_new_track_t (void)βvoidin,LIBMTP_track_t *out. π΅void LIBMTP_destroy_track_t (LIBMTP_track_t *)βvoidout. π§ΌLIBMTP_track_t * LIBMTP_Get_Tracklisting (LIBMTP_mtpdevice_t *)β device in, track pointer out. πLIBMTP_track_t * LIBMTP_Get_Tracklisting_With_Callback (LIBMTP_mtpdevice_t *, LIBMTP_progressfunc_t const, void const *const)β the callback edition. ποΈLIBMTP_track_t * LIBMTP_Get_Tracklisting_With_Callback_For_Storage (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_progressfunc_t const, void const *const)β the longest name in the lineup and honestly it earned it: plusuint32_t const. πLIBMTP_track_t * LIBMTP_Get_Trackmetadata (LIBMTP_mtpdevice_t *, uint32_t const)β device pointer plusuint32_t const. πint LIBMTP_Get_Track_To_File (LIBMTP_mtpdevice_t *, uint32_t, char const *const, LIBMTP_progressfunc_t const, void const *const)β bareuint32_tagain, just like the file one.intback. π§int LIBMTP_Get_Track_To_File_Descriptor (LIBMTP_mtpdevice_t *, uint32_t const, int const, LIBMTP_progressfunc_t const, void const *const)βuint32_t const,int const,intback. π§Ύint LIBMTP_Get_Track_To_Handler (LIBMTP_mtpdevice_t *, uint32_t const, MTPDataPutFunc, void *, LIBMTP_progressfunc_t const, void const *const)βMTPDataPutFuncplusvoid *.intback. πͺint LIBMTP_Send_Track_From_File (LIBMTP_mtpdevice_t *, char const *const, LIBMTP_track_t *const, LIBMTP_progressfunc_t const, void const *const)βintback. π€int LIBMTP_Send_Track_From_File_Descriptor (LIBMTP_mtpdevice_t *, int const, LIBMTP_track_t *const, LIBMTP_progressfunc_t const, void const *const)βint constdescriptor,LIBMTP_track_t *const. π€int LIBMTP_Send_Track_From_Handler (LIBMTP_mtpdevice_t *, MTPDataGetFunc, void *, LIBMTP_track_t *const, LIBMTP_progressfunc_t const, void const *const)βMTPDataGetFunc+void *+LIBMTP_track_t *const. π€int LIBMTP_Update_Track_Metadata (LIBMTP_mtpdevice_t *, LIBMTP_track_t const *const)βLIBMTP_track_t const *const, note theconston both sides.intback. πint LIBMTP_Track_Exists (LIBMTP_mtpdevice_t *, uint32_t const)βintback, and the name is a yes/no question. πint LIBMTP_Set_Track_Name (LIBMTP_mtpdevice_t *, LIBMTP_track_t *, const char *)βconst char *, written that way round.intback. π
LIBMTP_folder_t * LIBMTP_new_folder_t (void)βvoidin,LIBMTP_folder_t *out. π£void LIBMTP_destroy_folder_t (LIBMTP_folder_t *)βvoidout. π§ΌLIBMTP_folder_t * LIBMTP_Get_Folder_List (LIBMTP_mtpdevice_t *)β device in, folder pointer out. πLIBMTP_folder_t * LIBMTP_Get_Folder_List_For_Storage (LIBMTP_mtpdevice_t *, uint32_t const)β plusuint32_t const. πΎLIBMTP_folder_t * LIBMTP_Find_Folder (LIBMTP_folder_t *, uint32_t const)β takes a folder pointer and auint32_t const, hands back anLIBMTP_folder_t *. Finder energy, noGetin the name, we love a rebel. πuint32_t LIBMTP_Create_Folder (LIBMTP_mtpdevice_t *, char *, uint32_t, uint32_t)β note: plainchar *(noconst!) and two bareuint32_ts, and it hands you auint32_t. β¨int LIBMTP_Set_Folder_Name (LIBMTP_mtpdevice_t *, LIBMTP_folder_t *, const char *)βconst char *, same style as its file and track cousins.intback. πLIBMTP_playlist_t * LIBMTP_new_playlist_t (void)βvoidin,LIBMTP_playlist_t *out. π£void LIBMTP_destroy_playlist_t (LIBMTP_playlist_t *)βvoidout. π§ΌLIBMTP_playlist_t * LIBMTP_Get_Playlist_List (LIBMTP_mtpdevice_t *)β device in, playlist pointer out. πΆLIBMTP_playlist_t * LIBMTP_Get_Playlist (LIBMTP_mtpdevice_t *, uint32_t const)β singular this time. β¨int LIBMTP_Create_New_Playlist (LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *const)β both words in the name, iconic.intback. βint LIBMTP_Update_Playlist (LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *const)βLIBMTP_playlist_t *const,intback. πint LIBMTP_Set_Playlist_Name (LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *, const char *)βconst char *.intback. πLIBMTP_album_t * LIBMTP_new_album_t (void)βvoidin,LIBMTP_album_t *out. π£void LIBMTP_destroy_album_t (LIBMTP_album_t *)βvoidout. π§ΌLIBMTP_album_t * LIBMTP_Get_Album_List (LIBMTP_mtpdevice_t *)β device in, album pointer out. πΏLIBMTP_album_t * LIBMTP_Get_Album_List_For_Storage (LIBMTP_mtpdevice_t *, uint32_t const)β plusuint32_t const. πΎLIBMTP_album_t * LIBMTP_Get_Album (LIBMTP_mtpdevice_t *, uint32_t const)β the singular one. πint LIBMTP_Create_New_Album (LIBMTP_mtpdevice_t *, LIBMTP_album_t *const)βintback. βint LIBMTP_Update_Album (LIBMTP_mtpdevice_t *, LIBMTP_album_t const *const)β careful here:LIBMTP_album_t const *const, which is not howLIBMTP_Update_Playlistwrote it. Different functions, different signatures, that's the whole lesson.intback. πint LIBMTP_Set_Album_Name (LIBMTP_mtpdevice_t *, LIBMTP_album_t *, const char *)βconst char *.intback. π
int LIBMTP_Delete_Object (LIBMTP_mtpdevice_t *, uint32_t)β device pointer plus a bareuint32_t,intback. ποΈint LIBMTP_Move_Object (LIBMTP_mtpdevice_t *, uint32_t, uint32_t, uint32_t)β three bareuint32_ts and anint. π¦int LIBMTP_Copy_Object (LIBMTP_mtpdevice_t *, uint32_t, uint32_t, uint32_t)β identical silhouette, different verb. πint LIBMTP_Set_Object_Filename (LIBMTP_mtpdevice_t *, uint32_t, char *)β a plainchar *, noconstin sight.intback. π·οΈint LIBMTP_GetPartialObject (LIBMTP_mtpdevice_t *, uint32_t const, uint64_t, uint32_t, unsigned char **, unsigned int *)β six params, including anunsigned char **and anunsigned int *.intback. π°int LIBMTP_SendPartialObject (LIBMTP_mtpdevice_t *, uint32_t const, uint64_t, unsigned char *, unsigned int)β note: singleunsigned char *and a plainunsigned int, not double pointers like the Get.intback. π°int LIBMTP_BeginEditObject (LIBMTP_mtpdevice_t *, uint32_t const)βintback. βοΈint LIBMTP_EndEditObject (LIBMTP_mtpdevice_t *, uint32_t const)β the other half of that pair.intback. βοΈint LIBMTP_TruncateObject (LIBMTP_mtpdevice_t *, uint32_t const, uint64_t)β device pointer,uint32_t const,uint64_t.intback. βοΈ
int LIBMTP_Read_Event (LIBMTP_mtpdevice_t *, LIBMTP_event_t *, uint32_t *)β anLIBMTP_event_t *and auint32_t *in,intback. π¬int LIBMTP_Read_Event_Async (LIBMTP_mtpdevice_t *, LIBMTP_event_cb_fn, void *)β takes anLIBMTP_event_cb_fnand avoid *, nouint32_t *here.intback. β‘int LIBMTP_Handle_Events_Timeout_Completed (struct timeval *, int *)β no device pointer at all!! Juststruct timeval *andint *, and anintcomes back. Main character behaviour. πint LIBMTP_Custom_Operation (LIBMTP_mtpdevice_t *, uint16_t, int,...)β variadic!uint16_t, anint, then...and whatever you feel like passing,intback. Format it exactly like that, comma and all. π
π Variables π
int LIBMTP_debugβ one loneint, sitting out here on its own like it owns the place. It does. β
β¨ DETAILED DESCRIPTION β¨
Okay bestie, deep breath, because this is the whole vibe of the page: this header is the interface to the Media Transfer Protocol library. That's it, that's the thesis. π
π«Ά COPYRIGHT π«Ά
Like, legally we gotta say it, so here it is, every single name and address, no skipping:
Copyright (C) 2005-2013 Linus Walleij <triad@df.lth.se> Copyright (C) 2005-2008 Richard A. Low <richard@wentnet.com> Copyright (C) 2007 Ted Bullock <tbullock@canada.com> Copyright (C) 2008 Florent Mertens <flomertens@gmail.com>
π LICENSE (the legal slay) π
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
ngl bestie, "WITHOUT ANY WARRANTY" is not a suggestion, it's giving capital letters for a reason. It means it. π
And here's how you actually pull the whole thing in:
#include <libmtp.h>
π VARIABLE DOCUMENTATION π
β int LIBMTP_debug [extern] β
Global debug level, bestie!! π¦ This is the big one. We use a flag system to enable a part of logs β not all of them, a part, so you get to pick and choose which little logs you wanna see. Main character energy, honestly.
πΈ How the debug level gets set
The LIBMTP_DEBUG environment variable sets the debug flags for any binary that uses libmtp and calls LIBMTP_Init. So like, if the program calls LIBMTP_Init, your env var is heard. π«Ά
The value can be given in:
- decimal β but it must not start with
"0"or it will be interpreted in octal. Not me getting jumpscared by octal again π - hexadecimal β must start with
0x
And the special one, the π icon:
- The value
"-1"enables all debug flags. Everything. All of it. The whole feed. Be ready.
π§ The -d flag in examples/
Some of the utilities in examples/ also take a command-line flag "-d" that enables LIBMTP_DEBUG_PTP and LIBMTP_DEBUG_DATA β same as setting LIBMTP_DEBUG=9. Slay, one keystroke for two vibes. β¨
π The flags (combine by adding the hex values)
0x00 [0000 0000]:LIBMTP_DEBUG_NONE: no debug (default)0x01 [0000 0001]:LIBMTP_DEBUG_PTP: PTP debug0x02 [0000 0010]:LIBMTP_DEBUG_PLST: Playlist debug0x04 [0000 0100]:LIBMTP_DEBUG_USB: USB debug0x08 [0000 1000]:LIBMTP_DEBUG_DATA: USB data debug
(Please keep this list in sync with libmtp.h.) β literally a note to the maintainers, but now you know too, and knowing is half the battle π
Referenced by LIBMTP_Set_Debug().
π AUTHOR π
Generated automatically by Doxygen for libmtp from the source code. So technically the robot wrote this page, and technically I just made it cute. We contain multitudes. π¦
and that's the whole page, bestie!! π this was libmtp, Version 1.1.23, page libmtp.h(3) β read it, love it, set your LIBMTP_DEBUG responsibly, and go transfer some media. periodt. π
β¨π
π¦ where this page comes from
- ubuntu stonking: libmtp-doc 1.1.23-1 Β· LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms