camlib
Documentation for camlib is still a work-in-progress
Loading...
Searching...
No Matches
camlib.h File Reference
#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  PtpCommand
 Generic PTP command structure - accepted by operation API. More...
 
struct  PtpArray
 Generic Struct for arrays. More...
 

Macros

#define PTP_TIMEOUT   1000
 
#define CAMLIB_WAIT_MS   1000
 
#define CAMLIB_SLEEP(ms)
 
#define PUB
 
#define CAMLIB_DEFAULT_SIZE   1000000
 
#define CAMLIB_INCLUDE_IMPL
 
#define ptp_get_last_transaction(...)
 
#define ptp_generic_new(...)
 
#define ptp_generic_close(...)
 
#define ptp_generic_reset(...)
 
#define ptp_generic_init(...)
 
#define ptp_generic_send(...)
 
#define ptp_generic_send_data(...)
 

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
}
 Camlib 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.
 
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

void ptp_verbose_log (char *fmt,...)
 
 __attribute__ ((noreturn)) void ptp_panic(char *fmt
 
const char * ptp_perror (int rc)
 Evaluates PtpGeneralError into string message.
 
PUB int ptp_write_unicode_string (char *dat, const char *string)
 
PUB int ptp_read_unicode_string (char *buffer, 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)
 
int ptp_new_cmd_packet (struct PtpRuntime *r, struct PtpCommand *cmd)
 
int ptp_new_data_packet (struct PtpRuntime *r, struct PtpCommand *cmd, void *data, int data_length)
 
int ptpip_data_start_packet (struct PtpRuntime *r, int data_length)
 
int ptpip_data_end_packet (struct PtpRuntime *r, void *data, int data_length)
 
void ptp_update_transaction (struct PtpRuntime *r, int t)
 
void ptp_set_prop_avail_info (struct PtpRuntime *r, int code, int memb_size, int cnt, void *data)
 
void * ptp_dup_payload (struct PtpRuntime *r)
 
int ptp_dump (struct PtpRuntime *r)
 Write r->data to a file called DUMP.
 

Macro Definition Documentation

◆ CAMLIB_SLEEP

#define CAMLIB_SLEEP ( ms)
Value:
usleep(ms * 1000)

◆ ptp_generic_close

#define ptp_generic_close ( ...)
Value:
ptp_close(__VA_ARGS__)

◆ ptp_generic_init

#define ptp_generic_init ( ...)
Value:
ptp_init(__VA_ARGS__)

◆ ptp_generic_new

#define ptp_generic_new ( ...)
Value:
ptp_new(__VA_ARGS__)

◆ ptp_generic_reset

#define ptp_generic_reset ( ...)
Value:
ptp_reset(__VA_ARGS__)

◆ ptp_generic_send

#define ptp_generic_send ( ...)
Value:
ptp_send(__VA_ARGS__)

◆ ptp_generic_send_data

#define ptp_generic_send_data ( ...)
Value:
ptp_send_data(__VA_ARGS__)

◆ ptp_get_last_transaction

#define ptp_get_last_transaction ( ...)
Value:
ptp_get_last_transaction_id(__VA_ARGS__)

Enumeration Type Documentation

◆ PtpConnType

Tells lib what backend and packet style to use.

Note
This is a bitmask so that it can be passed to ptp_new with other options.

◆ PtpGeneralError

Camlib library errors, not PTP return codes.

Enumerator
PTP_NO_DEVICE 

No device found (USB)

PTP_NO_PERM 

EPERM or other permission denied error.

PTP_OPEN_FAIL 

Found device, but failed to connect.

PTP_OUT_OF_MEM 

malloc failed

PTP_IO_ERR 

General IO or communication error.

PTP_RUNTIME_ERR 

Unexpected, unhandled, or illegal behavior.

PTP_UNSUPPORTED 

Operation or functionality isn't implemented or supported.

PTP_CHECK_CODE 

response code is not PTP_RC_OK

PTP_CANCELED 

Operation (such as download) was canceled by another thread.

PTP_COMMAND_IGNORED 

No response.

Note
Used internally only

Function Documentation

◆ ptp_dump()

int ptp_dump ( struct PtpRuntime * r)

Write r->data to a file called DUMP.

Note
Debugging only