libgphoto2 photo camera library (libgphoto2) API 2.5.34

Loading...
Searching...
No Matches
gphoto2-file.h
Go to the documentation of this file.
1
25
26#ifndef LIBGPHOTO2_GPHOTO2_FILE_H
27#define LIBGPHOTO2_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_QTKN "image/qtkn"
47#define GP_MIME_QTKT "image/qtkt"
48#define GP_MIME_QUICKTIME "video/quicktime"
49#define GP_MIME_AVI "video/x-msvideo"
50#define GP_MIME_CRW "image/x-canon-raw"
51#define GP_MIME_CR2 "image/x-canon-cr2"
52#define GP_MIME_CR3 "image/x-canon-cr3"
53#define GP_MIME_NEF "image/x-nikon-nef"
54#define GP_MIME_UNKNOWN "application/octet-stream"
55#define GP_MIME_EXIF "application/x-exif"
56#define GP_MIME_MP3 "audio/mpeg"
57#define GP_MIME_OGG "application/ogg"
58#define GP_MIME_WMA "audio/x-wma"
59#define GP_MIME_ASF "audio/x-asf"
60#define GP_MIME_MPEG "video/mpeg"
61#define GP_MIME_AVCHD "video/mp2t"
62#define GP_MIME_MPO "video/mpo"
63#define GP_MIME_RW2 "image/x-panasonic-raw2"
64#define GP_MIME_ARW "image/x-sony-arw"
65#define GP_MIME_RAF "image/x-fuji-raf"
66#define GP_MIME_DNG "image/x-adobe-dng"
67
78 typedef enum {
79 GP_FILE_TYPE_PREVIEW,
80 GP_FILE_TYPE_NORMAL,
81 GP_FILE_TYPE_RAW,
84 GP_FILE_TYPE_AUDIO,
85 GP_FILE_TYPE_EXIF,
86 GP_FILE_TYPE_METADATA
87} CameraFileType;
88
95 typedef enum {
96 GP_FILE_ACCESSTYPE_MEMORY,
97 GP_FILE_ACCESSTYPE_FD,
98 GP_FILE_ACCESSTYPE_HANDLER
99} CameraFileAccessType;
100
101/* FIXME: api might be unstable. function return gphoto results codes. */
102 typedef struct _CameraFileHandler {
103 int (*size) (void*priv, uint64_t *size); /* only for read? */
104 int (*read) (void*priv, unsigned char *data, uint64_t *len);
105 int (*write) (void*priv, unsigned char *data, uint64_t *len);
106 /* FIXME: should we have both read/write methods? */
107 /* FIXME: how to finish method, due to LRU it might be longlived. */
108} CameraFileHandler;
109
116 typedef struct _CameraFile CameraFile;
117
118 int gp_file_new (CameraFile **file);
119 int gp_file_new_from_fd (CameraFile **file, int fd);
120 int gp_file_new_from_handler (CameraFile **file, CameraFileHandler *handler, void*priv);
121 int gp_file_ref (CameraFile *file);
122 int gp_file_unref (CameraFile *file);
123 int gp_file_free (CameraFile *file);
124
125 int gp_file_set_name (CameraFile *file, const char *name);
126 int gp_file_get_name (CameraFile *file, const char **name);
127
128 int gp_file_set_mime_type (CameraFile *file, const char *mime_type);
129 int gp_file_get_mime_type (CameraFile *file, const char **mime_type);
130
131 int gp_file_set_mtime (CameraFile *file, time_t mtime);
132 int gp_file_get_mtime (CameraFile *file, time_t *mtime);
133
134 int gp_file_detect_mime_type (CameraFile *file);
135 int gp_file_adjust_name_for_mime_type (CameraFile *file);
136 int gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType type, char **newname);
137
138 int gp_file_set_data_and_size (CameraFile*, char *data,
139 unsigned long int size);
140 int gp_file_get_data_and_size (CameraFile*, const char **data,
141 unsigned long int *size);
142/* "Do not use those"
143 *
144 * These functions probably were originally intended for internal use only.
145 * However, due to
146 * - the lack of good documentation
147 * - this being the obvious way to save a file
148 * - the fact that libgphoto2 has been exporting all its internal
149 * symbols for years (until 2005-06)
150 * - our in-house frontends gphoto2 and gtkam using them
151 * a number of external frontends started to use these functions, as
152 * of 2005-06:
153 * - digikam
154 * - f-spot
155 * - gthumb
156 * But a few frontends can live without it (and thus are likely to
157 * use the correct API):
158 * - flphoto
159 * - kamera
160 *
161 * So we're going to phase these functions out over the next year or
162 * so, going the GTK way of keeping the ABI but breaking the API. So
163 * we'll continue to export functionally equivalent functions, but the
164 * header files will not contain definitions for you to use any more.
165 */
166 int gp_file_open (CameraFile *file, const char *filename);
167 int gp_file_save (CameraFile *file, const char *filename);
168 int gp_file_clean (CameraFile *file);
169 int gp_file_copy (CameraFile *destination, CameraFile *source);
170
171
172/* These are for use by camera drivers only */
173 int gp_file_append (CameraFile*, const char *data,
174 unsigned long int size);
175 int gp_file_slurp (CameraFile*, char *data,
176 size_t size, size_t *readlen);
177
178#ifdef __cplusplus
179}
180#endif /* __cplusplus */
181
182#endif /* !defined(LIBGPHOTO2_GPHOTO2_FILE_H) */
gp_file_new_from_fd
int gp_file_new_from_fd(CameraFile **file, int fd)
Definition gphoto2-file.c:108
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:401
gp_file_get_mime_type
int gp_file_get_mime_type(CameraFile *file, const char **mime_type)
Definition gphoto2-file.c:988
gp_file_save
int gp_file_save(CameraFile *file, const char *filename)
Definition gphoto2-file.c:489
gp_file_get_name
int gp_file_get_name(CameraFile *file, const char **name)
Definition gphoto2-file.c:882
gp_file_slurp
int gp_file_slurp(CameraFile *, char *data, size_t size, size_t *readlen)
Definition gphoto2-file.c:257
gp_file_clean
int gp_file_clean(CameraFile *file)
Definition gphoto2-file.c:708
gp_file_adjust_name_for_mime_type
int gp_file_adjust_name_for_mime_type(CameraFile *file)
Definition gphoto2-file.c:1092
gp_file_open
int gp_file_open(CameraFile *file, const char *filename)
Definition gphoto2-file.c:611
gp_file_new_from_handler
int gp_file_new_from_handler(CameraFile **file, CameraFileHandler *handler, void *priv)
Definition gphoto2-file.c:129
gp_file_copy
int gp_file_copy(CameraFile *destination, CameraFile *source)
Definition gphoto2-file.c:738
gp_file_unref
int gp_file_unref(CameraFile *file)
Decrease reference counter for CameraFile object.
Definition gphoto2-file.c:187
gp_file_set_data_and_size
int gp_file_set_data_and_size(CameraFile *, char *data, unsigned long int size)
Definition gphoto2-file.c:316
gp_file_set_mime_type
int gp_file_set_mime_type(CameraFile *file, const char *mime_type)
Definition gphoto2-file.c:1022
gp_file_set_name
int gp_file_set_name(CameraFile *file, const char *name)
Definition gphoto2-file.c:1005
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:908
CameraFileType
CameraFileType
The type of view on the specified file.
Definition gphoto2-file.h:78
GP_FILE_TYPE_PREVIEW
@ GP_FILE_TYPE_PREVIEW
Definition gphoto2-file.h:79
GP_FILE_TYPE_METADATA
@ GP_FILE_TYPE_METADATA
Definition gphoto2-file.h:86
GP_FILE_TYPE_AUDIO
@ GP_FILE_TYPE_AUDIO
Definition gphoto2-file.h:84
GP_FILE_TYPE_NORMAL
@ GP_FILE_TYPE_NORMAL
Definition gphoto2-file.h:80
GP_FILE_TYPE_EXIF
@ GP_FILE_TYPE_EXIF
Definition gphoto2-file.h:85
GP_FILE_TYPE_RAW
@ GP_FILE_TYPE_RAW
Definition gphoto2-file.h:81
gp_file_get_mtime
int gp_file_get_mtime(CameraFile *file, time_t *mtime)
Definition gphoto2-file.c:1145
gp_file_free
int gp_file_free(CameraFile *file)
descruct a CameraFile object.
Definition gphoto2-file.c:150
gp_file_detect_mime_type
int gp_file_detect_mime_type(CameraFile *file)
Definition gphoto2-file.c:1038
gp_file_ref
int gp_file_ref(CameraFile *file)
Increase reference counter for CameraFile object.
Definition gphoto2-file.c:170
gp_file_set_mtime
int gp_file_set_mtime(CameraFile *file, time_t mtime)
Definition gphoto2-file.c:1162
CameraFileAccessType
CameraFileAccessType
File storage type.
Definition gphoto2-file.h:95
GP_FILE_ACCESSTYPE_FD
@ GP_FILE_ACCESSTYPE_FD
Definition gphoto2-file.h:97
GP_FILE_ACCESSTYPE_MEMORY
@ GP_FILE_ACCESSTYPE_MEMORY
Definition gphoto2-file.h:96
GP_FILE_ACCESSTYPE_HANDLER
@ GP_FILE_ACCESSTYPE_HANDLER
Definition gphoto2-file.h:98
gp_file_new
int gp_file_new(CameraFile **file)
Definition gphoto2-file.c:86
gp_file_append
int gp_file_append(CameraFile *, const char *data, unsigned long int size)
Definition gphoto2-file.c:208
CameraFile
File structure.
_CameraFileHandler
Definition gphoto2-file.h:102
_CameraFile
Definition gphoto2-file.c:58