libgphoto2 photo camera library (libgphoto2) API  2.5.24
gphoto2-file.h
Go to the documentation of this file.
1 
26 #ifndef __GPHOTO2_FILE_H__
27 #define __GPHOTO2_FILE_H__
28 
29 #include <time.h>
30 #include <stdint.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35 
36 #define GP_MIME_TXT "text/plain"
37 #define GP_MIME_WAV "audio/wav"
38 #define GP_MIME_RAW "image/x-raw"
39 #define GP_MIME_PNG "image/png"
40 #define GP_MIME_PGM "image/x-portable-graymap"
41 #define GP_MIME_PPM "image/x-portable-pixmap"
42 #define GP_MIME_PNM "image/x-portable-anymap"
43 #define GP_MIME_JPEG "image/jpeg"
44 #define GP_MIME_TIFF "image/tiff"
45 #define GP_MIME_BMP "image/bmp"
46 #define GP_MIME_QUICKTIME "video/quicktime"
47 #define GP_MIME_AVI "video/x-msvideo"
48 #define GP_MIME_CRW "image/x-canon-raw"
49 #define GP_MIME_CR2 "image/x-canon-cr2"
50 #define GP_MIME_CR3 "image/x-canon-cr3"
51 #define GP_MIME_NEF "image/x-nikon-nef"
52 #define GP_MIME_UNKNOWN "application/octet-stream"
53 #define GP_MIME_EXIF "application/x-exif"
54 #define GP_MIME_MP3 "audio/mpeg"
55 #define GP_MIME_OGG "application/ogg"
56 #define GP_MIME_WMA "audio/x-wma"
57 #define GP_MIME_ASF "audio/x-asf"
58 #define GP_MIME_MPEG "video/mpeg"
59 #define GP_MIME_AVCHD "video/mp2t"
60 #define GP_MIME_RW2 "image/x-panasonic-raw2"
61 #define GP_MIME_ARW "image/x-sony-arw"
62 
73 typedef enum {
83 
90 typedef enum {
95 
96 /* FIXME: api might be unstable. function return gphoto results codes. */
97 typedef struct _CameraFileHandler {
98  int (*size) (void*priv, uint64_t *size); /* only for read? */
99  int (*read) (void*priv, unsigned char *data, uint64_t *len);
100  int (*write) (void*priv, unsigned char *data, uint64_t *len);
101  /* FIXME: should we have both read/write methods? */
102  /* FIXME: how to finish method, due to LRU it might be longlived. */
104 
111 typedef struct _CameraFile CameraFile;
112 
113 int gp_file_new (CameraFile **file);
114 int gp_file_new_from_fd (CameraFile **file, int fd);
115 int gp_file_new_from_handler (CameraFile **file, CameraFileHandler *handler, void*priv);
116 int gp_file_ref (CameraFile *file);
117 int gp_file_unref (CameraFile *file);
118 int gp_file_free (CameraFile *file);
119 
120 int gp_file_set_name (CameraFile *file, const char *name);
121 int gp_file_get_name (CameraFile *file, const char **name);
122 
123 int gp_file_set_mime_type (CameraFile *file, const char *mime_type);
124 int gp_file_get_mime_type (CameraFile *file, const char **mime_type);
125 
126 int gp_file_set_mtime (CameraFile *file, time_t mtime);
127 int gp_file_get_mtime (CameraFile *file, time_t *mtime);
128 
131 int gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType type, char **newname);
132 
133 int gp_file_set_data_and_size (CameraFile*, char *data,
134  unsigned long int size);
135 int gp_file_get_data_and_size (CameraFile*, const char **data,
136  unsigned long int *size);
137 /* "Do not use those"
138  *
139  * These functions probably were originally intended for internal use only.
140  * However, due to
141  * - the lack of good documentation
142  * - this being the obvious way to save a file
143  * - the fact that libgphoto2 has been exporting all its internal
144  * symbols for years (until 2005-06)
145  * - our in-house frontends gphoto2 and gtkam using them
146  * a number of external frontends started to use these functions, as
147  * of 2005-06:
148  * - digikam
149  * - f-spot
150  * - gthumb
151  * But a few frontends can live without it (and thus are likely to
152  * use the correct API):
153  * - flphoto
154  * - kamera
155  *
156  * So we're going to phase these functions out over the next year or
157  * so, going the GTK way of keeping the ABI but breaking the API. So
158  * we'll continue to export functionally equivalent functions, but the
159  * header files will not contain definitions for you to use any more.
160  */
161 int gp_file_open (CameraFile *file, const char *filename);
162 int gp_file_save (CameraFile *file, const char *filename);
163 int gp_file_clean (CameraFile *file);
164 int gp_file_copy (CameraFile *destination, CameraFile *source);
165 
166 
167 /* These are for use by camera drivers only */
168 int gp_file_append (CameraFile*, const char *data,
169  unsigned long int size);
170 int gp_file_slurp (CameraFile*, char *data,
171  size_t size, size_t *readlen);
172 
173 #ifdef __cplusplus
174 }
175 #endif /* __cplusplus */
176 
177 #endif /* __GPHOTO2_FILE_H__ */
gp_file_detect_mime_type
int gp_file_detect_mime_type(CameraFile *file)
Definition: gphoto2-file.c:1029
gp_file_new_from_fd
int gp_file_new_from_fd(CameraFile **file, int fd)
Definition: gphoto2-file.c:105
_CameraFile
Definition: gphoto2-file.c:55
CameraFile
File structure.
GP_FILE_TYPE_PREVIEW
@ GP_FILE_TYPE_PREVIEW
Definition: gphoto2-file.h:74
gp_file_save
int gp_file_save(CameraFile *file, const char *filename)
Definition: gphoto2-file.c:486
CameraFileType
CameraFileType
The type of view on the specified file.
Definition: gphoto2-file.h:73
GP_FILE_ACCESSTYPE_MEMORY
@ GP_FILE_ACCESSTYPE_MEMORY
Definition: gphoto2-file.h:91
gp_file_get_mime_type
int gp_file_get_mime_type(CameraFile *file, const char **mime_type)
Definition: gphoto2-file.c:979
GP_FILE_TYPE_NORMAL
@ GP_FILE_TYPE_NORMAL
Definition: gphoto2-file.h:75
gp_file_slurp
int gp_file_slurp(CameraFile *, char *data, size_t size, size_t *readlen)
Definition: gphoto2-file.c:254
gp_file_get_name_by_type
int gp_file_get_name_by_type(CameraFile *file, const char *basename, CameraFileType type, char **newname)
Definition: gphoto2-file.c:899
_CameraFileHandler
Definition: gphoto2-file.h:97
GP_FILE_TYPE_RAW
@ GP_FILE_TYPE_RAW
Definition: gphoto2-file.h:76
gp_file_set_mime_type
int gp_file_set_mime_type(CameraFile *file, const char *mime_type)
Definition: gphoto2-file.c:1013
gp_file_copy
int gp_file_copy(CameraFile *destination, CameraFile *source)
Definition: gphoto2-file.c:729
gp_file_set_data_and_size
int gp_file_set_data_and_size(CameraFile *, char *data, unsigned long int size)
Definition: gphoto2-file.c:313
gp_file_open
int gp_file_open(CameraFile *file, const char *filename)
Definition: gphoto2-file.c:603
GP_FILE_TYPE_EXIF
@ GP_FILE_TYPE_EXIF
Definition: gphoto2-file.h:80
gp_file_new_from_handler
int gp_file_new_from_handler(CameraFile **file, CameraFileHandler *handler, void *priv)
Definition: gphoto2-file.c:126
gp_file_adjust_name_for_mime_type
int gp_file_adjust_name_for_mime_type(CameraFile *file)
Definition: gphoto2-file.c:1083
gp_file_get_mtime
int gp_file_get_mtime(CameraFile *file, time_t *mtime)
Definition: gphoto2-file.c:1130
gp_file_free
int gp_file_free(CameraFile *file)
descruct a CameraFile object.
Definition: gphoto2-file.c:147
GP_FILE_TYPE_AUDIO
@ GP_FILE_TYPE_AUDIO
Definition: gphoto2-file.h:79
gp_file_ref
int gp_file_ref(CameraFile *file)
Increase reference counter for CameraFile object.
Definition: gphoto2-file.c:167
gp_file_clean
int gp_file_clean(CameraFile *file)
Definition: gphoto2-file.c:699
gp_file_unref
int gp_file_unref(CameraFile *file)
Decrease reference counter for CameraFile object.
Definition: gphoto2-file.c:184
GP_FILE_ACCESSTYPE_HANDLER
@ GP_FILE_ACCESSTYPE_HANDLER
Definition: gphoto2-file.h:93
gp_file_new
int gp_file_new(CameraFile **file)
Definition: gphoto2-file.c:83
CameraFileAccessType
CameraFileAccessType
File storage type.
Definition: gphoto2-file.h:90
GP_FILE_TYPE_METADATA
@ GP_FILE_TYPE_METADATA
Definition: gphoto2-file.h:81
gp_file_get_name
int gp_file_get_name(CameraFile *file, const char **name)
Definition: gphoto2-file.c:873
gp_file_set_name
int gp_file_set_name(CameraFile *file, const char *name)
Definition: gphoto2-file.c:996
gp_file_get_data_and_size
int gp_file_get_data_and_size(CameraFile *, const char **data, unsigned long int *size)
Definition: gphoto2-file.c:398
gp_file_append
int gp_file_append(CameraFile *, const char *data, unsigned long int size)
Definition: gphoto2-file.c:205
gp_file_set_mtime
int gp_file_set_mtime(CameraFile *file, time_t mtime)
Definition: gphoto2-file.c:1147
GP_FILE_ACCESSTYPE_FD
@ GP_FILE_ACCESSTYPE_FD
Definition: gphoto2-file.h:92