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