Added effects and zoom to camera. Totally emoved privative libmmcamera
Change-Id: I801b538e27f883120743cb0740e6b5ad7a9da02d
This commit is contained in:
parent
9869596459
commit
3df7c89053
File diff suppressed because it is too large
Load Diff
@ -33,9 +33,11 @@ extern "C" {
|
||||
|
||||
#define CAM_CTRL_SUCCESS 1
|
||||
|
||||
#define REVISION_H "1"
|
||||
#define REVISION_H "2"
|
||||
|
||||
#define CAMERA_SET_PARM_DIMENSION 1
|
||||
#define CAMERA_SET_PARM_ZOOM 2
|
||||
#define CAMERA_GET_PARM_MAXZOOM 47
|
||||
#define CAMERA_SET_PARM_WB 14
|
||||
#define CAMERA_SET_PARM_EFFECT 15
|
||||
#define CAMERA_SET_PARM_ANTIBANDING 21
|
||||
@ -45,7 +47,7 @@ extern "C" {
|
||||
|
||||
#define CAMERA_SET_PARM_AUTO_FOCUS 13
|
||||
#define CAMERA_START_SNAPSHOT 40
|
||||
#define CAMERA_STOP_SNAPSHOT 42 //41
|
||||
#define CAMERA_STOP_SNAPSHOT 42
|
||||
|
||||
#define AF_MODE_AUTO 2
|
||||
#define CAMERA_AUTO_FOCUS_CANCEL 1 //204
|
||||
@ -142,6 +144,54 @@ struct str_map {
|
||||
int val;
|
||||
};
|
||||
|
||||
// ********************************************************************************************************
|
||||
typedef unsigned int exif_tag_id_t;
|
||||
|
||||
#define EXIF_RATIONAL 5
|
||||
#define EXIF_ASCII 2
|
||||
#define EXIF_BYTE 1
|
||||
|
||||
typedef struct {
|
||||
int val;
|
||||
int otherval;
|
||||
} rat_t;
|
||||
|
||||
|
||||
typedef union {
|
||||
char * _ascii; /* At byte 16 relative to exif_tag_entry_t */
|
||||
rat_t * _rats;
|
||||
rat_t _rat;
|
||||
uint8_t _byte;
|
||||
} exif_tag_data_t;
|
||||
|
||||
/* The entire exif_tag_entry_t struct must be 24 bytes in length */
|
||||
typedef unsigned int exif_tag_type_t;
|
||||
typedef struct {
|
||||
exif_tag_type_t type;
|
||||
uint32_t copy;
|
||||
uint32_t count;
|
||||
exif_tag_data_t data;
|
||||
} exif_tag_entry_t;
|
||||
|
||||
typedef struct {
|
||||
exif_tag_id_t tag_id;
|
||||
exif_tag_entry_t tag_entry;
|
||||
} exif_tags_info_t;
|
||||
|
||||
/* EXIF tag IDs */
|
||||
#define EXIFTAGID_GPS_LATITUDE 0x20002
|
||||
#define EXIFTAGID_GPS_LATITUDE_REF 0x10001
|
||||
#define EXIFTAGID_GPS_LONGITUDE 0x40004
|
||||
#define EXIFTAGID_GPS_LONGITUDE_REF 0x30003
|
||||
#define EXIFTAGID_GPS_ALTITUDE 0x60006
|
||||
#define EXIFTAGID_GPS_ALTITUDE_REF 0x50005
|
||||
#define EXIFTAGID_EXIF_CAMERA_MAKER 0x21010F
|
||||
#define EXIFTAGID_EXIF_CAMERA_MODEL 0x220110
|
||||
#define EXIFTAGID_EXIF_DATE_TIME_ORIGINAL 0x3A9003
|
||||
#define EXIFTAGID_EXIF_DATE_TIME 0x3B9004
|
||||
/* End of values originally in proprietary headers */
|
||||
// ********************************************************************************************************
|
||||
|
||||
namespace android {
|
||||
|
||||
class QualcommCameraHardware : public CameraHardwareInterface {
|
||||
@ -169,6 +219,7 @@ public:
|
||||
virtual status_t autoFocus();
|
||||
virtual status_t takePicture();
|
||||
virtual status_t cancelPicture();
|
||||
virtual void initCameraParameters();
|
||||
virtual status_t setParameters(const CameraParameters& params);
|
||||
virtual CameraParameters getParameters() const;
|
||||
virtual status_t sendCommand(int32_t command, int32_t arg1, int32_t arg2);
|
||||
@ -195,7 +246,6 @@ public:
|
||||
|
||||
void receivePreviewFrame(struct msm_frame_t *frame);
|
||||
void receiveJpegPicture(void);
|
||||
void jpeg_set_location();
|
||||
void receiveJpegPictureFragment(uint8_t *buf, uint32_t size);
|
||||
void notifyShutter();
|
||||
|
||||
@ -211,6 +261,8 @@ private:
|
||||
bool native_set_parm(cam_ctrl_type type, uint16_t length, void *value);
|
||||
bool native_set_dimension(cam_ctrl_dimension_t *value);
|
||||
int getParm(const char *parm_str, const str_map *parm_map);
|
||||
void setGpsParameters();
|
||||
const char *KEY_GPS_LATITUDE;
|
||||
|
||||
static wp<QualcommCameraHardware> singleton;
|
||||
|
||||
@ -218,7 +270,7 @@ private:
|
||||
for preview and raw, and need to be updated when libmmcamera
|
||||
changes.
|
||||
*/
|
||||
static const int kPreviewBufferCount = 2;
|
||||
static const int kPreviewBufferCount = 4;
|
||||
static const int kRawBufferCount = 1;
|
||||
static const int kJpegBufferCount = 1;
|
||||
static const int kRawFrameHeaderSize = 0;
|
||||
@ -314,8 +366,7 @@ private:
|
||||
Condition mFrameThreadWait;
|
||||
friend void *frame_thread(void *user);
|
||||
void runFrameThread(void *data);
|
||||
|
||||
bool mPrevThreadRunning;
|
||||
status_t setGpsLocation(const CameraParameters& params);
|
||||
|
||||
bool mShutterPending;
|
||||
Mutex mShutterLock;
|
||||
@ -331,6 +382,7 @@ private:
|
||||
void setAntibanding();
|
||||
void setEffect();
|
||||
void setWhiteBalance();
|
||||
void setZoom();
|
||||
|
||||
Mutex mLock;
|
||||
bool mReleasedRecordingFrame;
|
||||
@ -374,13 +426,13 @@ private:
|
||||
pthread_t mCamConfigThread;
|
||||
pthread_t mFrameThread;
|
||||
pthread_t mSnapshotThread;
|
||||
pthread_t mPrevThread;
|
||||
|
||||
common_crop_t mCrop;
|
||||
|
||||
struct msm_frame_t frames[kPreviewBufferCount];
|
||||
bool mInPreviewCallback;
|
||||
bool mCameraRecording;
|
||||
int32_t mCurZoom;
|
||||
};
|
||||
|
||||
}; // namespace android
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "jhead.h"
|
||||
#define LOG_TAG "ExifWriterCamera"
|
||||
//#define LOG_NDEBUG 0
|
||||
|
||||
#include <utils/Log.h>
|
||||
|
||||
@ -42,6 +43,8 @@ char * float2rationnal( float src )
|
||||
|
||||
startx = x = src;
|
||||
|
||||
LOGV("float2rationnal: Convertir %f", src);
|
||||
|
||||
/* initialize matrix */
|
||||
m[0][0] = m[1][1] = 1;
|
||||
m[0][1] = m[1][0] = 0;
|
||||
@ -64,15 +67,11 @@ char * float2rationnal( float src )
|
||||
/* now remaining x is between 0 and 1/ai */
|
||||
/* approx as either 0 or 1/m where m is max that will fit in maxden */
|
||||
/* first try zero */
|
||||
LOGV("%ld/%ld, error = %e\n", m[0][0], m[1][0],
|
||||
startx - ((float) m[0][0] / (float) m[1][0]));
|
||||
|
||||
/* now try other possibility */
|
||||
ai = (maxden - m[1][1]) / m[1][0];
|
||||
m[0][0] = m[0][0] * ai + m[0][1];
|
||||
m[1][0] = m[1][0] * ai + m[1][1];
|
||||
LOGV("%ld/%ld, error = %e\n", m[0][0], m[1][0],
|
||||
startx - ((float) m[0][0] / (float) m[1][0]));
|
||||
|
||||
char *res = (char *)malloc( 256 * sizeof(char) );
|
||||
|
||||
@ -83,52 +82,55 @@ char * float2rationnal( float src )
|
||||
char * coord2degminsec( float src )
|
||||
{
|
||||
char *res = (char *)malloc( 256 * sizeof(char) );
|
||||
LOGV("coord2degminsec: Convertir %f", src);
|
||||
float *dms = float2degminsec( fabs(src) );
|
||||
LOGV("coord2degminsec: paso1 (float) %f %f %f", dms[0], dms[1], dms[2]);
|
||||
strcpy( res, float2rationnal(dms[0]) );
|
||||
strcat( res , "," );
|
||||
strcat( res , float2rationnal(dms[1]) );
|
||||
strcat( res , "," );
|
||||
strcat( res , float2rationnal(dms[2]) );
|
||||
LOGV("coord2degminsec: Convertido en %s", res);
|
||||
free( dms );
|
||||
return res;
|
||||
}
|
||||
|
||||
static void dump_to_file(const char *fname,
|
||||
uint8_t *buf, uint32_t size)
|
||||
{
|
||||
int nw, cnt = 0;
|
||||
uint32_t written = 0;
|
||||
static void dump_to_file(const char *fname,
|
||||
uint8_t *buf, uint32_t size)
|
||||
{
|
||||
int nw, cnt = 0;
|
||||
uint32_t written = 0;
|
||||
|
||||
LOGD("opening file [%s]\n", fname);
|
||||
int fd = open(fname, O_RDWR | O_CREAT);
|
||||
if (fd < 0) {
|
||||
LOGE("failed to create file [%s]: %s", fname, strerror(errno));
|
||||
return;
|
||||
}
|
||||
LOGV("opening file [%s]\n", fname);
|
||||
int fd = open(fname, O_RDWR | O_CREAT);
|
||||
if (fd < 0) {
|
||||
LOGE("failed to create file [%s]: %s", fname, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
LOGD("writing %d bytes to file [%s]\n", size, fname);
|
||||
while (written < size) {
|
||||
nw = write(fd,
|
||||
buf + written,
|
||||
size - written);
|
||||
if (nw < 0) {
|
||||
LOGE("failed to write to file [%s]: %s",
|
||||
fname, strerror(errno));
|
||||
break;
|
||||
}
|
||||
written += nw;
|
||||
cnt++;
|
||||
}
|
||||
LOGD("done writing %d bytes to file [%s] in %d passes\n",
|
||||
size, fname, cnt);
|
||||
close(fd);
|
||||
}
|
||||
LOGV("writing %d bytes to file [%s]\n", size, fname);
|
||||
while (written < size) {
|
||||
nw = write(fd,
|
||||
buf + written,
|
||||
size - written);
|
||||
if (nw < 0) {
|
||||
LOGE("failed to write to file [%s]: %s",
|
||||
fname, strerror(errno));
|
||||
break;
|
||||
}
|
||||
written += nw;
|
||||
cnt++;
|
||||
}
|
||||
LOGV("done writing %d bytes to file [%s] in %d passes\n",
|
||||
size, fname, cnt);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void writeExif( void *origData, void *destData , int origSize , uint32_t *resultSize, int orientation,camera_position_type *pt ) {
|
||||
const char *filename = "/data/temp.jpg";
|
||||
|
||||
dump_to_file( filename, (uint8_t *)origData, origSize );
|
||||
LOGD("KalimochoAz WRITE EXIF Filename %s", filename);
|
||||
LOGV("WRITE EXIF Filename %s", filename);
|
||||
chmod( filename, S_IRWXU );
|
||||
ResetJpgfile();
|
||||
|
||||
@ -140,10 +142,10 @@ void writeExif( void *origData, void *destData , int origSize , uint32_t *result
|
||||
|
||||
int gpsTag = 0;
|
||||
if( pt != NULL ) {
|
||||
LOGD("KalimochoAz EXIF ADD GPS DATA ........");
|
||||
LOGV("EXIF ADD GPS DATA ........");
|
||||
gpsTag = 6;
|
||||
} else{
|
||||
LOGD("KalimochoAz EXIF NO GPS ........");
|
||||
LOGV("EXIF NO GPS ........");
|
||||
}
|
||||
|
||||
|
||||
@ -155,7 +157,7 @@ void writeExif( void *origData, void *destData , int origSize , uint32_t *result
|
||||
(*it).Format = FMT_USHORT;
|
||||
(*it).DataLength = 1;
|
||||
unsigned short v;
|
||||
LOGD("KalimochoAz EXIF Orientation %d º", orientation);
|
||||
LOGV("EXIF Orientation %d º", orientation);
|
||||
if( orientation == 90 ) {
|
||||
(*it).Value = "6";
|
||||
} else if( orientation == 180 ) {
|
||||
@ -183,9 +185,9 @@ void writeExif( void *origData, void *destData , int origSize , uint32_t *result
|
||||
|
||||
|
||||
if( pt != NULL ) {
|
||||
LOGD("pt->latitude == %f", pt->latitude );
|
||||
LOGD("pt->longitude == %f", pt->longitude );
|
||||
LOGD("pt->altitude == %d", pt->altitude );
|
||||
LOGV("pt->latitude == %f", pt->latitude );
|
||||
LOGV("pt->longitude == %f", pt->longitude );
|
||||
LOGV("pt->altitude == %d", pt->altitude );
|
||||
|
||||
it++;
|
||||
(*it).Tag = 0x01;
|
||||
@ -200,6 +202,7 @@ void writeExif( void *origData, void *destData , int origSize , uint32_t *result
|
||||
|
||||
it++;
|
||||
char *mylat = coord2degminsec( pt->latitude );
|
||||
LOGV("writeExif: La latitud queda en: %s", mylat);
|
||||
|
||||
(*it).Tag = 0x02;
|
||||
(*it).Format = FMT_URATIONAL;
|
||||
@ -221,6 +224,7 @@ void writeExif( void *origData, void *destData , int origSize , uint32_t *result
|
||||
|
||||
it++;
|
||||
char *mylong = coord2degminsec( (*pt).longitude );
|
||||
LOGV("writeExif: La longitud queda en: %s", mylong);
|
||||
|
||||
(*it).Tag = 0x04;
|
||||
(*it).Format = FMT_URATIONAL;
|
||||
@ -243,6 +247,7 @@ void writeExif( void *origData, void *destData , int origSize , uint32_t *result
|
||||
|
||||
it++;
|
||||
char *myalt = float2rationnal( fabs( (*pt).altitude ) );
|
||||
LOGV("writeExif: La altitud queda en: %s", myalt);
|
||||
|
||||
(*it).Tag = 0x06;
|
||||
(*it).Format = FMT_SRATIONAL;
|
||||
@ -262,13 +267,13 @@ void writeExif( void *origData, void *destData , int origSize , uint32_t *result
|
||||
}
|
||||
}
|
||||
strncpy(ImageInfo.FileName, filename, PATH_MAX);
|
||||
LOGD("KalimochoAz Image EXIF Filename %s", filename);
|
||||
LOGV("Image EXIF Filename %s", filename);
|
||||
|
||||
ReadMode_t ReadMode;
|
||||
ReadMode = READ_METADATA;
|
||||
ReadMode |= READ_IMAGE;
|
||||
int res = ReadJpegFile(filename, (ReadMode_t)ReadMode );
|
||||
LOGD("KalimochoAz READ EXIF Filename %s", filename);
|
||||
LOGV("READ EXIF Filename %s", filename);
|
||||
|
||||
create_EXIF( t, 3, gpsTag);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user