summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camera/AppCallbackNotifier.cpp6
-rw-r--r--camera/BaseCameraAdapter.cpp27
-rw-r--r--camera/Encoder_libjpeg.cpp61
-rwxr-xr-xcamera/OMXCameraAdapter/OMXExif.cpp92
-rw-r--r--camera/inc/CameraHal.h1
-rwxr-xr-xcamera/inc/Encoder_libjpeg.h11
-rw-r--r--camera/inc/OMXCameraAdapter/OMXCameraAdapter.h3
7 files changed, 131 insertions, 70 deletions
diff --git a/camera/AppCallbackNotifier.cpp b/camera/AppCallbackNotifier.cpp
index 784d042..9368d3e 100644
--- a/camera/AppCallbackNotifier.cpp
+++ b/camera/AppCallbackNotifier.cpp
@@ -104,6 +104,12 @@ void AppCallbackNotifier::EncoderDoneCb(void* main_jpeg, void* thumb_jpeg, Camer
}
} // scope for mutex lock
+ if (!mRawAvailable) {
+ dummyRaw();
+ } else {
+ mRawAvailable = false;
+ }
+
// Send the callback to the application only if the notifier is started and the message is enabled
if(picture && (mNotifierState==AppCallbackNotifier::NOTIFIER_STARTED) &&
(mCameraHal->msgTypeEnabled(CAMERA_MSG_COMPRESSED_IMAGE)))
diff --git a/camera/BaseCameraAdapter.cpp b/camera/BaseCameraAdapter.cpp
index 9670e4c..28dc5e5 100644
--- a/camera/BaseCameraAdapter.cpp
+++ b/camera/BaseCameraAdapter.cpp
@@ -1942,6 +1942,12 @@ status_t BaseCameraAdapter::setState(CameraCommands operation)
mNextState = PREVIEW_STATE;
break;
+ case CAMERA_PERFORM_AUTOFOCUS:
+ CAMHAL_LOGDB("Adapter state switch VIDEO_STATE->VIDEO_AF_STATE event = 0x%x",
+ operation);
+ mNextState = VIDEO_AF_STATE;
+ break;
+
case CAMERA_START_SMOOTH_ZOOM:
CAMHAL_LOGDB("Adapter state switch VIDEO_STATE->VIDEO_ZOOM_STATE event = 0x%x",
operation);
@@ -1970,6 +1976,27 @@ status_t BaseCameraAdapter::setState(CameraCommands operation)
break;
+ case VIDEO_AF_STATE:
+
+ switch ( operation )
+ {
+
+ case CAMERA_CANCEL_AUTOFOCUS:
+ CAMHAL_LOGDB("Adapter state switch VIDEO_AF_STATE->VIDEO_STATE event = 0x%x",
+ operation);
+ mNextState = VIDEO_STATE;
+ break;
+
+ default:
+ CAMHAL_LOGEB("Adapter state switch VIDEO_AF_STATE Invalid Op! event = 0x%x",
+ operation);
+ ret = INVALID_OPERATION;
+ break;
+
+ }
+
+ break;
+
case VIDEO_LOADED_CAPTURE_STATE:
switch ( operation )
diff --git a/camera/Encoder_libjpeg.cpp b/camera/Encoder_libjpeg.cpp
index 152e3cc..f6f6498 100644
--- a/camera/Encoder_libjpeg.cpp
+++ b/camera/Encoder_libjpeg.cpp
@@ -36,6 +36,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
+#include <math.h>
extern "C" {
#include "jpeglib.h"
@@ -207,6 +208,58 @@ const char* ExifElementsTable::degreesToExifOrientation(const char* degrees) {
return NULL;
}
+void ExifElementsTable::stringToRational(const char* str, unsigned int* num, unsigned int* den) {
+ int len;
+ char * tempVal = NULL;
+
+ if (str != NULL) {
+ len = strlen(str);
+ tempVal = (char*) malloc( sizeof(char) * (len + 1));
+ }
+
+ if (tempVal != NULL) {
+ // convert the decimal string into a rational
+ size_t den_len;
+ char *ctx;
+ unsigned int numerator = 0;
+ unsigned int denominator = 0;
+ char* temp = NULL;
+
+ memset(tempVal, '\0', len + 1);
+ strncpy(tempVal, str, len);
+ temp = strtok_r(tempVal, ".", &ctx);
+
+ if (temp != NULL)
+ numerator = atoi(temp);
+
+ if (!numerator)
+ numerator = 1;
+
+ temp = strtok_r(NULL, ".", &ctx);
+ if (temp != NULL) {
+ den_len = strlen(temp);
+ if(HUGE_VAL == den_len ) {
+ den_len = 0;
+ }
+
+ denominator = static_cast<unsigned int>(pow(10, den_len));
+ numerator = numerator * denominator + atoi(temp);
+ } else {
+ denominator = 1;
+ }
+
+ free(tempVal);
+
+ *num = numerator;
+ *den = denominator;
+ }
+}
+
+bool ExifElementsTable::isAsciiTag(const char* tag) {
+ // TODO(XXX): Add tags as necessary
+ return (strcmp(tag, TAG_GPS_PROCESSING_METHOD) == 0);
+}
+
void ExifElementsTable::insertExifToJpeg(unsigned char* jpeg, size_t jpeg_size) {
ReadMode_t read_mode = (ReadMode_t)(READ_METADATA | READ_IMAGE);
@@ -264,7 +317,11 @@ status_t ExifElementsTable::insertElement(const char* tag, const char* value) {
return NO_MEMORY;
}
- value_length = strlen(value);
+ if (isAsciiTag(tag)) {
+ value_length = sizeof(ExifAsciiPrefix) + strlen(value + sizeof(ExifAsciiPrefix));
+ } else {
+ value_length = strlen(value);
+ }
if (IsGpsTag(tag)) {
table[position].GpsTag = TRUE;
@@ -280,7 +337,7 @@ status_t ExifElementsTable::insertElement(const char* tag, const char* value) {
table[position].Value = (char*) malloc(sizeof(char) * (value_length + 1));
if (table[position].Value) {
- strcpy(table[position].Value, value);
+ memcpy(table[position].Value, value, value_length + 1);
table[position].DataLength = value_length + 1;
}
diff --git a/camera/OMXCameraAdapter/OMXExif.cpp b/camera/OMXCameraAdapter/OMXExif.cpp
index e13d145..1caeba9 100755
--- a/camera/OMXCameraAdapter/OMXExif.cpp
+++ b/camera/OMXCameraAdapter/OMXExif.cpp
@@ -31,8 +31,6 @@
namespace android {
-const char OMXCameraAdapter::EXIFASCIIPrefix [] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 };
-
status_t OMXCameraAdapter::setParametersEXIF(const CameraParameters &params,
BaseCameraAdapter::AdapterState state)
{
@@ -319,53 +317,17 @@ status_t OMXCameraAdapter::setupEXIF()
if ( ( OMX_TI_TagReadWrite == exifTags->eStatusFocalLength ))
{
- char *ctx;
- int len;
- char* temp = (char*) mParams.get(CameraParameters::KEY_FOCAL_LENGTH);
- char * tempVal = NULL;
- if(temp != NULL)
- {
- len = strlen(temp);
- tempVal = (char*) malloc( sizeof(char) * (len + 1));
- }
- if(tempVal != NULL)
- {
- memset(tempVal, '\0', len + 1);
- strncpy(tempVal, temp, len);
- CAMHAL_LOGDB("KEY_FOCAL_LENGTH = %s", tempVal);
-
- // convert the decimal string into a rational
- size_t den_len;
- OMX_U32 numerator = 0;
- OMX_U32 denominator = 0;
- char* temp = strtok_r(tempVal, ".", &ctx);
-
- if(temp != NULL)
- numerator = atoi(temp);
-
- temp = strtok_r(NULL, ".", &ctx);
- if(temp != NULL)
- {
- den_len = strlen(temp);
- if(HUGE_VAL == den_len )
- {
- den_len = 0;
- }
- denominator = static_cast<OMX_U32>(pow(10, den_len));
- numerator = numerator*denominator + atoi(temp);
- }else{
- denominator = 1;
- }
-
- free(tempVal);
-
- exifTags->ulFocalLength[0] = numerator;
- exifTags->ulFocalLength[1] = denominator;
- CAMHAL_LOGVB("exifTags->ulFocalLength = [%u] [%u]",
- (unsigned int)(exifTags->ulFocalLength[0]),
- (unsigned int)(exifTags->ulFocalLength[1]));
- exifTags->eStatusFocalLength = OMX_TI_TagUpdated;
- }
+ unsigned int numerator = 0, denominator = 0;
+ ExifElementsTable::stringToRational(mParams.get(CameraParameters::KEY_FOCAL_LENGTH),
+ &numerator, &denominator);
+ if (numerator || denominator) {
+ exifTags->ulFocalLength[0] = (OMX_U32) numerator;
+ exifTags->ulFocalLength[1] = (OMX_U32) denominator;
+ CAMHAL_LOGVB("exifTags->ulFocalLength = [%u] [%u]",
+ (unsigned int)(exifTags->ulFocalLength[0]),
+ (unsigned int)(exifTags->ulFocalLength[1]));
+ exifTags->eStatusFocalLength = OMX_TI_TagUpdated;
+ }
}
if ( OMX_TI_TagReadWrite == exifTags->eStatusDateTime )
@@ -472,12 +434,12 @@ status_t OMXCameraAdapter::setupEXIF()
( mEXIFData.mGPSData.mProcMethodValid ) )
{
exifTags->pGpsProcessingMethodBuff = ( OMX_S8 * ) ( sharedPtr - sharedBuffer.pSharedBuff );
- memcpy(sharedPtr, EXIFASCIIPrefix, sizeof(EXIFASCIIPrefix));
- sharedPtr += sizeof(EXIFASCIIPrefix);
+ memcpy(sharedPtr, ExifAsciiPrefix, sizeof(ExifAsciiPrefix));
+ sharedPtr += sizeof(ExifAsciiPrefix);
memcpy(sharedPtr,
mEXIFData.mGPSData.mProcMethod,
- ( GPS_PROCESSING_SIZE - sizeof(EXIFASCIIPrefix) ) );
+ ( GPS_PROCESSING_SIZE - sizeof(ExifAsciiPrefix) ) );
exifTags->ulGpsProcessingMethodBuffSizeBytes = GPS_PROCESSING_SIZE;
exifTags->eStatusGpsProcessingMethod = OMX_TI_TagUpdated;
sharedPtr += GPS_PROCESSING_SIZE;
@@ -556,8 +518,17 @@ status_t OMXCameraAdapter::setupEXIF_libjpeg(ExifElementsTable* exifTable)
}
if ((NO_ERROR == ret)) {
- ret = exifTable->insertElement(TAG_FOCALLENGTH,
- mParams.get(CameraParameters::KEY_FOCAL_LENGTH));
+ unsigned int numerator = 0, denominator = 0;
+ ExifElementsTable::stringToRational(mParams.get(CameraParameters::KEY_FOCAL_LENGTH),
+ &numerator, &denominator);
+ if (numerator || denominator) {
+ char temp_value[256]; // arbitrarily long string
+ snprintf(temp_value,
+ sizeof(temp_value)/sizeof(char),
+ "%u/%u", numerator, denominator);
+ ret = exifTable->insertElement(TAG_FOCALLENGTH, temp_value);
+
+ }
}
if ((NO_ERROR == ret)) {
@@ -597,7 +568,7 @@ status_t OMXCameraAdapter::setupEXIF_libjpeg(ExifElementsTable* exifTable)
"%d/%d,%d/%d,%d/%d",
abs(mEXIFData.mGPSData.mLatDeg), 1,
abs(mEXIFData.mGPSData.mLatMin), 1,
- abs(mEXIFData.mGPSData.mLatSec), 1);
+ abs(mEXIFData.mGPSData.mLatSec), abs(mEXIFData.mGPSData.mLatSecDiv));
ret = exifTable->insertElement(TAG_GPS_LAT, temp_value);
}
@@ -612,7 +583,7 @@ status_t OMXCameraAdapter::setupEXIF_libjpeg(ExifElementsTable* exifTable)
"%d/%d,%d/%d,%d/%d",
abs(mEXIFData.mGPSData.mLongDeg), 1,
abs(mEXIFData.mGPSData.mLongMin), 1,
- abs(mEXIFData.mGPSData.mLongSec), 1);
+ abs(mEXIFData.mGPSData.mLongSec), abs(mEXIFData.mGPSData.mLongSecDiv));
ret = exifTable->insertElement(TAG_GPS_LONG, temp_value);
}
@@ -644,11 +615,10 @@ status_t OMXCameraAdapter::setupEXIF_libjpeg(ExifElementsTable* exifTable)
if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mProcMethodValid)) {
char temp_value[GPS_PROCESSING_SIZE];
- memcpy(temp_value, EXIFASCIIPrefix, sizeof(EXIFASCIIPrefix));
- memcpy(temp_value + sizeof(EXIFASCIIPrefix),
- mEXIFData.mGPSData.mProcMethod,
- (GPS_PROCESSING_SIZE - sizeof(EXIFASCIIPrefix)));
-
+ memcpy(temp_value, ExifAsciiPrefix, sizeof(ExifAsciiPrefix));
+ memcpy(temp_value + sizeof(ExifAsciiPrefix),
+ mParams.get(CameraParameters::KEY_GPS_PROCESSING_METHOD),
+ (GPS_PROCESSING_SIZE - sizeof(ExifAsciiPrefix)));
ret = exifTable->insertElement(TAG_GPS_PROCESSING_METHOD, temp_value);
}
diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h
index e44c1b6..2b1f0c9 100644
--- a/camera/inc/CameraHal.h
+++ b/camera/inc/CameraHal.h
@@ -778,6 +778,7 @@ public:
AF_STATE = AF_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
ZOOM_STATE = ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
VIDEO_STATE = VIDEO_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ VIDEO_AF_STATE = VIDEO_ACTIVE | AF_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
VIDEO_ZOOM_STATE = VIDEO_ACTIVE | ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
VIDEO_LOADED_CAPTURE_STATE = VIDEO_ACTIVE | LOADED_CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
VIDEO_CAPTURE_STATE = VIDEO_ACTIVE | CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
diff --git a/camera/inc/Encoder_libjpeg.h b/camera/inc/Encoder_libjpeg.h
index da6382e..e3e9ac5 100755
--- a/camera/inc/Encoder_libjpeg.h
+++ b/camera/inc/Encoder_libjpeg.h
@@ -31,7 +31,6 @@ extern "C" {
#include "jhead.h"
}
namespace android {
-
/**
* libjpeg encoder class - uses libjpeg to encode yuv
*/
@@ -75,6 +74,8 @@ class ExifElementsTable {
status_t insertExifThumbnailImage(const char*, int);
void saveJpeg(unsigned char* picture, size_t jpeg_size);
static const char* degreesToExifOrientation(const char*);
+ static void stringToRational(const char*, unsigned int*, unsigned int*);
+ static bool isAsciiTag(const char* tag);
private:
ExifElement_t table[MAX_EXIF_TAGS_SUPPORTED];
unsigned int gps_tag_count;
@@ -136,10 +137,12 @@ class Encoder_libjpeg : public Thread {
mThumb->join();
mThumb.clear();
mThumb = NULL;
- if(mCb) {
- mCb(mMainInput, mThumbnailInput, mType, mCookie1, mCookie2, mCookie3);
- }
}
+
+ if(mCb) {
+ mCb(mMainInput, mThumbnailInput, mType, mCookie1, mCookie2, mCookie3);
+ }
+
// encoder thread runs, self-destructs, and then exits
this->decStrong(this);
return false;
diff --git a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
index 8c748a8..87e2987 100644
--- a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
+++ b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
@@ -204,9 +204,6 @@ public:
///Five second timeout
static const int CAMERA_ADAPTER_TIMEOUT = 5000*1000;
- //EXIF ASCII prefix
- static const char EXIFASCIIPrefix[];
-
enum OMXCameraEvents
{
CAMERA_PORT_ENABLE = 0x1,