libmtp.h(3)

๐Ÿ“ฆ version 1.1.23, in arch rolling

okay so this is libmtp.h(3) โ€” the Library Functions Manual โ€” and itโ€™s giving โ€œheader file main character energy,โ€ bestie. buckle up, because this is part one of the lore and we are not skipping a single line. ๐Ÿ’…โœจ

โœจ NAME โœจ

libmtp.h โ€” thatโ€™s the name, no cap. itโ€™s the header itself, and it said โ€œIโ€™ll be the whole vibe.โ€ periodt.


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

okay so before the structs and defines start pulling up, hereโ€™s the include starter pack. copy these exactly, bestie โ€” character for character, fr fr:

#include <sys/time.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>

๐Ÿ’– Data Structures ๐Ÿ’–

these are the structs, in order, and yes every single one is invited to the group chat:

  • struct LIBMTP_device_entry_struct
  • struct LIBMTP_raw_device_struct
  • struct LIBMTP_error_struct
  • struct LIBMTP_allowed_values_struct
  • struct LIBMTP_device_extension_struct
  • struct LIBMTP_mtpdevice_struct
  • struct LIBMTP_file_struct
  • struct LIBMTP_track_struct
  • struct LIBMTP_playlist_struct
  • struct LIBMTP_album_struct
  • struct LIBMTP_folder_struct
  • struct LIBMTP_filesampledata_struct
  • struct LIBMTP_devicestorage_struct

๐ŸŽ€ Macros ๐ŸŽ€

the #define section! every macro is here, exactly as written. no edits, no โ€œfixing,โ€ no nothing โ€” just iconic constants doing their thing:

#define LIBMTP_VERSION   1.1.23
#define LIBMTP_VERSION_STRING   '1.1.23'
#define LIBMTP_DEBUG_NONE   0x00
#define LIBMTP_DEBUG_PTP   0x01
#define LIBMTP_DEBUG_PLST   0x02
#define LIBMTP_DEBUG_USB   0x04
#define LIBMTP_DEBUG_DATA   0x08
#define LIBMTP_DEBUG_ALL   0xFF
#define LIBMTP_FILETYPE_IS_AUDIO(a)
#define LIBMTP_FILETYPE_IS_VIDEO(a)
#define LIBMTP_FILETYPE_IS_AUDIOVIDEO(a)
#define LIBMTP_FILETYPE_IS_TRACK(a)
#define LIBMTP_FILETYPE_IS_IMAGE(a)
#define LIBMTP_FILETYPE_IS_ADDRESSBOOK(a)
#define LIBMTP_FILETYPE_IS_CALENDAR(a)
#define LIBMTP_HANDLER_RETURN_OK   0
#define LIBMTP_HANDLER_RETURN_ERROR   1
#define LIBMTP_HANDLER_RETURN_CANCEL   2
#define LIBMTP_STORAGE_SORTBY_NOTSORTED   0
#define LIBMTP_STORAGE_SORTBY_FREESPACE   1
#define LIBMTP_STORAGE_SORTBY_MAXSPACE   2
#define LIBMTP_FILES_AND_FOLDERS_ROOT   0xffffffff

๐ŸŒˆ Typedefs ๐ŸŒˆ

typedef time, bestie. every alias and function-pointer situation is right here, exactly as written โ€” lowkey a little iconic, highkey very important:

  • typedef struct LIBMTP_device_entry_struct LIBMTP_device_entry_t
  • typedef struct LIBMTP_raw_device_struct LIBMTP_raw_device_t
  • typedef struct LIBMTP_error_struct LIBMTP_error_t
  • typedef struct LIBMTP_allowed_values_struct LIBMTP_allowed_values_t
  • typedef struct LIBMTP_device_extension_struct LIBMTP_device_extension_t
  • typedef struct LIBMTP_mtpdevice_struct LIBMTP_mtpdevice_t
  • typedef struct LIBMTP_file_struct LIBMTP_file_t
  • typedef struct LIBMTP_track_struct LIBMTP_track_t
  • typedef struct LIBMTP_playlist_struct LIBMTP_playlist_t
  • typedef struct LIBMTP_album_struct LIBMTP_album_t
  • typedef struct LIBMTP_folder_struct LIBMTP_folder_t
  • typedef struct LIBMTP_filesampledata_struct LIBMTP_filesampledata_t
  • typedef struct LIBMTP_devicestorage_struct LIBMTP_devicestorage_t
  • typedef int(* LIBMTP_progressfunc_t) (uint64_t const sent, uint64_t const total, void const *const data)
  • typedef uint16_t(* MTPDataGetFunc) (void *params, void *priv, uint32_t wantlen, unsigned char *data, uint32_t *gotlen)
  • typedef uint16_t(* MTPDataPutFunc) (void *params, void *priv, uint32_t sendlen, unsigned char *data, uint32_t *putlen)
  • typedef enum LIBMTP_event_enum LIBMTP_event_t
  • typedef void(* LIBMTP_event_cb_fn) (int, LIBMTP_event_t, uint32_t, void *)

โœจ Enumerations โœจ

okay bestie, this is the enum section and it is long โ€” but honestly? iconic. these are the named constant sets from libmtp.h, and every single identifier is right here. no cap, no skipping, no โ€œyou get the idea.โ€ ๐Ÿ’…


๐ŸŽ€ LIBMTP_filetype_t ๐ŸŽ€

this is the filetype roster. the whole roster. every value is in the block, exactly as it should be. ๐Ÿฆ‹

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 }

thatโ€™s the whole filetype lineup โ€” folder to playlist to unknown, all accounted for. ๐Ÿ’–


๐ŸŒธ LIBMTP_property_t ๐ŸŒธ

okay this one is the big one. and when I say big, I mean main-character-with-a-whole-lore-arc big. every property constant is here, exactly as listed, so if youโ€™re hunting for one specific name, itโ€™s in the block. periodt. ๐Ÿซถ

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 }

likeโ€ฆ the way that list just keeps going? obsessed. and yes, every name in that block is verbatim โ€” including the spelling of LIBMTP_PROPERTY_PersistantUniqueObjectIdentifier. do not โ€œfixโ€ it, bestie. copy it exactly. ๐Ÿ˜ญ


๐Ÿงš LIBMTP_datatype_t ๐Ÿงš

this one is short and sweet โ€” the datatype constants. full set below, no crumbs. โœจ

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 }

int8 through uint64, all eight of them. cute, concise, done. ๐Ÿ’œ


๐Ÿ”ฅ LIBMTP_devicecap_t ๐Ÿ”ฅ

device capability constants! hereโ€™s the whole little squad. ๐ŸŽ€

enum LIBMTP_devicecap_t { LIBMTP_DEVICECAP_GetPartialObject,
           LIBMTP_DEVICECAP_SendPartialObject, LIBMTP_DEVICECAP_EditObjects,
           LIBMTP_DEVICECAP_MoveObject, LIBMTP_DEVICECAP_CopyObject }

five values, zero missing, periodt. ๐Ÿ’…


๐ŸŒˆ LIBMTP_error_number_t ๐ŸŒˆ

the error-number enum. not exactly a fun vibe, but sheโ€™s part of the lore and we respect her. every value is right here. ๐Ÿ’€

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 }

from LIBMTP_ERROR_NONE all the way to LIBMTP_ERROR_CANCELLED โ€” thatโ€™s the full set. ๐Ÿ™ˆ


๐Ÿฆ‹ LIBMTP_event_enum ๐Ÿฆ‹

and this is the event enum that closes out this batch. store added, store removed, object added, object removed, device property changed โ€” all the event constants are in the block. ๐Ÿซถ

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 }

thatโ€™s the whole enumerations lineup โ€” every single identifier accounted for, no cap. ๐Ÿ’–

โœจ Functions โœจ

okay bestie, this is the function motherlode โ€” every prototype in the exact order the manpage gives them, no cap. grab a snack, weโ€™re going through all of them. ๐Ÿ’…

  • void LIBMTP_Set_Debug (int) โ€” takes an int, and the name says Set_Debug, so yeah โ€” the debug dial is a whole thing. ๐ŸŽ›๏ธ
  • void LIBMTP_Init (void) โ€” no args, just vibes. itโ€™s the init, you need it. โœจ
  • int LIBMTP_Get_Supported_Devices_List (LIBMTP_device_entry_t **const, int *const) โ€” hands you a supported-devices list via double pointer plus an int *const. fancy. ๐Ÿ‘‘
  • LIBMTP_error_number_t LIBMTP_Detect_Raw_Devices (LIBMTP_raw_device_t **, int *) โ€” detect raw devices, returns an error number type, takes a double pointer and int *. ๐Ÿ”
  • int LIBMTP_Check_Specific_Device (int busno, int devno) โ€” asks about a specific device by busno and devno, returns int. bus girl behavior. ๐ŸšŒ
  • LIBMTP_mtpdevice_t * LIBMTP_Open_Raw_Device (LIBMTP_raw_device_t *) โ€” returns an LIBMTP_mtpdevice_t *, takes a raw device pointer. the opening ceremony. ๐ŸŽฌ
  • LIBMTP_mtpdevice_t * LIBMTP_Open_Raw_Device_Uncached (LIBMTP_raw_device_t *) โ€” same energy as above but with _Uncached in the name โ€” spicy. ๐ŸŒถ๏ธ
  • LIBMTP_mtpdevice_t * LIBMTP_Get_Device (int) โ€” give it an int, get a device pointer back. simple math. ๐Ÿงฎ
  • LIBMTP_mtpdevice_t * LIBMTP_Get_First_Device (void) โ€” no args, returns the first device pointer. main character energy. ๐ŸŒŸ
  • LIBMTP_mtpdevice_t * LIBMTP_Get_Device_By_SerialNumber (char *) โ€” serial number in, device pointer out. iykyk. ๐Ÿ”ข
  • LIBMTP_mtpdevice_t * LIBMTP_Get_Device_By_ID (char *) โ€” same but by char * ID. two flavors of finding your device. ๐Ÿ†”
  • LIBMTP_error_number_t LIBMTP_Get_Connected_Devices (LIBMTP_mtpdevice_t **) โ€” takes a double pointer to device, returns error number. connected king. ๐Ÿ”Œ
  • uint32_t LIBMTP_Number_Devices_In_List (LIBMTP_mtpdevice_t *) โ€” counts devices in a list, returns uint32_t. math but make it device-y. ๐Ÿ”ข
  • void LIBMTP_Release_Device_List (LIBMTP_mtpdevice_t *) โ€” void return, frees the list vibe. bye bestie. ๐Ÿ‘‹
  • void LIBMTP_Release_Device (LIBMTP_mtpdevice_t *) โ€” same but for one device. cleanup crew. ๐Ÿงน
  • void LIBMTP_Dump_Device_Info (LIBMTP_mtpdevice_t *) โ€” dumps info, returns nothing. the audacity. ๐Ÿ’…
  • int LIBMTP_Reset_Device (LIBMTP_mtpdevice_t *) โ€” reset button in function form, returns int. ๐Ÿ”„
  • char * LIBMTP_Get_Manufacturername (LIBMTP_mtpdevice_t *) โ€” returns a char * for manufacturer name. brand girlie. ๐Ÿท๏ธ
  • char * LIBMTP_Get_Modelname (LIBMTP_mtpdevice_t *) โ€” model name as char *. iconic. ๐Ÿ“ฑ
  • char * LIBMTP_Get_Serialnumber (LIBMTP_mtpdevice_t *) โ€” serial number string. youโ€™re unique, periodt. ๐Ÿ”–
  • char * LIBMTP_Get_Deviceversion (LIBMTP_mtpdevice_t *) โ€” device version string. version check but make it cute. ๐Ÿ”ข
  • char * LIBMTP_Get_Friendlyname (LIBMTP_mtpdevice_t *) โ€” friendly name as char *. be nice. ๐Ÿซถ
  • int LIBMTP_Set_Friendlyname (LIBMTP_mtpdevice_t *, char const *const) โ€” set the friendly name, returns int. name change era. โœ๏ธ
  • char * LIBMTP_Get_Syncpartner (LIBMTP_mtpdevice_t *) โ€” sync partner string. partner in crime. ๐Ÿค
  • int LIBMTP_Set_Syncpartner (LIBMTP_mtpdevice_t *, char const *const) โ€” set sync partner, int return. match made in MTP. ๐Ÿ’ž
  • int LIBMTP_Get_Batterylevel (LIBMTP_mtpdevice_t *, uint8_t *const, uint8_t *const) โ€” battery level, two uint8_t *const params, int return. low battery anxiety. ๐Ÿ”‹
  • int LIBMTP_Get_Secure_Time (LIBMTP_mtpdevice_t *, char **const) โ€” secure time, char **const, returns int. clock it. โฐ
  • int LIBMTP_Get_Device_Certificate (LIBMTP_mtpdevice_t *, char **const) โ€” certificate as char **const. very official. ๐Ÿ“œ
  • int LIBMTP_Get_Supported_Filetypes (LIBMTP_mtpdevice_t *, uint16_t **const, uint16_t *const) โ€” filetypes via uint16_t **const and uint16_t *const. type check. ๐Ÿ—‚๏ธ
  • int LIBMTP_Check_Capability (LIBMTP_mtpdevice_t *, LIBMTP_devicecap_t) โ€” check capability, takes LIBMTP_devicecap_t, returns int. can she do it? ๐Ÿ’ช
  • LIBMTP_error_t * LIBMTP_Get_Errorstack (LIBMTP_mtpdevice_t *) โ€” returns an LIBMTP_error_t * error stack. errors but make it stacked. ๐Ÿ˜ญ
  • void LIBMTP_Clear_Errorstack (LIBMTP_mtpdevice_t *) โ€” clears it, void. moving on. ๐Ÿงผ
  • void LIBMTP_Dump_Errorstack (LIBMTP_mtpdevice_t *) โ€” dumps the error stack, void. let it out. ๐Ÿ—‘๏ธ
  • void LIBMTP_FreeMemory (void *) โ€” frees a void *. memory hygiene, bestie. ๐Ÿง 
  • int LIBMTP_Get_Storage (LIBMTP_mtpdevice_t *, int const) โ€” storage info, takes int const, returns int. storage wars. ๐Ÿ’พ
  • int LIBMTP_Format_Storage (LIBMTP_mtpdevice_t *, LIBMTP_devicestorage_t *) โ€” format storage, pointer to LIBMTP_devicestorage_t, int return. dangerous but slay. โš ๏ธ
  • char * LIBMTP_Get_String_From_Object (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const) โ€” string from object by uint32_t const and property. get that string. ๐Ÿงต
  • uint64_t LIBMTP_Get_u64_From_Object (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint64_t const) โ€” u64 from object, plus a uint64_t const fallback. big number energy. 6๏ธโƒฃ4๏ธโƒฃ
  • uint32_t LIBMTP_Get_u32_From_Object (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint32_t const) โ€” u32 version, with uint32_t const. 3๏ธโƒฃ2๏ธโƒฃ
  • uint16_t LIBMTP_Get_u16_From_Object (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint16_t const) โ€” u16 version. 1๏ธโƒฃ6๏ธโƒฃ
  • uint8_t LIBMTP_Get_u8_From_Object (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint8_t const) โ€” u8, the baby number. 8๏ธโƒฃ
  • int LIBMTP_Set_Object_String (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, char const *const) โ€” set object string, returns int. write it down. โœ๏ธ
  • int LIBMTP_Set_Object_u32 (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint32_t const) โ€” set u32 on object. numeric slay. ๐Ÿ”ข
  • int LIBMTP_Set_Object_u16 (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint16_t const) โ€” set u16. small but mighty. ๐Ÿ”ธ
  • int LIBMTP_Set_Object_u8 (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const, uint8_t const) โ€” set u8. tiny icon. ๐Ÿ”น
  • char const * LIBMTP_Get_Property_Description (LIBMTP_property_t inproperty) โ€” property description as char const *, takes LIBMTP_property_t inproperty. describe it. ๐Ÿ“
  • int LIBMTP_Is_Property_Supported (LIBMTP_mtpdevice_t *, LIBMTP_property_t const, LIBMTP_filetype_t const) โ€” is it supported? takes property and filetype consts, returns int. yes/no vibes. โœ…
  • int LIBMTP_Get_Allowed_Property_Values (LIBMTP_mtpdevice_t *, LIBMTP_property_t const, LIBMTP_filetype_t const, LIBMTP_allowed_values_t *) โ€” allowed values, pointers everywhere, int return. permission slip. ๐ŸŽซ
  • void LIBMTP_destroy_allowed_values_t (LIBMTP_allowed_values_t *) โ€” destroy the allowed values struct, void. clean up. ๐Ÿงฝ
  • LIBMTP_file_t * LIBMTP_new_file_t (void) โ€” new file struct pointer, no args. baby file. ๐Ÿ‘ถ
  • void LIBMTP_destroy_file_t (LIBMTP_file_t *) โ€” destroy file struct. bye file. ๐Ÿ“
  • char const * LIBMTP_Get_Filetype_Description (LIBMTP_filetype_t) โ€” filetype description as char const *. tell me what you are. ๐Ÿท๏ธ
  • LIBMTP_file_t * LIBMTP_Get_Filelisting (LIBMTP_mtpdevice_t *) โ€” file listing pointer. list it. ๐Ÿ“‹
  • LIBMTP_file_t * LIBMTP_Get_Filelisting_With_Callback (LIBMTP_mtpdevice_t *, LIBMTP_progressfunc_t const, void const *const) โ€” same but with a progress callback and void const *const. fancy. ๐Ÿ“ž
  • LIBMTP_file_t * LIBMTP_Get_Files_And_Folders (LIBMTP_mtpdevice_t *, uint32_t const, uint32_t const) โ€” files and folders, two uint32_t const args. both worlds. ๐Ÿ—‚๏ธ
  • int LIBMTP_Get_Children (LIBMTP_mtpdevice_t *, uint32_t const, uint32_t const, uint32_t **) โ€” get children, ends with uint32_t **, returns int. parent energy. ๐Ÿ‘ถ
  • LIBMTP_file_t * LIBMTP_Get_Filemetadata (LIBMTP_mtpdevice_t *, uint32_t const) โ€” file metadata pointer, uint32_t const. data girl. ๐Ÿ“Š
  • int LIBMTP_Get_File_To_File (LIBMTP_mtpdevice_t *, uint32_t, char const *const, LIBMTP_progressfunc_t const, void const *const) โ€” file to file, int return, includes progress func. transfer vibes. ๐Ÿ”
  • int LIBMTP_Get_File_To_File_Descriptor (LIBMTP_mtpdevice_t *, uint32_t const, int const, LIBMTP_progressfunc_t const, void const *const) โ€” to file descriptor, takes int const. fd realness. ๐Ÿงพ
  • int LIBMTP_Get_File_To_Handler (LIBMTP_mtpdevice_t *, uint32_t const, MTPDataPutFunc, void *, LIBMTP_progressfunc_t const, void const *const) โ€” to handler with MTPDataPutFunc, void *, progress func. handler slay. ๐ŸŽ›๏ธ
  • int LIBMTP_Send_File_From_File (LIBMTP_mtpdevice_t *, char const *const, LIBMTP_file_t *const, LIBMTP_progressfunc_t const, void const *const) โ€” send file from file, int return. outgoing. ๐Ÿ“ค
  • int LIBMTP_Send_File_From_File_Descriptor (LIBMTP_mtpdevice_t *, int const, LIBMTP_file_t *const, LIBMTP_progressfunc_t const, void const *const) โ€” from file descriptor. fd again. ๐Ÿ“จ
  • int LIBMTP_Send_File_From_Handler (LIBMTP_mtpdevice_t *, MTPDataGetFunc, void *, LIBMTP_file_t *const, LIBMTP_progressfunc_t const, void const *const) โ€” from handler with MTPDataGetFunc. get it. ๐ŸŽ
  • int LIBMTP_Set_File_Name (LIBMTP_mtpdevice_t *, LIBMTP_file_t *, const char *) โ€” set file name, int return. rename era. ๐Ÿท๏ธ
  • LIBMTP_filesampledata_t * LIBMTP_new_filesampledata_t (void) โ€” new filesampledata struct. sample platter. ๐Ÿ“
  • void LIBMTP_destroy_filesampledata_t (LIBMTP_filesampledata_t *) โ€” destroy it. no more samples. ๐Ÿ—‘๏ธ
  • int LIBMTP_Get_Representative_Sample_Format (LIBMTP_mtpdevice_t *, LIBMTP_filetype_t const, LIBMTP_filesampledata_t **) โ€” representative sample format, double pointer. represent. ๐Ÿ’
  • int LIBMTP_Send_Representative_Sample (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_filesampledata_t *) โ€” send representative sample, int. send it. ๐Ÿ“ฎ
  • int LIBMTP_Get_Representative_Sample (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_filesampledata_t *) โ€” get representative sample. receive it. ๐Ÿ“ฌ
  • int LIBMTP_Get_Thumbnail (LIBMTP_mtpdevice_t *, uint32_t const, unsigned char **data, unsigned int *size) โ€” thumbnail, unsigned char **data and unsigned int *size. cute little pic. ๐Ÿ–ผ๏ธ
  • LIBMTP_track_t * LIBMTP_new_track_t (void) โ€” new track struct. music era. ๐ŸŽต
  • void LIBMTP_destroy_track_t (LIBMTP_track_t *) โ€” destroy track. track ends. ๐ŸŽถ
  • LIBMTP_track_t * LIBMTP_Get_Tracklisting (LIBMTP_mtpdevice_t *) โ€” track listing pointer. playlist vibes. ๐Ÿ“ป
  • LIBMTP_track_t * LIBMTP_Get_Tracklisting_With_Callback (LIBMTP_mtpdevice_t *, LIBMTP_progressfunc_t const, void const *const) โ€” tracklisting with callback. call me maybe. ๐Ÿ“ž
  • LIBMTP_track_t * LIBMTP_Get_Tracklisting_With_Callback_For_Storage (LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_progressfunc_t const, void const *const) โ€” callback for storage, extra uint32_t const. storage-specific tracks. ๐Ÿ’ฝ
  • LIBMTP_track_t * LIBMTP_Get_Trackmetadata (LIBMTP_mtpdevice_t *, uint32_t const) โ€” track metadata pointer. metadata is the moment. ๐Ÿ“Š
  • int LIBMTP_Get_Track_To_File (LIBMTP_mtpdevice_t *, uint32_t, char const *const, LIBMTP_progressfunc_t const, void const *const) โ€” track to file, int. take it to the file. ๐Ÿ“
  • int LIBMTP_Get_Track_To_File_Descriptor (LIBMTP_mtpdevice_t *, uint32_t const, int const, LIBMTP_progressfunc_t const, void const *const) โ€” track to fd, int const. fd again, we love her. ๐Ÿงพ
  • int LIBMTP_Get_Track_To_Handler (LIBMTP_mtpdevice_t *, uint32_t const, MTPDataPutFunc, void *, LIBMTP_progressfunc_t const, void const *const) โ€” track to handler with MTPDataPutFunc. handled. ๐ŸŽ›๏ธ
  • int LIBMTP_Send_Track_From_File (LIBMTP_mtpdevice_t *, char const *const, LIBMTP_track_t *const, LIBMTP_progressfunc_t const, void const *const) โ€” send track from file. outgoing track. ๐Ÿ“ค
  • int LIBMTP_Send_Track_From_File_Descriptor (LIBMTP_mtpdevice_t *, int const, LIBMTP_track_t *const, LIBMTP_progressfunc_t const, void const *const) โ€” from fd. same energy. ๐Ÿ“จ
  • int LIBMTP_Send_Track_From_Handler (LIBMTP_mtpdevice_t *, MTPDataGetFunc, void *, LIBMTP_track_t *const, LIBMTP_progressfunc_t const, void const *const) โ€” from handler with MTPDataGetFunc. get that track. ๐ŸŽ
  • int LIBMTP_Update_Track_Metadata (LIBMTP_mtpdevice_t *, LIBMTP_track_t const *const) โ€” update track metadata, int return. glow-up for metadata. โœจ
  • int LIBMTP_Track_Exists (LIBMTP_mtpdevice_t *, uint32_t const) โ€” does the track exist? int return. existential crisis. ๐Ÿค”
  • int LIBMTP_Set_Track_Name (LIBMTP_mtpdevice_t *, LIBMTP_track_t *, const char *) โ€” set track name. name change. โœ๏ธ
  • LIBMTP_folder_t * LIBMTP_new_folder_t (void) โ€” new folder struct. folder baby. ๐Ÿ“
  • void LIBMTP_destroy_folder_t (LIBMTP_folder_t *) โ€” destroy folder. folder gone. ๐Ÿ—‘๏ธ
  • LIBMTP_folder_t * LIBMTP_Get_Folder_List (LIBMTP_mtpdevice_t *) โ€” folder list pointer. list it. ๐Ÿ“‚
  • LIBMTP_folder_t * LIBMTP_Get_Folder_List_For_Storage (LIBMTP_mtpdevice_t *, uint32_t const) โ€” folder list for storage, uint32_t const. storage folders. ๐Ÿ’ฝ
  • LIBMTP_folder_t * LIBMTP_Find_Folder (LIBMTP_folder_t *, uint32_t const) โ€” find folder, returns LIBMTP_folder_t *. seek and find. ๐Ÿ”
  • uint32_t LIBMTP_Create_Folder (LIBMTP_mtpdevice_t *, char *, uint32_t, uint32_t) โ€” create folder, returns uint32_t, takes char * and two uint32_t. new folder who dis. ๐Ÿ†•
  • int LIBMTP_Set_Folder_Name (LIBMTP_mtpdevice_t *, LIBMTP_folder_t *, const char *) โ€” set folder name. rename. โœ๏ธ
  • LIBMTP_playlist_t * LIBMTP_new_playlist_t (void) โ€” new playlist struct. playlist era. ๐ŸŽง
  • void LIBMTP_destroy_playlist_t (LIBMTP_playlist_t *) โ€” destroy playlist. playlist over. ๐Ÿ—‘๏ธ
  • LIBMTP_playlist_t * LIBMTP_Get_Playlist_List (LIBMTP_mtpdevice_t *) โ€” playlist list pointer. all the playlists. ๐Ÿ“œ
  • LIBMTP_playlist_t * LIBMTP_Get_Playlist (LIBMTP_mtpdevice_t *, uint32_t const) โ€” get one playlist, uint32_t const. specific vibes. ๐ŸŽฏ
  • int LIBMTP_Create_New_Playlist (LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *const) โ€” create new playlist, int. new playlist energy. โœจ
  • int LIBMTP_Update_Playlist (LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *const) โ€” update playlist. refresh. ๐Ÿ”„
  • int LIBMTP_Set_Playlist_Name (LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *, const char *) โ€” set playlist name. name it. โœ๏ธ
  • LIBMTP_album_t * LIBMTP_new_album_t (void) โ€” new album struct. album drop. ๐Ÿ’ฟ
  • void LIBMTP_destroy_album_t (LIBMTP_album_t *) โ€” destroy album. album out. ๐Ÿ—‘๏ธ
  • LIBMTP_album_t * LIBMTP_Get_Album_List (LIBMTP_mtpdevice_t *) โ€” album list pointer. discography. ๐Ÿ“€
  • LIBMTP_album_t * LIBMTP_Get_Album_List_For_Storage (LIBMTP_mtpdevice_t *, uint32_t const) โ€” album list for storage. storage albums. ๐Ÿ’ฝ
  • LIBMTP_album_t * LIBMTP_Get_Album (LIBMTP_mtpdevice_t *, uint32_t const) โ€” get one album. album specific. ๐ŸŽฏ
  • int LIBMTP_Create_New_Album (LIBMTP_mtpdevice_t *, LIBMTP_album_t *const) โ€” create new album, int. drop it. ๐ŸŽค
  • int LIBMTP_Update_Album (LIBMTP_mtpdevice_t *, LIBMTP_album_t const *const) โ€” update album. remix. ๐Ÿ”„
  • int LIBMTP_Set_Album_Name (LIBMTP_mtpdevice_t *, LIBMTP_album_t *, const char *) โ€” set album name. title track. โœ๏ธ
  • int LIBMTP_Delete_Object (LIBMTP_mtpdevice_t *, uint32_t) โ€” delete object, int. bye object. ๐Ÿ—‘๏ธ
  • int LIBMTP_Move_Object (LIBMTP_mtpdevice_t *, uint32_t, uint32_t, uint32_t) โ€” move object, three uint32_t. relocate. ๐Ÿšš
  • int LIBMTP_Copy_Object (LIBMTP_mtpdevice_t *, uint32_t, uint32_t, uint32_t) โ€” copy object, three uint32_t. duplicate. ๐Ÿ“‘
  • int LIBMTP_Set_Object_Filename (LIBMTP_mtpdevice_t *, uint32_t, char *) โ€” set object filename, int. filename glow-up. ๐Ÿท๏ธ
  • int LIBMTP_GetPartialObject (LIBMTP_mtpdevice_t *, uint32_t const, uint64_t, uint32_t, unsigned char **, unsigned int *) โ€” partial object, lots of args, int return. just a piece. ๐Ÿงฉ
  • int LIBMTP_SendPartialObject (LIBMTP_mtpdevice_t *, uint32_t const, uint64_t, unsigned char *, unsigned int) โ€” send partial object, int. send a piece. ๐Ÿ“ค
  • int LIBMTP_BeginEditObject (LIBMTP_mtpdevice_t *, uint32_t const) โ€” begin edit object, int. edit era starts. โœ๏ธ
  • int LIBMTP_EndEditObject (LIBMTP_mtpdevice_t *, uint32_t const) โ€” end edit object, int. edit era ends. ๐Ÿ
  • int LIBMTP_TruncateObject (LIBMTP_mtpdevice_t *, uint32_t const, uint64_t) โ€” truncate object, int, takes uint64_t. chop chop. โœ‚๏ธ
  • int LIBMTP_Read_Event (LIBMTP_mtpdevice_t *, LIBMTP_event_t *, uint32_t *) โ€” read event, int. event reading. ๐Ÿ“–
  • int LIBMTP_Read_Event_Async (LIBMTP_mtpdevice_t *, LIBMTP_event_cb_fn, void *) โ€” async event read with callback and void *. async slay. โšก
  • int LIBMTP_Handle_Events_Timeout_Completed (struct timeval *, int *) โ€” handle events timeout completed, takes struct timeval * and int *. timing. โฑ๏ธ
  • int LIBMTP_Custom_Operation (LIBMTP_mtpdevice_t *, uint16_t, int,...) โ€” custom operation, variadic with ..., returns int. do your own thing. ๐Ÿ› ๏ธ

โœจ Variables โœจ

  • int LIBMTP_debug โ€” the debug variable, an int. the debug dialโ€™s home. ๐ŸŽ›๏ธ

๐Ÿ’– DETAILED DESCRIPTION ๐Ÿ’–

okay so this page is the interface to the Media Transfer Protocol library โ€” that's the whole vibe. It's the header-level bestie that lets you talk to MTP devices, and the credits are giving iconic:

  • 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

Now for the legal tea, because we respect the license in this group chat:

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.

And the include line is literally this, bestie:

#include <libmtp.h>

๐Ÿงš VARIABLE DOCUMENTATION ๐Ÿงš

๐ŸŒŸ int LIBMTP_debug [extern] ๐ŸŒŸ

This is the global debug level. The library uses a flag system so you can switch on just a part of the logs โ€” very choose-your-own-adventure, very cute.

The LIBMTP_DEBUG environment variable sets the debug flags for any binary that uses libmtp and calls LIBMTP_Init. The value can be given in decimal โ€” but listen, it must not start with "0", or it will be interpreted in octal โ€” or in hexadecimal, which must start with 0x.

The value -1 enables all debug flags. All of them. The whole buffet. ๐Ÿ“

Some 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).

Flags (combine by adding the hex values):

  • 0x00 [0000 0000] : LIBMTP_DEBUG_NONE : no debug (default)
  • 0x01 [0000 0001] : LIBMTP_DEBUG_PTP : PTP debug
  • 0x02 [0000 0010] : LIBMTP_DEBUG_PLST : Playlist debug
  • 0x04 [0000 0100] : LIBMTP_DEBUG_USB : USB debug
  • 0x08 [0000 1000] : LIBMTP_DEBUG_DATA : USB data debug

(Please keep this list in sync with libmtp.h.)

Referenced by LIBMTP_Set_Debug().


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

The author section says, and I quote: โ€œGenerated automatically by Doxygen for libmtp from the source code.โ€ Doxygen really said โ€œI'll handle the typing, bestie.โ€ ๐Ÿ’…


okay that's the page, and the footer is serving source libmtp at Version 1.1.23 โ€” there's no date in this footer to read, so I'm not inventing one, periodt. ๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from