gphoto2-file.h

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

Generated on 19 Jun 2017 for libgphoto2 photo camera library (libgphoto2) API by  doxygen 1.6.1