summaryrefslogtreecommitdiff
path: root/camlibs/sonydscf55
diff options
context:
space:
mode:
authorRaymond Penners <raymond@dotsphinx.com>2004-05-13 20:10:34 +0000
committerRaymond Penners <raymond@dotsphinx.com>2004-05-13 20:10:34 +0000
commitee4bc1f1322fed81500ed7ff41809f7163d86d8c (patch)
treef838bd2ec116f92d1b5883fe496b1fe813620f5a /camlibs/sonydscf55
parenta6a8ca822171ec0a1f5c58e0edd23b72f7103e37 (diff)
downloadlibgphoto2-ee4bc1f1322fed81500ed7ff41809f7163d86d8c.tar.gz
Merged in Sony DSC-F55 patches from Alberto Garlassi: added support for downloading MPEG files, and fixed thumbnail downloading.
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@7201 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/sonydscf55')
-rw-r--r--camlibs/sonydscf55/ChangeLog6
-rw-r--r--camlibs/sonydscf55/TODO6
-rw-r--r--camlibs/sonydscf55/camera.c230
-rw-r--r--camlibs/sonydscf55/sony.c215
-rw-r--r--camlibs/sonydscf55/sony.h37
5 files changed, 358 insertions, 136 deletions
diff --git a/camlibs/sonydscf55/ChangeLog b/camlibs/sonydscf55/ChangeLog
index a8cfe5be1..603a1491c 100644
--- a/camlibs/sonydscf55/ChangeLog
+++ b/camlibs/sonydscf55/ChangeLog
@@ -1,3 +1,9 @@
+2004-05-13 Raymond Penners <raymond@dotsphinx.com>
+
+ * *.[ch]: Merged in Sony DSC-F55 patches from Alberto Garlassi:
+ added support for downloading MPEG files, and fixed thumbnail
+ downloading.
+
2004-04-08 Raymond Penners <raymond@dotsphinx.com>
* *.[ch]: Merged in patch from Alberto Garlassi: serial
diff --git a/camlibs/sonydscf55/TODO b/camlibs/sonydscf55/TODO
index 62c91f196..a434b6602 100644
--- a/camlibs/sonydscf55/TODO
+++ b/camlibs/sonydscf55/TODO
@@ -1,9 +1,3 @@
-* The original 0.4 driver contained code for downloading MPEG files.
-Unfortunately, that code did not work correctly when using an Sony
-MSAC-SR1 in combination with memory sticks from a Sony DCR-PC100. In this
-case, when the device is queried for a list of MPEG files it lists the
-JPEG still images. For now, the MPEG code has been left out.
-
* Fix all FIXME's
* Add calls to gp_frontend_status()
diff --git a/camlibs/sonydscf55/camera.c b/camlibs/sonydscf55/camera.c
index 5c20854b6..e519aaef7 100644
--- a/camlibs/sonydscf55/camera.c
+++ b/camlibs/sonydscf55/camera.c
@@ -31,26 +31,34 @@
#define GP_MODULE "sonydscf55"
-int camera_id(CameraText * id)
+struct ModelInfo {
+ SonyModel model_id;
+ const char *model_str;
+};
+
+static struct ModelInfo models[] = {
+ { SONY_MODEL_MSAC_SR1, "Sony:MSAC-SR1" },
+ { SONY_MODEL_DCR_PC100, "Sony:DCR-PC100" },
+ { SONY_MODEL_TRV_20E, "Sony:TRV-20E" },
+ { SONY_MODEL_DSC_F55, "Sony:DSC-F55" }
+};
+
+int
+camera_id(CameraText * id)
{
strcpy(id->text, SONY_CAMERA_ID);
return (GP_OK);
}
-int camera_abilities(CameraAbilitiesList * list)
+int
+camera_abilities(CameraAbilitiesList * list)
{
- static const char *models[] = {
- SONY_MODEL_DSC_F55,
- SONY_MODEL_MSAC_SR1,
- SONY_MODEL_TRV_20E,
- SONY_MODEL_DCR_PC100
- };
int i;
CameraAbilities a;
for (i = 0; i < sizeof(models) / sizeof(models[i]); i++) {
memset(&a, 0, sizeof(a));
- strcpy(a.model, models[i]);
+ strcpy(a.model, models[i].model_str);
a.status = GP_DRIVER_STATUS_PRODUCTION;
a.port = GP_PORT_SERIAL;
a.speed[0] = 0;
@@ -66,7 +74,8 @@ int camera_abilities(CameraAbilitiesList * list)
/**
* De-initialises camera
*/
-static int camera_exit(Camera * camera, GPContext *context)
+static int
+camera_exit(Camera * camera, GPContext *context)
{
int rc;
@@ -86,7 +95,8 @@ static int camera_exit(Camera * camera, GPContext *context)
-static int camera_about(Camera * camera, CameraText * about, GPContext *context)
+static int
+camera_about(Camera * camera, CameraText * about, GPContext *context)
{
strcpy(about->text,
_("Sony DSC-F55/505 gPhoto library\n"
@@ -102,28 +112,72 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list,
void *data, GPContext *context)
{
Camera *camera = data;
- int count, i, rc;
+ int mpeg, rc = GP_OK;
- GP_DEBUG(
- "camera_folder_list_files()");
+ GP_DEBUG("camera_folder_list_files()");
- count = sony_image_count(camera);
- if (count < 0)
- return (count);
+ for (mpeg = 0; mpeg <= 1 && rc == GP_OK; mpeg++) {
+ int i, count;
+ SonyFileType file_type;
- rc = GP_OK;
- for (i = 1; i <= count; i++) {
- char buf[13];
- rc = sony_file_name_get(camera, i, buf);
+ file_type = mpeg ? SONY_FILE_MPEG : SONY_FILE_IMAGE;
+
+ rc = sony_file_count(camera, file_type, &count);
if (rc != GP_OK) {
break;
}
- gp_list_append(list, buf, NULL);
+
+ for (i = 1; i <= count; i++) {
+ char buf[13];
+ rc = sony_file_name_get(camera, i, file_type, buf);
+ if (rc != GP_OK) {
+ break;
+ }
+ gp_list_append(list, buf, NULL);
+
+ if (gp_context_cancel(context)
+ == GP_CONTEXT_FEEDBACK_CANCEL) {
+ rc = GP_ERROR_CANCEL;
+ }
+ }
}
-
return rc;
}
+
+static int
+get_sony_file_id(Camera *camera, const char *folder,
+ const char *filename, GPContext *context,
+ int *sony_id, SonyFileType *sony_type)
+{
+ int num = gp_filesystem_number(camera->fs, folder, filename, context);
+ if (num < 0)
+ return (num);
+
+ num++;
+
+ if (sony_is_mpeg_file_name(filename)) {
+ const char *name_found;
+ int mpeg_num = 0;
+ do {
+ mpeg_num++;
+ gp_filesystem_name(camera->fs, folder, num-mpeg_num, &name_found, context);
+ }
+ while (sony_is_mpeg_file_name(name_found)
+ && (mpeg_num<=num));
+ mpeg_num--;
+
+ *sony_type = SONY_FILE_MPEG;
+ *sony_id = mpeg_num;
+ }
+ else {
+ *sony_type = SONY_FILE_IMAGE;
+ *sony_id = num;
+ }
+ return GP_OK;
+}
+
+
static int
get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
CameraFileType type, CameraFile * file, void *data,
@@ -131,34 +185,46 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
{
Camera *camera = data;
int num;
+ SonyFileType file_type;
int rc = GP_ERROR;
- GP_DEBUG(
- "camera_file_get(\"%s/%s\")", folder, filename);
+ GP_DEBUG("camera_file_get(\"%s/%s\")", folder, filename);
- num = gp_filesystem_number(camera->fs, folder, filename, context);
- if (num < 0)
- return (num);
-
- num++;
- GP_DEBUG(
- "file %s has id %d", filename, num);
+ rc = get_sony_file_id(camera, folder, filename, context,
+ &num, &file_type);
+ if (rc != GP_OK)
+ return rc;
switch (type) {
case GP_FILE_TYPE_NORMAL:
- rc = sony_image_get(camera, num, file, context);
+ if (file_type == SONY_FILE_MPEG) {
+ rc = sony_mpeg_get(camera, num, file, context);
+ }
+ else {
+ rc = sony_image_get(camera, num, file, context);
+ }
break;
case GP_FILE_TYPE_PREVIEW:
- rc = sony_thumbnail_get(camera, num, file, context);
+ if (file_type == SONY_FILE_MPEG) {
+ rc = GP_OK;
+ }
+ else {
+ rc = sony_thumbnail_get(camera, num, file, context);
+ }
break;
case GP_FILE_TYPE_EXIF:
- rc = sony_exif_get(camera, num, file, context);
+ if (file_type == SONY_FILE_MPEG) {
+ rc = GP_OK;
+ }
+ else {
+ rc = sony_exif_get(camera, num, file, context);
+ }
break;
default:
rc = GP_ERROR_NOT_SUPPORTED;
}
-
+
if (rc == GP_OK) {
gp_file_set_name (file, filename);
}
@@ -174,39 +240,103 @@ get_info_func (CameraFilesystem *fs, const char *folder,
GPContext *context)
{
Camera *camera = data;
- int num;
+ int num, rc;
+ SonyFileType file_type;
- num = gp_filesystem_number(camera->fs, folder, filename, context);
- if (num < 0)
- return (num);
+ rc = get_sony_file_id(camera, folder, filename, context,
+ &num, &file_type);
+ if (rc != GP_OK)
+ return rc;
- num++;
- return (sony_image_info(camera, num, info, context));
+ rc = sony_image_info(camera, num, file_type, info, context);
+ return rc;
+}
+
+
+static int
+model_compare(const char *a, const char *b)
+{
+ const char *amod;
+ const char *bmod;
+ int alen, blen;
+ int rc;
+
+ alen = strlen(a);
+ blen = strlen(b);
+ if (alen != blen) {
+ rc = 0;
+ }
+ else {
+ amod = strchr(a, ':');
+ bmod = strchr(b, ':');
+ if ((amod == NULL && bmod == NULL)
+ || (amod != NULL && bmod != NULL)) {
+ rc = !strcasecmp(a, b);
+ }
+ else if (amod != NULL) {
+ int aidx = amod - a;
+ rc = (!strncasecmp(a, b, aidx))
+ && (!strcasecmp(a+aidx+1, b+aidx+1));
+ }
+ else if (bmod != NULL) {
+ int bidx = bmod - b;
+ rc = (!strncasecmp(a, b, bidx))
+ && (!strcasecmp(a+bidx+1, b+bidx+1));
+ }
+ }
+ return rc;
}
+static int
+get_camera_model(Camera *camera, SonyModel *model)
+{
+ CameraAbilities a;
+ int rc;
+
+ rc = gp_camera_get_abilities (camera, &a);
+ if (rc == GP_OK) {
+ int i;
+ rc = GP_ERROR;
+ for (i = 0; i < sizeof(models) / sizeof(models[i]); i++) {
+ if (model_compare(models[i].model_str,
+ a.model)) {
+ rc = GP_OK;
+ *model = models[i].model_id;
+ break;
+ }
+ }
+ }
+ return rc;
+}
+
+
/**
* Initialises camera
*/
-int camera_init(Camera * camera, GPContext *context)
+int
+camera_init(Camera * camera, GPContext *context)
{
- CameraAbilities a;
- int is_msac, rc;
+ int rc;
+ SonyModel model;
+
+ rc = get_camera_model(camera, &model);
+ if (rc != GP_OK) {
+ return rc;
+ }
camera->functions->exit = camera_exit;
camera->functions->about = camera_about;
- gp_camera_get_abilities (camera, &a);
- is_msac = strcmp (a.model, SONY_MODEL_DSC_F55);
-
gp_filesystem_set_info_funcs (camera->fs, get_info_func, NULL, camera);
gp_filesystem_set_list_funcs (camera->fs, file_list_func, NULL, camera);
gp_filesystem_set_file_funcs (camera->fs, get_file_func, NULL, camera);
camera->pl = malloc (sizeof (CameraPrivateLibrary));
- if (!camera->pl)
+ if (!camera->pl) {
return (GP_ERROR_NO_MEMORY);
+ }
- rc = sony_init (camera, is_msac);
+ rc = sony_init (camera, model);
if (rc < 0) {
free (camera->pl);
camera->pl = NULL;
diff --git a/camlibs/sonydscf55/sony.c b/camlibs/sonydscf55/sony.c
index c0bee2967..569ea9716 100644
--- a/camlibs/sonydscf55/sony.c
+++ b/camlibs/sonydscf55/sony.c
@@ -43,12 +43,6 @@
#define SONY_START_CHAR 0xc0
#define SONY_END_CHAR 0xc1
-enum
-{
- SONY_FILE_EXIF=0,
- SONY_FILE_THUMBNAIL,
- SONY_FILE_IMAGE
-};
static unsigned char START_PACKET = 192;
static unsigned char END_PACKET = 193;
@@ -131,7 +125,8 @@ static const int baud_rate = 9600;
/**
* Returns transfer rate ID
*/
-static int sony_baud_to_id(long baud)
+static int
+sony_baud_to_id(long baud)
{
int r;
@@ -160,7 +155,8 @@ static int sony_baud_to_id(long baud)
/**
* Reads a byte
*/
-static int sony_read_byte(Camera * camera, unsigned char *b)
+static int
+sony_read_byte(Camera * camera, unsigned char *b)
{
int n = gp_port_read(camera->port, b, 1);
if (n != 1)
@@ -174,7 +170,8 @@ static int sony_read_byte(Camera * camera, unsigned char *b)
/**
* Returns the checksum for a packet
*/
-static unsigned char sony_packet_checksum(Packet * p)
+static unsigned char
+sony_packet_checksum(Packet * p)
{
unsigned short int o = 0;
unsigned long int sum = 0;
@@ -190,7 +187,8 @@ static unsigned char sony_packet_checksum(Packet * p)
/**
* Returns TRUE iff the packet is valid
*/
-static int sony_packet_validate(Camera * camera, Packet * p)
+static int
+sony_packet_validate(Camera * camera, Packet * p)
{
unsigned char c = sony_packet_checksum(p);
@@ -301,7 +299,8 @@ static int sony_packet_read(Camera * camera, Packet * pack)
/**
* Sends a packet
*/
-static int sony_packet_write(Camera * camera, Packet * p)
+static int
+sony_packet_write(Camera * camera, Packet * p)
{
unsigned short int count;
int rc;
@@ -384,7 +383,8 @@ sony_converse(Camera * camera, Packet * out, unsigned char *str, int len)
break;
case SONY_INVALID_SEQUENCE:
- if (camera->pl->msac_sr1) {
+ if (camera->pl->model
+ != SONY_MODEL_DSC_F55) {
invalid_sequence = 1;
sony_packet_make(camera,
&ps, str,
@@ -450,7 +450,8 @@ sony_converse(Camera * camera, Packet * out, unsigned char *str, int len)
/**
* Sets baud rate
*/
-static int sony_baud_port_set(Camera * camera, long baud)
+static int
+sony_baud_port_set(Camera * camera, long baud)
{
gp_port_settings settings;
@@ -466,7 +467,8 @@ static int sony_baud_port_set(Camera * camera, long baud)
/**
* Sets baud rate
*/
-static int sony_baud_set(Camera * camera, long baud)
+static int
+sony_baud_set(Camera * camera, long baud)
{
Packet dp;
int rc;
@@ -498,7 +500,8 @@ static int sony_baud_set(Camera * camera, long baud)
/**
* Port initialisation
*/
-static int sony_init_port (Camera *camera)
+static int
+sony_init_port (Camera *camera)
{
gp_port_settings settings;
int rc;
@@ -524,7 +527,8 @@ static int sony_init_port (Camera *camera)
/**
* Establish first contact (remember the prime directive? :)
*/
-static int sony_init_first_contact (Camera *camera)
+static int
+sony_init_first_contact (Camera *camera)
{
int count = 0;
Packet dp;
@@ -547,15 +551,25 @@ static int sony_init_first_contact (Camera *camera)
}
/**
+ * Device supports MPEG?
+ */
+static int
+sony_is_mpeg_supported (Camera * camera)
+{
+ return camera->pl->model == SONY_MODEL_DSC_F55;
+}
+
+/**
* Initialises camera
*/
-int sony_init (Camera * camera, int msac)
+int
+sony_init (Camera * camera, SonyModel model)
{
int rc;
-
- camera->pl->msac_sr1 = msac;
+ camera->pl->model = model;
camera->pl->current_baud_rate = -1;
-
+ camera->pl->current_mpeg_mode = -1;
+
rc = sony_init_port (camera);
if (rc == GP_OK)
rc = sony_init_first_contact (camera);
@@ -566,7 +580,8 @@ int sony_init (Camera * camera, int msac)
/**
* Reset the camera sequence count and baud rate.
*/
-int sony_exit(Camera * camera)
+int
+sony_exit(Camera * camera)
{
Packet dp;
int rc = GP_ERROR;
@@ -579,76 +594,107 @@ int sony_exit(Camera * camera)
return rc;
}
-/**
- * Return count of images taken.
- */
+
static int
-sony_item_count(Camera * camera, unsigned char *from, int from_len)
+sony_set_file_mode(Camera * camera, SonyFileType file_type)
{
+ int rc = GP_OK;
Packet dp;
- int rc;
-
- GP_DEBUG( "sony_item_count()");
- rc = sony_converse(camera, &dp, SetTransferRate, 4);
- if (rc == GP_OK) {
- rc = sony_converse(camera, &dp, from, from_len);
- if (rc == GP_OK) {
- rc = sony_converse(camera, &dp, SendImageCount, 3);
+ if (file_type == SONY_FILE_MPEG) {
+ if (camera->pl->current_mpeg_mode != 1) {
+ rc = sony_converse(camera, &dp, MpegImage, 21);
if (rc == GP_OK) {
- int nr = dp.buffer[5] | (dp.buffer[4]<<8);
- GP_DEBUG ("count = %d", nr);
- return nr;
+ camera->pl->current_mpeg_mode = 1;
}
}
}
- return GP_ERROR;
+ else {
+ if (camera->pl->current_mpeg_mode != 0) {
+ rc = sony_converse(camera, &dp, StillImage, 19);
+ if (rc == GP_OK) {
+ camera->pl->current_mpeg_mode = 0;
+ }
+ }
+ }
+ return rc;
}
/**
- * Returns number of still images
+ * Return count of images taken.
*/
-int sony_image_count(Camera * camera)
+int
+sony_file_count(Camera * camera, SonyFileType file_type, int *count)
{
- return sony_item_count(camera, StillImage, sizeof(StillImage));
-}
-
+ Packet dp;
+ int rc;
-/**
- * Returns number of still images
- */
-int sony_mpeg_count(Camera * camera)
-{
- return sony_item_count(camera, MpegImage, sizeof(MpegImage));
+ GP_DEBUG( "sony_file_count()");
+ if (file_type == SONY_FILE_MPEG
+ && (! sony_is_mpeg_supported(camera))) {
+ rc = GP_OK;
+ *count = 0;
+ }
+ else {
+ *count = -1;
+ rc = sony_converse(camera, &dp, SetTransferRate, 4);
+ if (rc == GP_OK) {
+ int rc = sony_set_file_mode(camera, file_type);
+ if (rc == GP_OK) {
+ rc = sony_converse(camera, &dp, SendImageCount, 3);
+ if (rc == GP_OK) {
+ int nr = dp.buffer[5] | (dp.buffer[4]<<8);
+ GP_DEBUG ("count = %d", nr);
+ *count = nr;
+ }
+ }
+ }
+ }
+ return rc;
}
+
/**
* Fetches file name.
*/
int
-sony_file_name_get(Camera *camera, int imageid, char buf[13])
+sony_file_name_get(Camera *camera, int imageid, SonyFileType mpeg, char buf[13])
{
Packet dp;
int rc;
-
+
GP_DEBUG( "sony_file_name_get()");
- sony_baud_set(camera, baud_rate);
- /* FIXME: Not nice, changing global data like this. */
- SelectImage[3] = (imageid >> 8);
- SelectImage[4] = imageid & 0xff;
- rc = sony_converse(camera, &dp, SelectImage, 7);
+ rc = sony_set_file_mode(camera, mpeg);
if (rc == GP_OK) {
- memcpy(buf, &dp.buffer[5], 8);
- buf[8] = '.';
- memcpy(buf+9, &dp.buffer[5+8], 3);
- buf[12] = 0;
+ sony_baud_set(camera, baud_rate);
+ /* FIXME: Not nice, changing global data like this. */
+ SelectImage[3] = (imageid >> 8);
+ SelectImage[4] = imageid & 0xff;
+ rc = sony_converse(camera, &dp, SelectImage, 7);
+ if (rc == GP_OK) {
+ memcpy(buf, &dp.buffer[5], 8);
+ buf[8] = '.';
+ memcpy(buf+9, &dp.buffer[5+8], 3);
+ buf[12] = 0;
+ }
}
return rc;
}
/**
+ * Is it an MPEG file?
+ */
+int
+sony_is_mpeg_file_name(const char * file_name)
+{
+ return strncmp(file_name,"MOV",3)==0;
+}
+
+
+
+/**
* Fetches an image.
*/
static int
@@ -658,9 +704,15 @@ sony_file_get(Camera * camera, int imageid, int file_type,
int sc; /* count of bytes to skip at start of packet */
Packet dp;
int rc;
- char buffer[128];
+ char buffer[128];
GP_DEBUG( "sony_file_get()");
+
+ rc = sony_set_file_mode(camera, file_type);
+ if (rc != GP_OK) {
+ return rc;
+ }
+
if (gp_context_cancel(context) == GP_CONTEXT_FEEDBACK_CANCEL) {
return GP_ERROR_CANCEL;
}
@@ -677,16 +729,16 @@ sony_file_get(Camera * camera, int imageid, int file_type,
sony_baud_set(camera, baud_rate);
- rc = sony_converse(camera, &dp, StillImage, 19);
+ rc = sony_set_file_mode(camera, file_type);
if (rc == GP_OK) {
if (file_type == SONY_FILE_THUMBNAIL) {
sc = 0x247;
-
SelectImage[3] = (imageid >> 8);
SelectImage[4] = imageid & 0xff;
sony_converse(camera, &dp, SelectImage, 7);
- if (camera->pl->msac_sr1) {
+ if (camera->pl->model
+ != SONY_MODEL_DSC_F55) {
gp_file_append(file,
"\xff\xd8\xff", 3);
}
@@ -764,9 +816,10 @@ sony_file_get(Camera * camera, int imageid, int file_type,
}
/**
- * Fetches an image.
+ * Fetches a thumbnail image.
*/
-int sony_thumbnail_get(Camera * camera, int imageid, CameraFile * file, GPContext *context)
+int
+sony_thumbnail_get(Camera * camera, int imageid, CameraFile * file, GPContext *context)
{
return sony_file_get(camera, imageid, SONY_FILE_THUMBNAIL, file, context);
}
@@ -774,7 +827,8 @@ int sony_thumbnail_get(Camera * camera, int imageid, CameraFile * file, GPContex
/**
* Fetches an image.
*/
-int sony_image_get(Camera * camera, int imageid, CameraFile * file, GPContext *context)
+int
+sony_image_get(Camera * camera, int imageid, CameraFile * file, GPContext *context)
{
return sony_file_get(camera, imageid, SONY_FILE_IMAGE, file, context);
}
@@ -782,21 +836,38 @@ int sony_image_get(Camera * camera, int imageid, CameraFile * file, GPContext *c
/**
* Fetches EXIF information.
*/
-int sony_exif_get(Camera * camera, int imageid, CameraFile * file, GPContext *context)
+int
+sony_exif_get(Camera * camera, int imageid, CameraFile * file, GPContext *context)
{
return sony_file_get(camera, imageid, SONY_FILE_EXIF, file, context);
}
+/**
+ * Fetches an Mpeg.
+ */
+int
+sony_mpeg_get(Camera * camera, int imageid, CameraFile * file, GPContext *context)
+{
+ return sony_file_get(camera, imageid, SONY_FILE_MPEG, file, context);
+}
+
/**
* Fetches image details.
*/
-int sony_image_info(Camera * camera, int imageid, CameraFileInfo * info, GPContext *context)
+int
+sony_image_info(Camera * camera, int imageid, SonyFileType file_type,
+ CameraFileInfo * info, GPContext *context)
{
unsigned int l = 0;
int rc;
Packet dp;
+ rc = sony_set_file_mode(camera, file_type);
+ if (rc != GP_OK) {
+ return rc;
+ }
+
if (gp_context_cancel(context) == GP_CONTEXT_FEEDBACK_CANCEL) {
return GP_ERROR_CANCEL;
}
@@ -812,9 +883,15 @@ int sony_image_info(Camera * camera, int imageid, CameraFileInfo * info, GPConte
info->file.fields = GP_FILE_INFO_SIZE | GP_FILE_INFO_TYPE;
info->file.size = l;
- strcpy (info->file.type, GP_MIME_JPEG);
info->preview.fields = GP_FILE_INFO_TYPE;
+
+ if (file_type == SONY_FILE_MPEG) {
+ strcpy (info->file.type, GP_MIME_AVI);
+ }
+ else {
+ strcpy (info->file.type, GP_MIME_JPEG);
+ }
}
return rc;
}
diff --git a/camlibs/sonydscf55/sony.h b/camlibs/sonydscf55/sony.h
index 96bdbc102..a02e3f6e6 100644
--- a/camlibs/sonydscf55/sony.h
+++ b/camlibs/sonydscf55/sony.h
@@ -21,10 +21,14 @@
#define SONY_H
#define SONY_CAMERA_ID "sonydscf55"
-#define SONY_MODEL_MSAC_SR1 "Sony:MSAC-SR1"
-#define SONY_MODEL_DCR_PC100 "Sony:DCR-PC100"
-#define SONY_MODEL_TRV_20E "Sony:TRV-20E"
-#define SONY_MODEL_DSC_F55 "Sony:DSC-F55"
+
+typedef enum {
+ SONY_MODEL_MSAC_SR1 = 0,
+ SONY_MODEL_DCR_PC100,
+ SONY_MODEL_TRV_20E,
+ SONY_MODEL_DSC_F55,
+ SONY_MODEL_SIZEOF
+} SonyModel;
#define SONY_FILE_NAME_FMT "dsc%05d.jpg"
@@ -37,21 +41,32 @@ typedef struct _tagPacket {
struct _CameraPrivateLibrary {
unsigned short int sequence_id;
- int msac_sr1;
long current_baud_rate;
+ int current_mpeg_mode;
+ SonyModel model;
};
-int sony_init(Camera * camera, int ismsac);
+
+typedef enum
+{
+ SONY_FILE_EXIF=0,
+ SONY_FILE_THUMBNAIL,
+ SONY_FILE_IMAGE,
+ SONY_FILE_MPEG
+} SonyFileType;
+
+int sony_init(Camera * camera, SonyModel model);
int sony_exit(Camera * camera);
-int sony_image_count(Camera * camera);
-int sony_mpeg_count(Camera * camera);
+int sony_file_count(Camera * camera, SonyFileType file_type, int * count);
int sony_image_get(Camera * camera, int imageid, CameraFile * file, GPContext *context);
int sony_thumbnail_get(Camera * camera, int imageid, CameraFile * file, GPContext *context);
int sony_exif_get(Camera * camera, int imageid, CameraFile * file, GPContext *context);
-int sony_image_info(Camera * camera, int imageid, CameraFileInfo * info, GPContext *context);
-int sony_file_name_get(Camera *camera, int imageid, char buf[13]);
+int sony_mpeg_get(Camera * camera, int imageid, CameraFile * file, GPContext *context);
+int sony_image_info(Camera * camera, int imageid, SonyFileType file_type, CameraFileInfo * info, GPContext *context);
+int sony_file_name_get(Camera *camera, int imageid, SonyFileType file_type, char buf[13]);
+int sony_is_mpeg_file_name(const char * file_name);
-#endif /* SONY_H */
+#endif /* SONY_H */
/*
* Local Variables: