.TH "files" 3 "Version 1.1.21" "libmtp" \" -*- nroff -*- .ad l .nh .SH NAME libmtp \- files .SH SYNOPSIS .br .PP .SS "Macros" .in +1c .ti -1c .RI "#define \fBLIBMTP_FILES_AND_FOLDERS_ROOT\fP 0xffffffff" .br .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef void(* \fBLIBMTP_event_cb_fn\fP) (int, LIBMTP_event_t, uint32_t, void *)" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "\fBLIBMTP_file_t\fP * \fBLIBMTP_new_file_t\fP (void)" .br .ti -1c .RI "void \fBLIBMTP_destroy_file_t\fP (\fBLIBMTP_file_t\fP *)" .br .ti -1c .RI "char const * \fBLIBMTP_Get_Filetype_Description\fP (\fBLIBMTP_filetype_t\fP)" .br .ti -1c .RI "\fBLIBMTP_file_t\fP * \fBLIBMTP_Get_Filelisting\fP (\fBLIBMTP_mtpdevice_t\fP *)" .br .ti -1c .RI "\fBLIBMTP_file_t\fP * \fBLIBMTP_Get_Filelisting_With_Callback\fP (\fBLIBMTP_mtpdevice_t\fP *, \fBLIBMTP_progressfunc_t\fP const, void const *const)" .br .ti -1c .RI "\fBLIBMTP_file_t\fP * \fBLIBMTP_Get_Files_And_Folders\fP (\fBLIBMTP_mtpdevice_t\fP *, uint32_t const, uint32_t const)" .br .ti -1c .RI "int \fBLIBMTP_Get_Children\fP (\fBLIBMTP_mtpdevice_t\fP *, uint32_t const, uint32_t const, uint32_t **)" .br .ti -1c .RI "\fBLIBMTP_file_t\fP * \fBLIBMTP_Get_Filemetadata\fP (\fBLIBMTP_mtpdevice_t\fP *, uint32_t const)" .br .ti -1c .RI "int \fBLIBMTP_Get_File_To_File\fP (\fBLIBMTP_mtpdevice_t\fP *, uint32_t, char const *const, \fBLIBMTP_progressfunc_t\fP const, void const *const)" .br .ti -1c .RI "int \fBLIBMTP_Get_File_To_File_Descriptor\fP (\fBLIBMTP_mtpdevice_t\fP *, uint32_t const, int const, \fBLIBMTP_progressfunc_t\fP const, void const *const)" .br .ti -1c .RI "int \fBLIBMTP_Get_File_To_Handler\fP (\fBLIBMTP_mtpdevice_t\fP *, uint32_t const, \fBMTPDataPutFunc\fP, void *, \fBLIBMTP_progressfunc_t\fP const, void const *const)" .br .ti -1c .RI "int \fBLIBMTP_Send_File_From_File\fP (\fBLIBMTP_mtpdevice_t\fP *, char const *const, \fBLIBMTP_file_t\fP *const, \fBLIBMTP_progressfunc_t\fP const, void const *const)" .br .ti -1c .RI "int \fBLIBMTP_Send_File_From_File_Descriptor\fP (\fBLIBMTP_mtpdevice_t\fP *, int const, \fBLIBMTP_file_t\fP *const, \fBLIBMTP_progressfunc_t\fP const, void const *const)" .br .ti -1c .RI "int \fBLIBMTP_Send_File_From_Handler\fP (\fBLIBMTP_mtpdevice_t\fP *, \fBMTPDataGetFunc\fP, void *, \fBLIBMTP_file_t\fP *const, \fBLIBMTP_progressfunc_t\fP const, void const *const)" .br .ti -1c .RI "int \fBLIBMTP_Set_File_Name\fP (\fBLIBMTP_mtpdevice_t\fP *, \fBLIBMTP_file_t\fP *, const char *)" .br .ti -1c .RI "\fBLIBMTP_filesampledata_t\fP * \fBLIBMTP_new_filesampledata_t\fP (void)" .br .ti -1c .RI "void \fBLIBMTP_destroy_filesampledata_t\fP (\fBLIBMTP_filesampledata_t\fP *)" .br .ti -1c .RI "int \fBLIBMTP_Get_Representative_Sample_Format\fP (\fBLIBMTP_mtpdevice_t\fP *, \fBLIBMTP_filetype_t\fP const, \fBLIBMTP_filesampledata_t\fP **)" .br .ti -1c .RI "int \fBLIBMTP_Send_Representative_Sample\fP (\fBLIBMTP_mtpdevice_t\fP *, uint32_t const, \fBLIBMTP_filesampledata_t\fP *)" .br .ti -1c .RI "int \fBLIBMTP_Get_Representative_Sample\fP (\fBLIBMTP_mtpdevice_t\fP *, uint32_t const, \fBLIBMTP_filesampledata_t\fP *)" .br .ti -1c .RI "int \fBLIBMTP_Get_Thumbnail\fP (\fBLIBMTP_mtpdevice_t\fP *, uint32_t const, unsigned char **data, unsigned int *size)" .br .ti -1c .RI "int \fBLIBMTP_Read_Event\fP (\fBLIBMTP_mtpdevice_t\fP *, LIBMTP_event_t *, uint32_t *)" .br .ti -1c .RI "int \fBLIBMTP_Read_Event_Async\fP (\fBLIBMTP_mtpdevice_t\fP *, LIBMTP_event_cb_fn, void *)" .br .ti -1c .RI "int \fBLIBMTP_Handle_Events_Timeout_Completed\fP (struct timeval *, int *)" .br .in -1c .SH "Detailed Description" .PP .SH "Function Documentation" .PP .SS "void LIBMTP_destroy_file_t (\fBLIBMTP_file_t\fP * file)" This destroys a file metadata structure and deallocates the memory used by it, including any strings\&. Never use a file metadata structure again after calling this function on it\&. .PP \fBParameters\fP .RS 4 \fIfile\fP the file metadata to destroy\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_new_file_t()\fP .RE .PP .PP References \fBLIBMTP_file_struct::filename\fP\&. .PP Referenced by \fBLIBMTP_Get_File_To_File_Descriptor()\fP, \fBLIBMTP_Get_File_To_Handler()\fP, \fBLIBMTP_Send_File_From_File_Descriptor()\fP, and \fBLIBMTP_Send_File_From_Handler()\fP\&. .SS "void LIBMTP_destroy_filesampledata_t (\fBLIBMTP_filesampledata_t\fP * sample)" This destroys a file sample metadata type\&. .PP \fBParameters\fP .RS 4 \fIsample\fP the file sample metadata to be destroyed\&. .RE .PP .PP References \fBLIBMTP_filesampledata_struct::data\fP\&. .SS "int LIBMTP_Get_Children (\fBLIBMTP_mtpdevice_t\fP * device, uint32_t const storage, uint32_t const parent, uint32_t ** out)" This function retrieves the list of ids of files and folders in a certain folder with id parent on a certain storage on a certain device\&. The device used with this operations must have been opened with \fBLIBMTP_Open_Raw_Device_Uncached()\fP or it will fail\&. .PP NOTE: the request will always perform I/O with the device\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the MTP device to report info from\&. .br \fIstorage\fP a storage on the device to report info from\&. If 0 is passed in, the files for the given parent will be searched across all available storages\&. .br \fIparent\fP the parent folder id\&. .br \fIout\fP the pointer where the array of ids is returned\&. It is set only when the returned value > 0\&. The caller takes the ownership of the array and has to free() it\&. .RE .PP \fBReturns\fP .RS 4 the length of the returned array or \-1 in case of failure\&. .RE .PP .PP References \fBLIBMTP_mtpdevice_struct::cached\fP, and \fBLIBMTP_mtpdevice_struct::params\fP\&. .SS "int LIBMTP_Get_File_To_File (\fBLIBMTP_mtpdevice_t\fP * device, uint32_t const id, char const *const path, \fBLIBMTP_progressfunc_t\fP const callback, void const *const data)" This gets a file off the device to a local file identified by a filename\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device to get the track from\&. .br \fIid\fP the file ID of the file to retrieve\&. .br \fIpath\fP a filename to use for the retrieved file\&. .br \fIcallback\fP a progress indicator function or NULL to ignore\&. .br \fIdata\fP a user-defined pointer that is passed along to the \fCprogress\fP function in order to pass along some user defined data to the progress updates\&. If not used, set this to NULL\&. .RE .PP \fBReturns\fP .RS 4 0 if the transfer was successful, any other value means failure\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_Get_File_To_File_Descriptor()\fP .RE .PP .PP References \fBLIBMTP_Get_File_To_File_Descriptor()\fP\&. .PP Referenced by \fBLIBMTP_Get_Track_To_File()\fP\&. .SS "int LIBMTP_Get_File_To_File_Descriptor (\fBLIBMTP_mtpdevice_t\fP * device, uint32_t const id, int const fd, \fBLIBMTP_progressfunc_t\fP const callback, void const *const data)" This gets a file off the device to a file identified by a file descriptor\&. .PP This function can potentially be used for streaming files off the device for playback or broadcast for example, by downloading the file into a stream sink e\&.g\&. a socket\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device to get the file from\&. .br \fIid\fP the file ID of the file to retrieve\&. .br \fIfd\fP a local file descriptor to write the file to\&. .br \fIcallback\fP a progress indicator function or NULL to ignore\&. .br \fIdata\fP a user-defined pointer that is passed along to the \fCprogress\fP function in order to pass along some user defined data to the progress updates\&. If not used, set this to NULL\&. .RE .PP \fBReturns\fP .RS 4 0 if the transfer was successful, any other value means failure\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_Get_File_To_File()\fP .RE .PP .PP References \fB_PTP_USB::callback_active\fP, \fBLIBMTP_file_struct::filesize\fP, \fBLIBMTP_file_struct::filetype\fP, \fBLIBMTP_destroy_file_t()\fP, \fBLIBMTP_Get_Filemetadata()\fP, \fBLIBMTP_mtpdevice_struct::params\fP, and \fBLIBMTP_mtpdevice_struct::usbinfo\fP\&. .PP Referenced by \fBLIBMTP_Get_File_To_File()\fP, and \fBLIBMTP_Get_Track_To_File_Descriptor()\fP\&. .SS "int LIBMTP_Get_File_To_Handler (\fBLIBMTP_mtpdevice_t\fP * device, uint32_t const id, \fBMTPDataPutFunc\fP put_func, void * priv, \fBLIBMTP_progressfunc_t\fP const callback, void const *const data)" This gets a file off the device and calls put_func with chunks of data .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device to get the file from\&. .br \fIid\fP the file ID of the file to retrieve\&. .br \fIput_func\fP the function to call when we have data\&. .br \fIpriv\fP the user-defined pointer that is passed to \fCput_func\fP\&. .br \fIcallback\fP a progress indicator function or NULL to ignore\&. .br \fIdata\fP a user-defined pointer that is passed along to the \fCprogress\fP function in order to pass along some user defined data to the progress updates\&. If not used, set this to NULL\&. .RE .PP \fBReturns\fP .RS 4 0 if the transfer was successful, any other value means failure\&. .RE .PP .PP References \fB_PTP_USB::callback_active\fP, \fBLIBMTP_file_struct::filesize\fP, \fBLIBMTP_file_struct::filetype\fP, \fBLIBMTP_destroy_file_t()\fP, \fBLIBMTP_Get_Filemetadata()\fP, \fBLIBMTP_mtpdevice_struct::params\fP, and \fBLIBMTP_mtpdevice_struct::usbinfo\fP\&. .PP Referenced by \fBLIBMTP_Get_Track_To_Handler()\fP\&. .SS "\fBLIBMTP_file_t\fP * LIBMTP_Get_Filelisting (\fBLIBMTP_mtpdevice_t\fP * device)" THIS FUNCTION IS DEPRECATED\&. PLEASE UPDATE YOUR CODE IN ORDER NOT TO USE IT\&. .PP \fBSee also\fP .RS 4 \fBLIBMTP_Get_Filelisting_With_Callback()\fP .RE .PP .PP References \fBLIBMTP_Get_Filelisting_With_Callback()\fP\&. .SS "\fBLIBMTP_file_t\fP * LIBMTP_Get_Filelisting_With_Callback (\fBLIBMTP_mtpdevice_t\fP * device, \fBLIBMTP_progressfunc_t\fP const callback, void const *const data)" This returns a long list of all files available on the current MTP device\&. Folders will not be returned, but abstract entities like playlists and albums will show up as 'files'\&. Typical usage: .PP .PP .nf LIBMTP_file_t *filelist; filelist = LIBMTP_Get_Filelisting_With_Callback(device, callback, data); while (filelist != NULL) { LIBMTP_file_t *tmp; // Do something on each element in the list here\&.\&.\&. tmp = filelist; filelist = filelist->next; LIBMTP_destroy_file_t(tmp); } .fi .PP .PP If you want to group your file listing by storage (per storage unit) or arrange files into folders, you must dereference the \fCstorage_id\fP and/or \fCparent_id\fP field of the returned \fCLIBMTP_file_t\fP struct\&. To arrange by folders or files you typically have to create the proper trees by calls to \fC\fBLIBMTP_Get_Storage()\fP\fP and/or \fC\fBLIBMTP_Get_Folder_List()\fP\fP first\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device to get the file listing for\&. .br \fIcallback\fP a function to be called during the tracklisting retrieveal for displaying progress bars etc, or NULL if you don't want any callbacks\&. .br \fIdata\fP a user-defined pointer that is passed along to the \fCprogress\fP function in order to pass along some user defined data to the progress updates\&. If not used, set this to NULL\&. .RE .PP \fBReturns\fP .RS 4 a list of files that can be followed using the \fCnext\fP field of the \fCLIBMTP_file_t\fP data structure\&. Each of the metadata tags must be freed after use, and may contain only partial metadata information, i\&.e\&. one or several fields may be NULL or 0\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_Get_Filemetadata()\fP .RE .PP .PP References \fBLIBMTP_file_struct::next\fP, and \fBLIBMTP_mtpdevice_struct::params\fP\&. .PP Referenced by \fBLIBMTP_Get_Filelisting()\fP\&. .SS "\fBLIBMTP_file_t\fP * LIBMTP_Get_Filemetadata (\fBLIBMTP_mtpdevice_t\fP * device, uint32_t const fileid)" This function retrieves the metadata for a single file off the device\&. .PP Do not call this function repeatedly! The file handles are linearly searched O(n) and the call may involve (slow) USB traffic, so use \fC\fBLIBMTP_Get_Filelisting()\fP\fP and cache the file, preferably as an efficient data structure such as a hash list\&. .PP Incidentally this function will return metadata for a folder (association) as well, but this is not a proper use of it, it is intended for file manipulation, not folder manipulation\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device to get the file metadata from\&. .br \fIfileid\fP the object ID of the file that you want the metadata for\&. .RE .PP \fBReturns\fP .RS 4 a metadata entry on success or NULL on failure\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_Get_Filelisting()\fP .RE .PP .PP References \fBLIBMTP_mtpdevice_struct::cached\fP, and \fBLIBMTP_mtpdevice_struct::params\fP\&. .PP Referenced by \fBLIBMTP_Get_File_To_File_Descriptor()\fP, \fBLIBMTP_Get_File_To_Handler()\fP, \fBLIBMTP_Get_Files_And_Folders()\fP, \fBLIBMTP_Send_File_From_File_Descriptor()\fP, \fBLIBMTP_Send_File_From_Handler()\fP, and \fBLIBMTP_Set_Object_Filename()\fP\&. .SS "\fBLIBMTP_file_t\fP * LIBMTP_Get_Files_And_Folders (\fBLIBMTP_mtpdevice_t\fP * device, uint32_t const storage, uint32_t const parent)" This function retrieves the contents of a certain folder with id parent on a certain storage on a certain device\&. The result contains both files and folders\&. The device used with this operations must have been opened with \fBLIBMTP_Open_Raw_Device_Uncached()\fP or it will fail\&. .PP NOTE: the request will always perform I/O with the device\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the MTP device to report info from\&. .br \fIstorage\fP a storage on the device to report info from\&. If 0 is passed in, the files for the given parent will be searched across all available storages\&. .br \fIparent\fP the parent folder id\&. .RE .PP .PP References \fBLIBMTP_mtpdevice_struct::cached\fP, \fBLIBMTP_Get_Filemetadata()\fP, \fBLIBMTP_file_struct::next\fP, and \fBLIBMTP_mtpdevice_struct::params\fP\&. .SS "char const * LIBMTP_Get_Filetype_Description (\fBLIBMTP_filetype_t\fP intype)" This helper function returns a textual description for a libmtp file type to be used in dialog boxes etc\&. .PP \fBParameters\fP .RS 4 \fIintype\fP the libmtp internal filetype to get a description for\&. .RE .PP \fBReturns\fP .RS 4 a string representing the filetype, this must \fBNOT\fP be free():ed by the caller! .RE .PP .PP References \fBfilemap_struct::description\fP, and \fBfilemap_struct::id\fP\&. .SS "int LIBMTP_Get_Representative_Sample (\fBLIBMTP_mtpdevice_t\fP * device, uint32_t const id, \fBLIBMTP_filesampledata_t\fP * sampledata)" This routine gets representative sample data for an object\&. This uses the RepresentativeSampleData property of the album, if the device supports it\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device which the object is on\&. .br \fIid\fP unique id of the object to get data for\&. .br \fIsampledata\fP pointer to LIBMTP_filesampledata_t struct to receive data .RE .PP \fBReturns\fP .RS 4 0 on success, any other value means failure\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_Send_Representative_Sample()\fP .PP \fBLIBMTP_Get_Representative_Sample_Format()\fP .PP \fBLIBMTP_Create_New_Album()\fP .RE .PP .PP References \fBLIBMTP_filesampledata_struct::data\fP, \fBLIBMTP_filesampledata_struct::duration\fP, \fBLIBMTP_filesampledata_struct::filetype\fP, \fBLIBMTP_filesampledata_struct::height\fP, \fBLIBMTP_mtpdevice_struct::params\fP, \fBLIBMTP_filesampledata_struct::size\fP, and \fBLIBMTP_filesampledata_struct::width\fP\&. .SS "int LIBMTP_Get_Representative_Sample_Format (\fBLIBMTP_mtpdevice_t\fP * device, \fBLIBMTP_filetype_t\fP const filetype, \fBLIBMTP_filesampledata_t\fP ** sample)" This routine figures out whether a certain filetype supports representative samples (small thumbnail images) or not\&. This typically applies to JPEG files, MP3 files and Album abstract playlists, but in theory any filetype could support representative samples\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device which is to be examined\&. .br \fIfiletype\fP the fileype to examine, and return the representative sample properties for\&. .br \fIsample\fP this will contain a new sample type with the fields filled in with suitable default values\&. For example, the supported sample type will be set, the supported height and width will be set to max values if it is an image sample, and duration will also be given some suitable default value which should not be exceeded on audio samples\&. If the device does not support samples for this filetype, this pointer will be NULL\&. If it is not NULL, the user must destroy this struct with \fC\fBLIBMTP_destroy_filesampledata_t()\fP\fP after use\&. .RE .PP \fBReturns\fP .RS 4 0 on success, any other value means failure\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_Send_Representative_Sample()\fP .PP \fBLIBMTP_Create_New_Album()\fP .RE .PP .PP References \fBLIBMTP_filesampledata_struct::duration\fP, \fBLIBMTP_filesampledata_struct::filetype\fP, \fBLIBMTP_filesampledata_struct::height\fP, \fBLIBMTP_new_filesampledata_t()\fP, \fBLIBMTP_mtpdevice_struct::params\fP, \fBLIBMTP_filesampledata_struct::size\fP, and \fBLIBMTP_filesampledata_struct::width\fP\&. .SS "int LIBMTP_Get_Thumbnail (\fBLIBMTP_mtpdevice_t\fP * device, uint32_t const id, unsigned char ** data, unsigned int * size)" Retrieve the thumbnail for a file\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device to get the thumbnail from\&. .br \fIid\fP the object ID of the file to retrieve the thumbnail for\&. .RE .PP \fBReturns\fP .RS 4 0 on success, any other value means failure\&. .RE .PP .PP References \fBLIBMTP_mtpdevice_struct::params\fP\&. .SS "int LIBMTP_Handle_Events_Timeout_Completed (struct timeval * tv, int * completed)" Trivial wrapper around the most generic libusb method for polling for events\&. Can be used to drive asynchronous event detection\&. .SS "\fBLIBMTP_file_t\fP * LIBMTP_new_file_t (void)" This creates a new file metadata structure and allocates memory for it\&. Notice that if you add strings to this structure they will be freed by the corresponding \fCLIBMTP_destroy_file_t\fP operation later, so be careful of using strdup() when assigning strings, e\&.g\&.: .PP .PP .nf LIBMTP_file_t *file = \fBLIBMTP_new_file_t()\fP; file->filename = strdup(namestr); \&.\&.\&.\&. LIBMTP_destroy_file_t(file); .fi .PP .PP \fBReturns\fP .RS 4 a pointer to the newly allocated metadata structure\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_destroy_file_t()\fP .RE .PP .PP References \fBLIBMTP_file_struct::filename\fP\&. .SS "\fBLIBMTP_filesampledata_t\fP * LIBMTP_new_filesampledata_t (void)" This creates a new sample data metadata structure and allocates memory for it\&. Notice that if you add strings to this structure they will be freed by the corresponding \fCLIBMTP_destroy_sampledata_t\fP operation later, so be careful of using strdup() when assigning strings\&. .PP \fBReturns\fP .RS 4 a pointer to the newly allocated metadata structure\&. .RE .PP \fBSee also\fP .RS 4 LIBMTP_destroy_sampledata_t() .RE .PP .PP References \fBLIBMTP_filesampledata_struct::height\fP\&. .PP Referenced by \fBLIBMTP_Get_Representative_Sample_Format()\fP\&. .SS "int LIBMTP_Read_Event (\fBLIBMTP_mtpdevice_t\fP * device, LIBMTP_event_t * event, uint32_t * out1)" To read events sent by the device, repeatedly call this function from a secondary thread until the return value is < 0\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the MTP device to poll for events\&. .br \fIevent\fP contains a pointer to be filled in with the event retrieved if the call is successful\&. .br \fIout1\fP contains the param1 value from the raw event\&. .RE .PP \fBReturns\fP .RS 4 0 on success, any other value means the polling loop shall be terminated immediately for this session\&. .RE .PP .PP References \fBLIBMTP_mtpdevice_struct::params\fP\&. .SS "int LIBMTP_Read_Event_Async (\fBLIBMTP_mtpdevice_t\fP * device, LIBMTP_event_cb_fn cb, void * user_data)" This function reads events sent by the device, in a non-blocking manner\&. The callback function will be called when an event is received, but for the function to make progress, polling must take place, using LIBMTP_Handle_Events_Timeout_Completed\&. .PP After an event is received, this function should be called again to listen for the next event\&. .PP For now, this non-blocking mechanism only works with libusb-1\&.0, and not any of the other usb library backends\&. Attempting to call this method with another backend will always return an error\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the MTP device to poll for events\&. .br \fIcb\fP a callback to be invoked when an event is received\&. .br \fIuser_data\fP arbitrary user data passed to the callback\&. .RE .PP \fBReturns\fP .RS 4 0 on success, any other value means that the callback was not registered and no event notification will take place\&. .RE .PP .PP References \fBLIBMTP_mtpdevice_struct::params\fP\&. .SS "int LIBMTP_Send_File_From_File (\fBLIBMTP_mtpdevice_t\fP * device, char const *const path, \fBLIBMTP_file_t\fP *const filedata, \fBLIBMTP_progressfunc_t\fP const callback, void const *const data)" This function sends a local file to an MTP device\&. A filename and a set of metadata must be given as input\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device to send the track to\&. .br \fIpath\fP the filename of a local file which will be sent\&. .br \fIfiledata\fP a file metadata set to be written along with the file\&. After this call the field \fCfiledata->item_id\fP will contain the new file ID\&. Other fields such as the \fCfiledata->filename\fP, \fCfiledata->parent_id\fP or \fCfiledata->storage_id\fP may also change during this operation due to device restrictions, so do not rely on the contents of this struct to be preserved in any way\&. .PD 0 .IP "\(bu" 2 \fCfiledata->parent_id\fP should be set to the parent (e\&.g\&. folder) to store this file in\&. If this is 0, the file will be stored in the root folder\&. .IP "\(bu" 2 \fCfiledata->storage_id\fP should be set to the desired storage (e\&.g\&. memory card or whatever your device presents) to store this file in\&. Setting this to 0 will store the file on the primary storage\&. .PP .br \fIcallback\fP a progress indicator function or NULL to ignore\&. .br \fIdata\fP a user-defined pointer that is passed along to the \fCprogress\fP function in order to pass along some user defined data to the progress updates\&. If not used, set this to NULL\&. .RE .PP \fBReturns\fP .RS 4 0 if the transfer was successful, any other value means failure\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_Send_File_From_File_Descriptor()\fP .PP \fBLIBMTP_Delete_Object()\fP .RE .PP .PP References \fBLIBMTP_Send_File_From_File_Descriptor()\fP\&. .SS "int LIBMTP_Send_File_From_File_Descriptor (\fBLIBMTP_mtpdevice_t\fP * device, int const fd, \fBLIBMTP_file_t\fP *const filedata, \fBLIBMTP_progressfunc_t\fP const callback, void const *const data)" This function sends a generic file from a file descriptor to an MTP device\&. A filename and a set of metadata must be given as input\&. .PP This can potentially be used for sending in a stream of unknown length\&. Send music files with \fC\fBLIBMTP_Send_Track_From_File_Descriptor()\fP\fP .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device to send the file to\&. .br \fIfd\fP the filedescriptor for a local file which will be sent\&. .br \fIfiledata\fP a file metadata set to be written along with the file\&. After this call the field \fCfiledata->item_id\fP will contain the new file ID\&. Other fields such as the \fCfiledata->filename\fP, \fCfiledata->parent_id\fP or \fCfiledata->storage_id\fP may also change during this operation due to device restrictions, so do not rely on the contents of this struct to be preserved in any way\&. .PD 0 .IP "\(bu" 2 \fCfiledata->parent_id\fP should be set to the parent (e\&.g\&. folder) to store this file in\&. If this is 0, the file will be stored in the root folder\&. .IP "\(bu" 2 \fCfiledata->storage_id\fP should be set to the desired storage (e\&.g\&. memory card or whatever your device presents) to store this file in\&. Setting this to 0 will store the file on the primary storage\&. .PP .br \fIcallback\fP a progress indicator function or NULL to ignore\&. .br \fIdata\fP a user-defined pointer that is passed along to the \fCprogress\fP function in order to pass along some user defined data to the progress updates\&. If not used, set this to NULL\&. .RE .PP \fBReturns\fP .RS 4 0 if the transfer was successful, any other value means failure\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_Send_File_From_File()\fP .PP \fBLIBMTP_Send_Track_From_File_Descriptor()\fP .PP \fBLIBMTP_Delete_Object()\fP .RE .PP .PP References \fB_PTP_USB::callback_active\fP, \fBLIBMTP_file_struct::filesize\fP, \fBLIBMTP_file_struct::item_id\fP, \fBLIBMTP_destroy_file_t()\fP, \fBLIBMTP_Get_Filemetadata()\fP, \fBLIBMTP_mtpdevice_struct::params\fP, \fBLIBMTP_file_struct::parent_id\fP, \fBLIBMTP_file_struct::storage_id\fP, and \fBLIBMTP_mtpdevice_struct::usbinfo\fP\&. .PP Referenced by \fBLIBMTP_Send_File_From_File()\fP, and \fBLIBMTP_Send_Track_From_File_Descriptor()\fP\&. .SS "int LIBMTP_Send_File_From_Handler (\fBLIBMTP_mtpdevice_t\fP * device, \fBMTPDataGetFunc\fP get_func, void * priv, \fBLIBMTP_file_t\fP *const filedata, \fBLIBMTP_progressfunc_t\fP const callback, void const *const data)" This function sends a generic file from a handler function to an MTP device\&. A filename and a set of metadata must be given as input\&. .PP This can potentially be used for sending in a stream of unknown length\&. Send music files with \fC\fBLIBMTP_Send_Track_From_Handler()\fP\fP .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device to send the file to\&. .br \fIget_func\fP the function to call to get data to write .br \fIpriv\fP a user-defined pointer that is passed along to \fCget_func\fP\&. If not used, this is set to NULL\&. .br \fIfiledata\fP a file metadata set to be written along with the file\&. After this call the field \fCfiledata->item_id\fP will contain the new file ID\&. Other fields such as the \fCfiledata->filename\fP, \fCfiledata->parent_id\fP or \fCfiledata->storage_id\fP may also change during this operation due to device restrictions, so do not rely on the contents of this struct to be preserved in any way\&. .PD 0 .IP "\(bu" 2 \fCfiledata->parent_id\fP should be set to the parent (e\&.g\&. folder) to store this file in\&. If this is 0, the file will be stored in the root folder\&. .IP "\(bu" 2 \fCfiledata->storage_id\fP should be set to the desired storage (e\&.g\&. memory card or whatever your device presents) to store this file in\&. Setting this to 0 will store the file on the primary storage\&. .PP .br \fIcallback\fP a progress indicator function or NULL to ignore\&. .br \fIdata\fP a user-defined pointer that is passed along to the \fCprogress\fP function in order to pass along some user defined data to the progress updates\&. If not used, set this to NULL\&. .RE .PP \fBReturns\fP .RS 4 0 if the transfer was successful, any other value means failure\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_Send_File_From_File()\fP .PP \fBLIBMTP_Send_Track_From_File_Descriptor()\fP .PP \fBLIBMTP_Delete_Object()\fP .RE .PP .PP References \fB_PTP_USB::callback_active\fP, \fBLIBMTP_file_struct::filesize\fP, \fBLIBMTP_file_struct::item_id\fP, \fBLIBMTP_destroy_file_t()\fP, \fBLIBMTP_Get_Filemetadata()\fP, \fBLIBMTP_mtpdevice_struct::params\fP, \fBLIBMTP_file_struct::parent_id\fP, \fBLIBMTP_file_struct::storage_id\fP, and \fBLIBMTP_mtpdevice_struct::usbinfo\fP\&. .PP Referenced by \fBLIBMTP_Send_Track_From_Handler()\fP\&. .SS "int LIBMTP_Send_Representative_Sample (\fBLIBMTP_mtpdevice_t\fP * device, uint32_t const id, \fBLIBMTP_filesampledata_t\fP * sampledata)" This routine sends representative sample data for an object\&. This uses the RepresentativeSampleData property of the album, if the device supports it\&. The data should be of a format acceptable to the player (for iRiver and Creative, this seems to be JPEG) and must not be too large\&. (for a Creative, max seems to be about 20KB\&.) Check by calling \fBLIBMTP_Get_Representative_Sample_Format()\fP to get maximum size, dimensions, etc\&.\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device which the object is on\&. .br \fIid\fP unique id of the object to set artwork for\&. .br \fIsampledata\fP pointer to LIBMTP_filesampledata_t struct containing data .RE .PP \fBReturns\fP .RS 4 0 on success, any other value means failure\&. .RE .PP \fBSee also\fP .RS 4 \fBLIBMTP_Get_Representative_Sample()\fP .PP \fBLIBMTP_Get_Representative_Sample_Format()\fP .PP \fBLIBMTP_Create_New_Album()\fP .RE .PP .PP References \fBLIBMTP_filesampledata_struct::data\fP, \fBLIBMTP_filesampledata_struct::duration\fP, \fBLIBMTP_filesampledata_struct::filetype\fP, \fBLIBMTP_filesampledata_struct::height\fP, \fBLIBMTP_mtpdevice_struct::params\fP, \fBLIBMTP_filesampledata_struct::size\fP, \fBLIBMTP_mtpdevice_struct::usbinfo\fP, and \fBLIBMTP_filesampledata_struct::width\fP\&. .SS "int LIBMTP_Set_File_Name (\fBLIBMTP_mtpdevice_t\fP * device, \fBLIBMTP_file_t\fP * file, const char * newname)" This function renames a single file\&. This simply means that the PTP_OPC_ObjectFileName property is updated, if this is supported by the device\&. .PP \fBParameters\fP .RS 4 \fIdevice\fP a pointer to the device that contains the file\&. .br \fIfile\fP the file metadata of the file to rename\&. On success, the filename member is updated\&. Be aware, that this name can be different than newname depending of device restrictions\&. .br \fInewname\fP the new filename for this object\&. .RE .PP \fBReturns\fP .RS 4 0 on success, any other value means failure\&. .RE .PP .PP References \fBLIBMTP_file_struct::filename\fP, \fBLIBMTP_file_struct::filetype\fP, and \fBLIBMTP_file_struct::item_id\fP\&. .SH "Author" .PP Generated automatically by Doxygen for libmtp from the source code\&.