|
|
|
@ -62,12 +62,12 @@ static void onImageAvailable(void* context, AImageReader* reader)
|
|
|
|
|
|
|
|
|
|
static void onSessionActive(void* context, ACameraCaptureSession *session)
|
|
|
|
|
{
|
|
|
|
|
ALOGW("onSessionActive %p", session);
|
|
|
|
|
ALOGD("onSessionActive %p", session);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void onSessionReady(void* context, ACameraCaptureSession *session)
|
|
|
|
|
{
|
|
|
|
|
ALOGW("onSessionReady %p", session);
|
|
|
|
|
ALOGD("onSessionReady %p", session);
|
|
|
|
|
((NdkCamera*)context)->onSessionReady(session);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -83,12 +83,12 @@ void onCaptureFailed(void* context, ACameraCaptureSession* session, ACaptureRequ
|
|
|
|
|
|
|
|
|
|
void onCaptureSequenceCompleted(void* context, ACameraCaptureSession* session, int sequenceId, int64_t frameNumber)
|
|
|
|
|
{
|
|
|
|
|
ALOGW("onCaptureSequenceCompleted %p %d %ld", session, sequenceId, frameNumber);
|
|
|
|
|
ALOGD("onCaptureSequenceCompleted %p %d %ld", session, sequenceId, frameNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void onCaptureSequenceAborted(void* context, ACameraCaptureSession* session, int sequenceId)
|
|
|
|
|
{
|
|
|
|
|
ALOGW("onCaptureSequenceAborted %p %d", session, sequenceId);
|
|
|
|
|
ALOGD("onCaptureSequenceAborted %p %d", session, sequenceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void onCaptureProgressed(void* context, ACameraCaptureSession* session, ACaptureRequest* request, const ACameraMetadata* result)
|
|
|
|
@ -102,7 +102,7 @@ void onCaptureProgressed(void* context, ACameraCaptureSession* session, ACapture
|
|
|
|
|
{
|
|
|
|
|
uint8_t afState = *(val.data.u8);
|
|
|
|
|
|
|
|
|
|
ALOGW("onCaptureProgressed AF_STATE=%u", (unsigned int)afState);
|
|
|
|
|
ALOGD("onCaptureProgressed AF_STATE=%u", (unsigned int)afState);
|
|
|
|
|
|
|
|
|
|
// ((NdkCamera*)context)->onCaptureProgressed(session, request, result);
|
|
|
|
|
}
|
|
|
|
@ -400,7 +400,7 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
|
|
|
|
|
// setup imagereader and its surface
|
|
|
|
|
{
|
|
|
|
|
media_status_t mstatus = AImageReader_new(foundRes.width(), foundRes.height(), AIMAGE_FORMAT_YUV_420_888, /*maxImages*/1, &image_reader);
|
|
|
|
|
media_status_t mstatus = AImageReader_new(foundRes.width(), foundRes.height(), AIMAGE_FORMAT_YUV_420_888, /*maxImages*/2, &image_reader);
|
|
|
|
|
|
|
|
|
|
if (mstatus == AMEDIA_OK)
|
|
|
|
|
{
|
|
|
|
@ -451,7 +451,7 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AF_MODE, 1, &afMode);
|
|
|
|
|
|
|
|
|
|
uint8_t trig = ACAMERA_CONTROL_AF_TRIGGER_START;
|
|
|
|
|
status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AF_TRIGGER, 1, &trig);
|
|
|
|
|
// status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AF_TRIGGER, 1, &trig);
|
|
|
|
|
m_imagesCaptured = (status == ACAMERA_OK) ? ~0 : 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -522,6 +522,8 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
{
|
|
|
|
|
status = ACameraCaptureSession_capture(capture_session, &camera_capture_session_capture_callbacks, 1, &capture_request, &captureSequenceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_startTime = GetMicroTimeStamp();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return status == ACAMERA_OK ? 0 : 1;
|
|
|
|
@ -602,7 +604,7 @@ void NdkCamera::close()
|
|
|
|
|
|
|
|
|
|
void NdkCamera::onImageAvailable(AImageReader* reader)
|
|
|
|
|
{
|
|
|
|
|
ALOGW("onImageAvailable %p", reader);
|
|
|
|
|
ALOGD("onImageAvailable %p", reader);
|
|
|
|
|
|
|
|
|
|
AImage* image = 0;
|
|
|
|
|
media_status_t status = AImageReader_acquireLatestImage(reader, &image);
|
|
|
|
@ -848,12 +850,21 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
val = { 0 };
|
|
|
|
|
status = ACameraMetadata_getConstEntry(result, ACAMERA_CONTROL_AF_STATE, &val);
|
|
|
|
|
afState = *(val.data.u8);
|
|
|
|
|
ALOGW("onCaptureCompleted AF_STATE=%u", (unsigned int)afState);
|
|
|
|
|
ALOGD("onCaptureCompleted AF_STATE=%u", (unsigned int)afState);
|
|
|
|
|
if (afState == ACAMERA_CONTROL_AF_STATE_PASSIVE_FOCUSED || afState == ACAMERA_CONTROL_AF_STATE_FOCUSED_LOCKED)
|
|
|
|
|
// if (afState != ACAMERA_CONTROL_AF_STATE_INACTIVE)
|
|
|
|
|
{
|
|
|
|
|
m_imagesCaptured = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
unsigned long long ts = GetMicroTimeStamp();
|
|
|
|
|
if (ts - m_startTime >= 1000)
|
|
|
|
|
{
|
|
|
|
|
ALOGD("onCaptureCompleted Timeout for AutoFocus And will Capture AF_STATE=%u", (unsigned int)afState);
|
|
|
|
|
m_imagesCaptured = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -893,7 +904,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
status = ACameraMetadata_getConstEntry(result, ACAMERA_CONTROL_AF_STATE, &val);
|
|
|
|
|
mResult.afState = *(val.data.u8);
|
|
|
|
|
|
|
|
|
|
ALOGW("onCaptureCompleted AF_STATE=%u", (unsigned int)afState);
|
|
|
|
|
ALOGD("onCaptureCompleted AF_STATE=%u", (unsigned int)afState);
|
|
|
|
|
|
|
|
|
|
val = {0};
|
|
|
|
|
status = ACameraMetadata_getConstEntry(result, ACAMERA_SENSOR_SENSITIVITY, &val);
|
|
|
|
|