#include <stdio.h>#include <stdint.h>#include <pthread.h>#include "ptp.h"#include <unistd.h>#include "cl_data.h"#include "cl_backend.h"#include "cl_ops.h"#include "cl_enum.h"#include "cl_bind.h"Go to the source code of this file.
Classes | |
| struct | PtpPropAvail |
| Linked list to handle currently possible values for a property. More... | |
| struct | PtpRuntime |
| Represents a single device connection. More... | |
| struct | PtpGenericEvent |
| Generic event / property change. More... | |
| struct | PtpEventReader |
| Stream reader state struct for struct PtpGenericEvent. More... | |
| struct | PtpCommand |
| Generic PTP command structure - accepted by operation API. More... | |
| struct | PtpArray |
| Generic Struct for arrays. More... | |
Macros | |
| #define | PTP_TIMEOUT 1000 |
| #define | PTP_WAIT_MS 1000 |
| #define | PTP_SLEEP(ms) |
| #define | PUB |
| #define | PTP_DEFAULT_SIZE 1000000 |
Enumerations | |
| enum | PtpGeneralError { PTP_OK = 0 , PTP_NO_DEVICE = -1 , PTP_NO_PERM = -2 , PTP_OPEN_FAIL = -3 , PTP_OUT_OF_MEM = -4 , PTP_IO_ERR = -5 , PTP_RUNTIME_ERR = -6 , PTP_UNSUPPORTED = -7 , PTP_CHECK_CODE = -8 , PTP_CANCELED = -9 , PTP_COMMAND_IGNORED = -10 } |
| Library errors, not PTP return codes. More... | |
| enum | PtpVendors { PTP_DEV_EMPTY = 0 , PTP_DEV_EOS = 1 , PTP_DEV_CANON = 2 , PTP_DEV_NIKON = 3 , PTP_DEV_SONY = 4 , PTP_DEV_FUJI = 5 , PTP_DEV_PANASONIC = 6 } |
| Unique camera types - each type should have similar opcodes and behavior. More... | |
| enum | ImageFormats { IMG_FORMAT_ETC = 0 , IMG_FORMAT_RAW = 1 , IMG_FORMAT_STD = 2 , IMG_FORMAT_HIGH = 3 , IMG_FORMAT_RAW_JPEG = 4 } |
| enum | PtpConnType { PTP_IP = (1 << 0) , PTP_IP_USB = (1 << 1) , PTP_USB = (1 << 2) , PTP_BLE = (1 << 3) } |
| Tells lib what backend and packet style to use. More... | |
Functions | |
| PUB void | ptp_verbose_log (char *fmt,...) |
| Verbose log debugging info, could be called dozens of times per second. | |
| PUB void | ptp_error_log (char *fmt,...) |
| Used for critical IO errors, (not runtime errors) | |
| PUB | __attribute__ ((noreturn)) void ptp_panic(char *fmt |
| Client has no way out, crash the application. | |
| PUB void | ptp_report_read_progress (unsigned int size) |
| Update UI progress on download progress. | |
| const char * | ptp_perror (int rc) |
| Evaluates PtpGeneralError into string message. | |
| PUB int | ptp_get_return_code (struct PtpRuntime *r) |
| Returns the return code (RC) currently in the data buffer. | |
| PUB unsigned int | ptp_get_param_length (struct PtpRuntime *r) |
| Get number of parameters in packet in data buffer. | |
| PUB uint32_t | ptp_get_param (struct PtpRuntime *r, int i) |
| Get parameter at index i. | |
| PUB int | ptp_get_last_transaction_id (struct PtpRuntime *r) |
| Get transaction ID of packet in the data buffer. | |
| PUB uint8_t * | ptp_get_payload (struct PtpRuntime *r) |
| Get ptr of packet payload in data buffer, after packet header. | |
| PUB unsigned int | ptp_get_payload_length (struct PtpRuntime *r) |
| Get length of payload returned by ptp_get_payload. | |
| PUB struct PtpRuntime * | ptp_new (int options) |
| Allocate new PtpRuntime based on bitfield options - see PtpConnType. | |
| PUB void | ptp_reset (struct PtpRuntime *r) |
| Resets all session-specific fields of PtpRuntime This must be called if you plan to use the same PtpRuntime between connections. | |
| PUB void | ptp_init (struct PtpRuntime *r) |
| Init PtpRuntime struct. | |
| PUB void | ptp_close (struct PtpRuntime *r) |
| Frees PtpRuntime data buffer - doesn't free the actual structure, or device info (yet) | |
| PUB int | ptp_send (struct PtpRuntime *r, struct PtpCommand *cmd) |
| Send a command request to the device with no data phase. | |
| PUB int | ptp_send_data (struct PtpRuntime *r, const struct PtpCommand *cmd, const void *data, unsigned int length) |
| Send a command request to the device with a data phase (thread safe) | |
| PUB int | ptp_get_event (struct PtpRuntime *r, struct PtpEventContainer *ec) |
| Try and get an event from the camera over int endpoint (USB-only) | |
| PUB void | ptp_mutex_unlock (struct PtpRuntime *r) |
| Unlock the IO mutex (unless it was kept locked) | |
| PUB void | ptp_mutex_unlock_thread (struct PtpRuntime *r) |
| Completely unlock the mutex for the current thread, to ensure there isn't a deadlock. This is normally used on handling errors, and when exiting a thread. | |
| PUB void | ptp_mutex_lock (struct PtpRuntime *r) |
| Lock the IO mutex - only should be used by backend. | |
| PUB int | ptp_device_type (struct PtpRuntime *r) |
| Gets type of device from r->di. | |
| PUB int | ptp_check_opcode (struct PtpRuntime *r, int opcode) |
| Check if an opcode is supported by looking through supported props in r->di. | |
| PUB int | ptp_check_prop (struct PtpRuntime *r, int code) |
| Check if a property code is supported by looking through supported props in r->di. | |
| PUB int | ptp_buffer_resize (struct PtpRuntime *r, size_t size) |
| Mostly for internal use - realloc the data buffer. | |
| PUB int | ptp_write_unicode_string (char *dat, const char *string) |
| PUB int | ptp_read_unicode_string (char *buffer, const char *dat, int max) |
| PUB int | ptp_read_utf8_string (void *dat, char *string, int max) |
| PUB int | ptp_read_string (uint8_t *dat, char *string, int max) |
| PUB int | ptp_write_string (uint8_t *dat, const char *string) |
| PUB int | ptp_write_utf8_string (void *dat, const char *string) |
| PUB int | ptp_read_uint16_array (const uint8_t *dat, uint16_t *buf, int max, int *length) |
| PUB int | ptp_read_uint16_array_s (uint8_t *bs, uint8_t *be, uint16_t *buf, int max, int *length) |
| unsigned int | ptp_new_cmd_packet (struct PtpRuntime *r, const struct PtpCommand *cmd) |
| int | ptpusb_new_data_packet (struct PtpRuntime *r, const struct PtpCommand *cmd, const void *data, unsigned int data_length) |
| unsigned int | ptpip_data_start_packet (struct PtpRuntime *r, unsigned int data_length) |
| unsigned int | ptpip_data_end_packet (struct PtpRuntime *r, const void *data, unsigned int data_length) |
| __attribute__ ((deprecated)) void ptp_update_transaction(struct PtpRuntime *r | |
| void | ptp_set_prop_avail_info (struct PtpRuntime *r, int code, unsigned int memb_size, unsigned int cnt, void *data) |
| int | ptp_dump (struct PtpRuntime *r) |
| Write r->data to a file called DUMP. | |
Variables | |
| int | t |
| #define PTP_SLEEP | ( | ms | ) |
| enum PtpConnType |
| enum PtpGeneralError |
Library errors, not PTP return codes.
| enum PtpVendors |
| PUB int ptp_buffer_resize | ( | struct PtpRuntime * | r, |
| size_t | size ) |
Mostly for internal use - realloc the data buffer.
| PUB int ptp_check_opcode | ( | struct PtpRuntime * | r, |
| int | opcode ) |
Check if an opcode is supported by looking through supported props in r->di.
| PUB int ptp_check_prop | ( | struct PtpRuntime * | r, |
| int | code ) |
Check if a property code is supported by looking through supported props in r->di.
| PUB int ptp_device_type | ( | struct PtpRuntime * | r | ) |
Gets type of device from r->di.
| int ptp_dump | ( | struct PtpRuntime * | r | ) |
Write r->data to a file called DUMP.
| PUB int ptp_get_last_transaction_id | ( | struct PtpRuntime * | r | ) |
Get transaction ID of packet in the data buffer.
| PUB uint32_t ptp_get_param | ( | struct PtpRuntime * | r, |
| int | i ) |
Get parameter at index i.
| PUB unsigned int ptp_get_param_length | ( | struct PtpRuntime * | r | ) |
Get number of parameters in packet in data buffer.
| PUB uint8_t * ptp_get_payload | ( | struct PtpRuntime * | r | ) |
Get ptr of packet payload in data buffer, after packet header.
| PUB unsigned int ptp_get_payload_length | ( | struct PtpRuntime * | r | ) |
Get length of payload returned by ptp_get_payload.
| PUB int ptp_get_return_code | ( | struct PtpRuntime * | r | ) |
Returns the return code (RC) currently in the data buffer.