camlibs/panasonic/coolshot

2002-01-04  Chris Pinkham <cpinkham@infi.net>

    * coolshot.c, library.c, library.h: updated code to use new
	      gp_file_progress instead of gp_camera_progress.

camlibs/jamcam

2002-01-04  Chris Pinkham <cpinkham@infi.net>

    * jamcam.c, library.c, library.h: updated code to use new
	      gp_file_progress instead of gp_camera_progress.


git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@3722 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
Chris Pinkham
2002-01-05 05:24:59 +00:00
parent 2729ec7f16
commit 3c55c3dd25
8 changed files with 68 additions and 35 deletions

View File

@@ -1,3 +1,8 @@
2002-01-04 Chris Pinkham <cpinkham@infi.net>
* jamcam.c, library.c, library.h: updated code to use new
gp_file_progress instead of gp_camera_progress.
2001-12-05 Lutz Müller <urc8@rz.uni-karlsruhe.de>
* jamcam.c: Don't include <libgphoto2/*.>, include <*.h> instead.

View File

@@ -181,11 +181,14 @@ static int get_file_func (CameraFilesystem *fs, const char *folder,
CHECK (n = gp_filesystem_number (camera->fs, folder, filename));
gp_camera_progress( camera, 0 );
n = gp_file_progress( file, 0 );
if ( n < 0 ) {
return( n );
}
switch (type) {
case GP_FILE_TYPE_PREVIEW:
CHECK (jamcam_request_thumbnail (camera, raw, &size, n));
CHECK (jamcam_request_thumbnail (camera, file, raw, &size, n));
width = 80;
height = 60;
@@ -210,7 +213,7 @@ static int get_file_func (CameraFilesystem *fs, const char *folder,
break;
case GP_FILE_TYPE_NORMAL:
CHECK (jamcam_request_image (camera, raw, &size, n));
CHECK (jamcam_request_image (camera, file, raw, &size, n));
jc_file = jamcam_file_info (camera, n);
@@ -235,7 +238,7 @@ static int get_file_func (CameraFilesystem *fs, const char *folder,
break;
case GP_FILE_TYPE_RAW:
CHECK (jamcam_request_image (camera, raw, &size, n));
CHECK (jamcam_request_image (camera, file, raw, &size, n));
CHECK (gp_file_set_mime_type (file, GP_MIME_RAW));
strcpy( tmp_filename, filename );
tmp_filename[strlen(tmp_filename)-3] = 'r';

View File

@@ -293,7 +293,8 @@ int jamcam_file_count (Camera *camera) {
return( jamcam_count );
}
int jamcam_fetch_memory( Camera *camera, char *data, int start, int length ) {
int jamcam_fetch_memory( Camera *camera, CameraFile *file,
char *data, int start, int length ) {
char tmp_buf[16];
char packet[16];
int new_start;
@@ -301,7 +302,7 @@ int jamcam_fetch_memory( Camera *camera, char *data, int start, int length ) {
int bytes_read = 0;
int bytes_to_read;
int bytes_left = length;
float percentage;
int res = GP_OK;
gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_fetch_memory");
gp_debug_printf (GP_DEBUG_LOW, "jamcam", " * start: %d (0x%x)",
@@ -354,16 +355,23 @@ int jamcam_fetch_memory( Camera *camera, char *data, int start, int length ) {
/* hate this hardcoded, but don't want to update here */
/* when downloading parts of a thumbnail */
if ( length > 1000 ) {
percentage = ( 1.0 * bytes_read ) / length;
gp_camera_progress( camera, percentage );
res = gp_file_progress( file,
(float)(bytes_read)/(float)(length) );
if ( res < 0 ) {
gp_debug_printf (GP_DEBUG_LOW, "jamcam", " * CANCELED");
break;
}
}
}
gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_fetch_memory OK");
return( GP_OK );
if ( res == GP_OK ) {
gp_debug_printf (GP_DEBUG_LOW, "jamcam", " * returning OK");
}
return( res );
}
int jamcam_request_image( Camera *camera, char *buf, int *len, int number ) {
int jamcam_request_image( Camera *camera, CameraFile *file,
char *buf, int *len, int number ) {
int position;
int result;
char tmp_buf[300000];
@@ -385,7 +393,7 @@ int jamcam_request_image( Camera *camera, char *buf, int *len, int number ) {
NULL, 0 );
}
result = jamcam_fetch_memory( camera, tmp_buf, position,
result = jamcam_fetch_memory( camera, file, tmp_buf, position,
jamcam_files[number].data_incr );
/* this seems to reset the camera to a sane status */
@@ -410,13 +418,14 @@ struct jamcam_file *jamcam_file_info(Camera *camera, int number)
return( &jamcam_files[number] );
}
int jamcam_request_thumbnail( Camera *camera, char *buf, int *len, int number ) {
int jamcam_request_thumbnail( Camera *camera, CameraFile *file,
char *buf, int *len, int number ) {
char line[2048];
char packet[16];
int position;
int x, y;
int res = GP_OK;
char *ptr;
float percentage;
int bytes_to_read;
gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_request_thumbnail");
@@ -454,10 +463,13 @@ int jamcam_request_thumbnail( Camera *camera, char *buf, int *len, int number )
/* fetch thumbnail lines and build the thumbnail */
position += 10 * jamcam_files[number].width;
for( y = 0 ; y < 60 ; y++ ) {
jamcam_fetch_memory( camera, line, position, bytes_to_read );
jamcam_fetch_memory( camera, file, line, position, bytes_to_read );
percentage = (1.0 * y) / 60;
gp_camera_progress( camera, percentage );
res = gp_file_progress( file, (float)(y)/60.0 );
gp_debug_printf (GP_DEBUG_LOW, "jamcam", " * progress: %.2f", (float)(y)/60.0);
if ( res < 0 ) {
break;
}
if ( jamcam_files[number].width == 600 ) {
for( x = 22; x < 578 ; x += 7 ) {
@@ -489,7 +501,7 @@ int jamcam_request_thumbnail( Camera *camera, char *buf, int *len, int number )
NULL, 0 );
}
return( GP_OK );
return( res );
}
int jamcam_write_packet (Camera *camera, char *packet, int length) {

View File

@@ -46,8 +46,8 @@ int jamcam_write_packet(Camera *camera, char *packet, int length);
int jamcam_read_packet(Camera *camera, char *packet, int length);
int jamcam_file_count(Camera *camera);
struct jamcam_file *jamcam_file_info(Camera *camera, int number);
int jamcam_fetch_memory(Camera *camera, char *data, int start, int length );
int jamcam_request_image(Camera *camera, char *buf, int *len, int number);
int jamcam_request_thumbnail(Camera *camera, char *buf, int *len, int number );
int jamcam_fetch_memory(Camera *camera, CameraFile *file, char *data, int start, int length );
int jamcam_request_image(Camera *camera, CameraFile *file, char *buf, int *len, int number);
int jamcam_request_thumbnail(Camera *camera, CameraFile *file, char *buf, int *len, int number );
#endif /* __LIBRARY_H__ */

View File

@@ -1,3 +1,8 @@
2002-01-04 Chris Pinkham <cpinkham@infi.net>
* coolshot.c, library.c, library.h: updated code to use new
gp_file_progress instead of gp_camera_progress.
2001-11-28 Chris Pinkham <cpinkham@infi.net>
* README: took out mention of protocol.txt until file is ready.

View File

@@ -192,7 +192,10 @@ static int get_file_func (CameraFilesystem *fs, const char *folder,
CHECK (camera_start (camera));
gp_camera_progress( camera, 0 );
n = gp_file_progress( file, 0 );
if ( n < 0 ) {
return (camera_stop (camera));
}
/*
* Get the file number from the CameraFileSystem (and increment
@@ -203,7 +206,7 @@ static int get_file_func (CameraFilesystem *fs, const char *folder,
switch (type) {
case GP_FILE_TYPE_PREVIEW:
CHECK (coolshot_request_thumbnail (camera, data, &size, n));
CHECK (coolshot_request_thumbnail (camera, file, data, &size, n));
CHECK (coolshot_build_thumbnail (data, &size));
CHECK (gp_file_set_mime_type (file, GP_MIME_PPM));
@@ -215,7 +218,7 @@ static int get_file_func (CameraFilesystem *fs, const char *folder,
break;
case GP_FILE_TYPE_NORMAL:
CHECK (coolshot_request_image (camera, data, &size, n));
CHECK (coolshot_request_image (camera, file, data, &size, n));
CHECK (gp_file_set_mime_type (file, GP_MIME_JPEG));
CHECK (gp_file_set_name (file, filename));
break;

View File

@@ -220,7 +220,8 @@ int coolshot_file_count (Camera *camera) {
return( count );
}
int coolshot_request_image( Camera *camera, char *buf, int *len, int number ) {
int coolshot_request_image( Camera *camera, CameraFile *file,
char *buf, int *len, int number ) {
char packet[16];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_request_image");
@@ -249,12 +250,13 @@ int coolshot_request_image( Camera *camera, char *buf, int *len, int number ) {
coolshot_read_packet( camera, packet );
/* read data */
coolshot_download_image( camera, buf, len, 0 );
coolshot_download_image( camera, file, buf, len, 0 );
return( GP_OK );
}
int coolshot_request_thumbnail( Camera *camera, char *buf, int *len, int number ) {
int coolshot_request_thumbnail( Camera *camera, CameraFile *file,
char *buf, int *len, int number ) {
char packet[16];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_request_thumbnail");
@@ -285,7 +287,7 @@ int coolshot_request_thumbnail( Camera *camera, char *buf, int *len, int number
coolshot_read_packet( camera, packet );
/* read data */
coolshot_download_image( camera, buf, len, 0 );
coolshot_download_image( camera, file, buf, len, 1 );
return( GP_OK );
}
@@ -314,7 +316,8 @@ int coolshot_check_checksum( char *packet, int length ) {
}
}
int coolshot_download_image( Camera *camera, char *buf, int *len, int thumbnail ) {
int coolshot_download_image( Camera *camera, CameraFile *file,
char *buf, int *len, int thumbnail ) {
char packet[1024];
int data_len;
int bytes_read = 0;
@@ -358,11 +361,13 @@ int coolshot_download_image( Camera *camera, char *buf, int *len, int thumbnail
}
if ( thumbnail ) {
percentage = bytes_read > 1800 ? 1.0 : ( 1.0 * bytes_read ) / 1800;
percentage = bytes_read > 1800 ? 1.0 : (float)(bytes_read)/1800.0;
} else {
percentage = bytes_read > 80000 ? 1.0 : ( 1.0 * bytes_read ) / 80000;
percentage = bytes_read > 80000 ? 1.0 : (float)(bytes_read)/80000.0;
}
gp_camera_progress( camera, percentage );
/* fixme, add ability to cancel download by checking result */
gp_file_progress( file, percentage );
coolshot_read_packet( camera, packet );

View File

@@ -45,7 +45,7 @@ int coolshot_write_packet (Camera *camera, char *packet);
int coolshot_read_packet (Camera *camera, char *packet);
int coolshot_file_count (Camera *camera);
int coolshot_check_checksum( char *packet, int length );
int coolshot_request_image (Camera *camera, char *buf, int *len, int number);
int coolshot_request_thumbnail (Camera *camera, char *buf, int *len, int number);
int coolshot_download_image (Camera *camera, char *buf, int *len, int thumbnail);
int coolshot_request_image (Camera *camera, CameraFile *file, char *buf, int *len, int number);
int coolshot_request_thumbnail (Camera *camera, CameraFile *file, char *buf, int *len, int number);
int coolshot_download_image (Camera *camera, CameraFile *file, char *buf, int *len, int thumbnail);
int coolshot_build_thumbnail (char *data, int *size);