2001-12-04 Lutz M�ller <urc8@rz.uni-karlsruhe.de>
* libgphoto2: Support for GP_FILE_TYPE_EXIF. Not that there is not
support for it in the frontends (yet).
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@3380 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
2001-12-04 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
|
||||
* libgphoto2: Support for GP_FILE_TYPE_EXIF. Not that there is not
|
||||
support for it in the frontends (yet).
|
||||
|
||||
2001-12-04 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
|
||||
* libgphoto2/gphoto2-camera.c: Don't exit the camera if it is
|
||||
|
||||
@@ -115,7 +115,8 @@ static int localization_file_read (Camera* camera, const char* file_name,
|
||||
unsigned char** data, long int* data_size);
|
||||
|
||||
static int
|
||||
get_info (Camera *camera, unsigned int n, CameraFileInfo *info)
|
||||
get_info (Camera *camera, unsigned int n, CameraFileInfo *info,
|
||||
CameraFile *file)
|
||||
{
|
||||
unsigned long image_id;
|
||||
unsigned int buffer_size, exif_size;
|
||||
@@ -126,7 +127,6 @@ get_info (Camera *camera, unsigned int n, CameraFileInfo *info)
|
||||
CHECK (camera, k_get_image_information (camera->port,
|
||||
camera->pl->image_id_long, n, &image_id, &exif_size, &protected,
|
||||
&buffer, &buffer_size));
|
||||
free (buffer);
|
||||
|
||||
info->audio.fields = GP_FILE_INFO_NONE;
|
||||
|
||||
@@ -143,6 +143,19 @@ get_info (Camera *camera, unsigned int n, CameraFileInfo *info)
|
||||
snprintf (info->file.name, sizeof (info->file.name),
|
||||
"%06i.jpeg", (int) image_id);
|
||||
|
||||
if (file) {
|
||||
gp_file_set_type (file, GP_FILE_TYPE_EXIF);
|
||||
gp_file_set_name (file, info->file.name);
|
||||
|
||||
/* Make a JPEG file out of it (for parser) */
|
||||
gp_file_append (file, "\xff\xd8", 2);
|
||||
gp_file_append (file, buffer, buffer_size);
|
||||
gp_file_append (file, "\x01", 1);
|
||||
gp_file_append (file, "\xff\xda", 2);
|
||||
gp_file_append (file, "\x00\x02", 2);
|
||||
}
|
||||
free (buffer);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
@@ -150,10 +163,12 @@ static int
|
||||
file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
|
||||
void *data)
|
||||
{
|
||||
CameraFile *file;
|
||||
CameraFileInfo info;
|
||||
KStatus status;
|
||||
unsigned int i;
|
||||
Camera *camera = data;
|
||||
int result;
|
||||
|
||||
/*
|
||||
* We can't get the filename from the camera.
|
||||
@@ -164,7 +179,12 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
|
||||
for (i = 0; i < status.pictures; i++) {
|
||||
|
||||
/* Get information */
|
||||
CHECK (camera, get_info (camera, i + 1, &info));
|
||||
gp_file_new (&file);
|
||||
result = get_info (camera, i + 1, &info, file);
|
||||
if (result < 0) {
|
||||
gp_file_unref (file);
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Append directly to the filesystem instead of to the list,
|
||||
@@ -172,6 +192,8 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
|
||||
*/
|
||||
gp_filesystem_append (camera->fs, folder, info.file.name);
|
||||
gp_filesystem_set_info_noop (camera->fs, folder, info);
|
||||
gp_filesystem_set_file_noop (camera->fs, folder, file);
|
||||
gp_file_unref (file);
|
||||
}
|
||||
|
||||
return (GP_OK);
|
||||
@@ -352,13 +374,23 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
|
||||
CameraFileInfo *info, void *data)
|
||||
{
|
||||
Camera *camera = data;
|
||||
int n;
|
||||
CameraFile *file;
|
||||
int n, result;
|
||||
|
||||
/* We need image numbers starting with 1 */
|
||||
CHECK (camera, n = gp_filesystem_number (camera->fs, folder, filename));
|
||||
n = gp_filesystem_number (camera->fs, folder, filename);
|
||||
if (n < 0)
|
||||
return (n);
|
||||
n++;
|
||||
|
||||
CHECK (camera, get_info (camera, n, info));
|
||||
gp_file_new (&file);
|
||||
result = get_info (camera, n, info, file);
|
||||
if (result < 0) {
|
||||
gp_file_unref (file);
|
||||
return (result);
|
||||
}
|
||||
gp_filesystem_set_file_noop (fs, folder, file);
|
||||
gp_file_unref (file);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ typedef enum {
|
||||
GP_FILE_TYPE_PREVIEW,
|
||||
GP_FILE_TYPE_NORMAL,
|
||||
GP_FILE_TYPE_RAW,
|
||||
GP_FILE_TYPE_AUDIO
|
||||
GP_FILE_TYPE_AUDIO,
|
||||
GP_FILE_TYPE_EXIF
|
||||
} CameraFileType;
|
||||
|
||||
/* Internals are private */
|
||||
|
||||
@@ -58,6 +58,7 @@ typedef struct {
|
||||
CameraFile *normal;
|
||||
CameraFile *raw;
|
||||
CameraFile *audio;
|
||||
CameraFile *exif;
|
||||
} CameraFilesystemFile;
|
||||
|
||||
typedef struct {
|
||||
@@ -129,6 +130,10 @@ delete_all_files (CameraFilesystem *fs, int x)
|
||||
gp_file_unref (fs->folder[x].file[y].audio);
|
||||
fs->folder[x].file[y].audio = NULL;
|
||||
}
|
||||
if (fs->folder[x].file[y].exif) {
|
||||
gp_file_unref (fs->folder[x].file[y].exif);
|
||||
fs->folder[x].file[y].exif = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
free (fs->folder[x].file);
|
||||
@@ -533,6 +538,10 @@ delete_file (CameraFilesystem *fs, int x, int y)
|
||||
gp_file_unref (fs->folder[x].file[y].audio);
|
||||
fs->folder[x].file[y].audio = NULL;
|
||||
}
|
||||
if (fs->folder[x].file[y].exif) {
|
||||
gp_file_unref (fs->folder[x].file[y].exif);
|
||||
fs->folder[x].file[y].exif = NULL;
|
||||
}
|
||||
|
||||
/* Move all files behind one position up */
|
||||
if (y < fs->folder[x].count - 1)
|
||||
@@ -1244,6 +1253,11 @@ gp_filesystem_get_file (CameraFilesystem *fs, const char *folder,
|
||||
return (gp_file_copy (file,
|
||||
fs->folder[x].file[y].audio));
|
||||
break;
|
||||
case GP_FILE_TYPE_EXIF:
|
||||
if (fs->folder[x].file[y].exif)
|
||||
return (gp_file_copy (file,
|
||||
fs->folder[x].file[y].exif));
|
||||
break;
|
||||
default:
|
||||
gp_log (GP_LOG_ERROR, "gphoto2-filesystem",
|
||||
_("Unknown file type %i"), type);
|
||||
@@ -1396,6 +1410,12 @@ gp_filesystem_set_file_noop (CameraFilesystem *fs, const char *folder,
|
||||
fs->folder[x].file[y].audio = file;
|
||||
gp_file_ref (file);
|
||||
break;
|
||||
case GP_FILE_TYPE_EXIF:
|
||||
if (fs->folder[x].file[y].exif)
|
||||
gp_file_unref (fs->folder[x].file[y].exif);
|
||||
fs->folder[x].file[y].exif = file;
|
||||
gp_file_ref (file);
|
||||
break;
|
||||
default:
|
||||
gp_log (GP_LOG_ERROR, "gphoto2-filesystem",
|
||||
_("Unknown file type %i"), type);
|
||||
|
||||
Reference in New Issue
Block a user