libgphoto2 photo camera library (libgphoto2) API
2.5.2
|
00001 00026 #ifndef __GPHOTO2_FILE_H__ 00027 #define __GPHOTO2_FILE_H__ 00028 00029 #include <time.h> 00030 #include <stdint.h> 00031 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif /* __cplusplus */ 00035 00036 #define GP_MIME_WAV "audio/wav" 00037 #define GP_MIME_RAW "image/x-raw" 00038 #define GP_MIME_PNG "image/png" 00039 #define GP_MIME_PGM "image/x-portable-graymap" 00040 #define GP_MIME_PPM "image/x-portable-pixmap" 00041 #define GP_MIME_PNM "image/x-portable-anymap" 00042 #define GP_MIME_JPEG "image/jpeg" 00043 #define GP_MIME_TIFF "image/tiff" 00044 #define GP_MIME_BMP "image/bmp" 00045 #define GP_MIME_QUICKTIME "video/quicktime" 00046 #define GP_MIME_AVI "video/x-msvideo" 00047 #define GP_MIME_CRW "image/x-canon-raw" 00048 #define GP_MIME_CR2 "image/x-canon-cr2" 00049 #define GP_MIME_UNKNOWN "application/octet-stream" 00050 #define GP_MIME_EXIF "application/x-exif" 00051 #define GP_MIME_MP3 "audio/mpeg" 00052 #define GP_MIME_OGG "application/ogg" 00053 #define GP_MIME_WMA "audio/x-wma" 00054 #define GP_MIME_ASF "audio/x-asf" 00055 #define GP_MIME_MPEG "video/mpeg" 00056 #define GP_MIME_AVCHD "video/mp2t" 00057 #define GP_MIME_RW2 "image/x-panasonic-raw2" 00058 00069 typedef enum { 00070 GP_FILE_TYPE_PREVIEW, 00071 GP_FILE_TYPE_NORMAL, 00072 GP_FILE_TYPE_RAW, 00075 GP_FILE_TYPE_AUDIO, 00076 GP_FILE_TYPE_EXIF, 00077 GP_FILE_TYPE_METADATA 00078 } CameraFileType; 00079 00086 typedef enum { 00087 GP_FILE_ACCESSTYPE_MEMORY, 00088 GP_FILE_ACCESSTYPE_FD, 00089 GP_FILE_ACCESSTYPE_HANDLER 00090 } CameraFileAccessType; 00091 00092 /* FIXME: api might be unstable. function return gphoto results codes. */ 00093 typedef struct _CameraFileHandler { 00094 int (*size) (void*priv, uint64_t *size); /* only for read? */ 00095 int (*read) (void*priv, unsigned char *data, uint64_t *len); 00096 int (*write) (void*priv, unsigned char *data, uint64_t *len); 00097 /* FIXME: should we have both read/write methods? */ 00098 /* FIXME: how to finish method, due to LRU it might be longlived. */ 00099 } CameraFileHandler; 00100 00107 typedef struct _CameraFile CameraFile; 00108 00109 int gp_file_new (CameraFile **file); 00110 int gp_file_new_from_fd (CameraFile **file, int fd); 00111 int gp_file_new_from_handler (CameraFile **file, CameraFileHandler *handler, void*priv); 00112 int gp_file_ref (CameraFile *file); 00113 int gp_file_unref (CameraFile *file); 00114 int gp_file_free (CameraFile *file); 00115 00116 int gp_file_set_name (CameraFile *file, const char *name); 00117 int gp_file_get_name (CameraFile *file, const char **name); 00118 00119 int gp_file_set_mime_type (CameraFile *file, const char *mime_type); 00120 int gp_file_get_mime_type (CameraFile *file, const char **mime_type); 00121 00122 int gp_file_set_mtime (CameraFile *file, time_t mtime); 00123 int gp_file_get_mtime (CameraFile *file, time_t *mtime); 00124 00125 int gp_file_detect_mime_type (CameraFile *file); 00126 int gp_file_adjust_name_for_mime_type (CameraFile *file); 00127 int gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType type, char **newname); 00128 00129 int gp_file_set_data_and_size (CameraFile*, char *data, 00130 unsigned long int size); 00131 int gp_file_get_data_and_size (CameraFile*, const char **data, 00132 unsigned long int *size); 00133 /* "Do not use those" 00134 * 00135 * These functions probably were originally intended for internal use only. 00136 * However, due to 00137 * - the lack of good documentation 00138 * - this being the obvious way to save a file 00139 * - the fact that libgphoto2 has been exporting all its internal 00140 * symbols for years (until 2005-06) 00141 * - our in-house frontends gphoto2 and gtkam using them 00142 * a number of external frontends started to use these functions, as 00143 * of 2005-06: 00144 * - digikam 00145 * - f-spot 00146 * - gthumb 00147 * But a few frontends can live without it (and thus are likely to 00148 * use the correct API): 00149 * - flphoto 00150 * - kamera 00151 * 00152 * So we're going to phase these functions out over the next year or 00153 * so, going the GTK way of keeping the ABI but breaking the API. So 00154 * we'll continue to export functionally equivalent functions, but the 00155 * header files will not contain definitions for you to use any more. 00156 */ 00157 int gp_file_open (CameraFile *file, const char *filename); 00158 int gp_file_save (CameraFile *file, const char *filename); 00159 int gp_file_clean (CameraFile *file); 00160 int gp_file_copy (CameraFile *destination, CameraFile *source); 00161 00162 00163 /* These are for use by camera drivers only */ 00164 int gp_file_append (CameraFile*, const char *data, 00165 unsigned long int size); 00166 int gp_file_slurp (CameraFile*, char *data, 00167 size_t size, size_t *readlen); 00168 00169 #ifdef __cplusplus 00170 } 00171 #endif /* __cplusplus */ 00172 00173 #endif /* __GPHOTO2_FILE_H__ */