Loading camera/CaptureResult.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,16 @@ status_t CaptureResultExtras::readFromParcel(const android::Parcel *parcel) { parcel->readInt64(&frameNumber); parcel->readInt32(&partialResultCount); parcel->readInt32(&errorStreamId); auto physicalCameraIdPresent = parcel->readBool(); if (physicalCameraIdPresent) { String16 cameraId; status_t res = OK; if ((res = parcel->readString16(&cameraId)) != OK) { ALOGE("%s: Failed to read camera id: %d", __FUNCTION__, res); return res; } errorPhysicalCameraId = cameraId; } return OK; } Loading @@ -56,6 +66,16 @@ status_t CaptureResultExtras::writeToParcel(android::Parcel *parcel) const { parcel->writeInt64(frameNumber); parcel->writeInt32(partialResultCount); parcel->writeInt32(errorStreamId); if (errorPhysicalCameraId.size() > 0) { parcel->writeBool(true); status_t res = OK; if ((res = parcel->writeString16(errorPhysicalCameraId)) != OK) { ALOGE("%s: Failed to write physical camera ID to parcel: %d", __FUNCTION__, res); return res; } } else { parcel->writeBool(false); } return OK; } Loading camera/include/camera/CaptureResult.h +9 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,13 @@ struct CaptureResultExtras : public android::Parcelable { */ int32_t errorStreamId; /** * For capture result errors, the physical camera ID in case the respective request contains * a reference to physical camera device. * Empty otherwise. */ String16 errorPhysicalCameraId; /** * Constructor initializes object as invalid by setting requestId to be -1. */ Loading @@ -79,7 +86,8 @@ struct CaptureResultExtras : public android::Parcelable { precaptureTriggerId(0), frameNumber(0), partialResultCount(0), errorStreamId(-1) { errorStreamId(-1), errorPhysicalCameraId() { } /** Loading camera/ndk/impl/ACameraDevice.cpp +50 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ const char* CameraDevice::kCaptureFailureKey = "CaptureFailure"; const char* CameraDevice::kSequenceIdKey = "SequenceId"; const char* CameraDevice::kFrameNumberKey = "FrameNumber"; const char* CameraDevice::kAnwKey = "Anw"; const char* CameraDevice::kFailingPhysicalCameraId= "FailingPhysicalCameraId"; /** * CameraDevice Implementation Loading Loading @@ -867,10 +868,19 @@ CameraDevice::onCaptureErrorLocked( failure->wasImageCaptured = (errorCode == hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_RESULT); sp<AMessage> msg = new AMessage(kWhatCaptureFail, mHandler); sp<AMessage> msg = new AMessage(cbh.mIsLogicalCameraCallback ? kWhatLogicalCaptureFail : kWhatCaptureFail, mHandler); msg->setPointer(kContextKey, cbh.mContext); msg->setObject(kSessionSpKey, session); if (cbh.mIsLogicalCameraCallback) { if (resultExtras.errorPhysicalCameraId.size() > 0) { String8 cameraId(resultExtras.errorPhysicalCameraId); msg->setString(kFailingPhysicalCameraId, cameraId.string(), cameraId.size()); } msg->setPointer(kCallbackFpKey, (void*) cbh.mOnLogicalCameraCaptureFailed); } else { msg->setPointer(kCallbackFpKey, (void*) onError); } msg->setObject(kCaptureRequestKey, request); msg->setObject(kCaptureFailureKey, failure); postSessionMsgAndCleanup(msg); Loading @@ -895,6 +905,7 @@ void CameraDevice::CallbackHandler::onMessageReceived( case kWhatCaptureResult: case kWhatLogicalCaptureResult: case kWhatCaptureFail: case kWhatLogicalCaptureFail: case kWhatCaptureSeqEnd: case kWhatCaptureSeqAbort: case kWhatCaptureBufferLost: Loading Loading @@ -966,6 +977,7 @@ void CameraDevice::CallbackHandler::onMessageReceived( case kWhatCaptureResult: case kWhatLogicalCaptureResult: case kWhatCaptureFail: case kWhatLogicalCaptureFail: case kWhatCaptureSeqEnd: case kWhatCaptureSeqAbort: case kWhatCaptureBufferLost: Loading @@ -984,6 +996,7 @@ void CameraDevice::CallbackHandler::onMessageReceived( case kWhatCaptureResult: case kWhatLogicalCaptureResult: case kWhatCaptureFail: case kWhatLogicalCaptureFail: case kWhatCaptureBufferLost: found = msg->findObject(kCaptureRequestKey, &obj); if (!found) { Loading Loading @@ -1138,6 +1151,39 @@ void CameraDevice::CallbackHandler::onMessageReceived( freeACaptureRequest(request); break; } case kWhatLogicalCaptureFail: { ACameraCaptureSession_logicalCamera_captureCallback_failed onFail; found = msg->findPointer(kCallbackFpKey, (void**) &onFail); if (!found) { ALOGE("%s: Cannot find capture fail callback!", __FUNCTION__); return; } if (onFail == nullptr) { return; } found = msg->findObject(kCaptureFailureKey, &obj); if (!found) { ALOGE("%s: Cannot find capture failure!", __FUNCTION__); return; } sp<CameraCaptureFailure> failureSp( static_cast<CameraCaptureFailure*>(obj.get())); ALogicalCameraCaptureFailure failure; AString physicalCameraId; found = msg->findString(kFailingPhysicalCameraId, &physicalCameraId); if (found && !physicalCameraId.empty()) { failure.physicalCameraId = physicalCameraId.c_str(); } else { failure.physicalCameraId = nullptr; } failure.captureFailure = *failureSp; ACaptureRequest* request = allocateACaptureRequest(requestSp, mId); (*onFail)(context, session.get(), request, &failure); freeACaptureRequest(request); break; } case kWhatCaptureSeqEnd: { ACameraCaptureSession_captureCallback_sequenceEnd onSeqEnd; Loading Loading @@ -1233,6 +1279,7 @@ CameraDevice::CallbackHolder::CallbackHolder( if (cbs != nullptr) { mOnCaptureCompleted = cbs->onCaptureCompleted; mOnCaptureFailed = cbs->onCaptureFailed; } } Loading @@ -1248,6 +1295,7 @@ CameraDevice::CallbackHolder::CallbackHolder( if (lcbs != nullptr) { mOnLogicalCameraCaptureCompleted = lcbs->onLogicalCameraCaptureCompleted; mOnLogicalCameraCaptureFailed = lcbs->onLogicalCameraCaptureFailed; } } Loading camera/ndk/impl/ACameraDevice.h +4 −1 Original line number Diff line number Diff line Loading @@ -214,6 +214,7 @@ class CameraDevice final : public RefBase { kWhatCaptureResult, // onCaptureProgressed, onCaptureCompleted kWhatLogicalCaptureResult, // onLogicalCameraCaptureCompleted kWhatCaptureFail, // onCaptureFailed kWhatLogicalCaptureFail, // onLogicalCameraCaptureFailed kWhatCaptureSeqEnd, // onCaptureSequenceCompleted kWhatCaptureSeqAbort, // onCaptureSequenceAborted kWhatCaptureBufferLost,// onCaptureBufferLost Loading @@ -233,6 +234,7 @@ class CameraDevice final : public RefBase { static const char* kSequenceIdKey; static const char* kFrameNumberKey; static const char* kAnwKey; static const char* kFailingPhysicalCameraId; class CallbackHandler : public AHandler { public: Loading Loading @@ -281,6 +283,7 @@ class CameraDevice final : public RefBase { mOnCaptureProgressed = nullptr; mOnCaptureCompleted = nullptr; mOnLogicalCameraCaptureCompleted = nullptr; mOnLogicalCameraCaptureFailed = nullptr; mOnCaptureFailed = nullptr; mOnCaptureSequenceCompleted = nullptr; mOnCaptureSequenceAborted = nullptr; Loading @@ -289,7 +292,6 @@ class CameraDevice final : public RefBase { mContext = cbs->context; mOnCaptureStarted = cbs->onCaptureStarted; mOnCaptureProgressed = cbs->onCaptureProgressed; mOnCaptureFailed = cbs->onCaptureFailed; mOnCaptureSequenceCompleted = cbs->onCaptureSequenceCompleted; mOnCaptureSequenceAborted = cbs->onCaptureSequenceAborted; mOnCaptureBufferLost = cbs->onCaptureBufferLost; Loading @@ -305,6 +307,7 @@ class CameraDevice final : public RefBase { ACameraCaptureSession_captureCallback_result mOnCaptureProgressed; ACameraCaptureSession_captureCallback_result mOnCaptureCompleted; ACameraCaptureSession_logicalCamera_captureCallback_result mOnLogicalCameraCaptureCompleted; ACameraCaptureSession_logicalCamera_captureCallback_failed mOnLogicalCameraCaptureFailed; ACameraCaptureSession_captureCallback_failed mOnCaptureFailed; ACameraCaptureSession_captureCallback_sequenceEnd mOnCaptureSequenceCompleted; ACameraCaptureSession_captureCallback_sequenceAbort mOnCaptureSequenceAborted; Loading camera/ndk/include/camera/NdkCameraCaptureSession.h +51 −1 Original line number Diff line number Diff line Loading @@ -676,6 +676,41 @@ typedef void (*ACameraCaptureSession_logicalCamera_captureCallback_result)( size_t physicalResultCount, const char** physicalCameraIds, const ACameraMetadata** physicalResults); /// Struct to describe a logical camera capture failure typedef struct ALogicalCameraCaptureFailure { /** * The {@link ACameraCaptureFailure} contains information about regular logical device capture * failure. */ struct ACameraCaptureFailure captureFailure; /** * The physical camera device ID in case the capture failure comes from a capture request * with configured physical camera streams for a logical camera. physicalCameraId will be set * to NULL in case the capture request has no associated physical camera device. * */ const char* physicalCameraId; } ALogicalCameraCaptureFailure; /** * The definition of logical camera capture failure callback. * * @param context The optional application context provided by user in * {@link ACameraCaptureSession_captureCallbacks}. * @param session The camera capture session of interest. * @param request The capture request of interest. Note that this pointer points to a copy of * capture request sent by application, so the address is different to what * application sent but the content will match. This request will be freed by * framework immediately after this callback returns. * @param failure The {@link ALogicalCameraCaptureFailure} desribes the capture failure. The memory * is managed by camera framework. Do not access this pointer after this callback * returns. */ typedef void (*ACameraCaptureSession_logicalCamera_captureCallback_failed)( void* context, ACameraCaptureSession* session, ACaptureRequest* request, ALogicalCameraCaptureFailure* failure); /** * This has the same functionality as ACameraCaptureSession_captureCallbacks, * with the exception that an onLogicalCameraCaptureCompleted callback is Loading Loading @@ -707,10 +742,25 @@ typedef struct ACameraCaptureSession_logicalCamera_captureCallbacks { */ ACameraCaptureSession_logicalCamera_captureCallback_result onLogicalCameraCaptureCompleted; /** * This callback is called instead of {@link onLogicalCameraCaptureCompleted} when the * camera device failed to produce a capture result for the * request. * * <p>Other requests are unaffected, and some or all image buffers from * the capture may have been pushed to their respective output * streams.</p> * * <p>Note that the ACaptureRequest pointer in the callback will not match what application has * submitted, but the contents the ACaptureRequest will match what application submitted.</p> * * @see ALogicalCameraCaptureFailure */ ACameraCaptureSession_logicalCamera_captureCallback_failed onLogicalCameraCaptureFailed; /** * Same as ACameraCaptureSession_captureCallbacks */ ACameraCaptureSession_captureCallback_failed onCaptureFailed; ACameraCaptureSession_captureCallback_sequenceEnd onCaptureSequenceCompleted; ACameraCaptureSession_captureCallback_sequenceAbort onCaptureSequenceAborted; ACameraCaptureSession_captureCallback_bufferLost onCaptureBufferLost; Loading Loading
camera/CaptureResult.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,16 @@ status_t CaptureResultExtras::readFromParcel(const android::Parcel *parcel) { parcel->readInt64(&frameNumber); parcel->readInt32(&partialResultCount); parcel->readInt32(&errorStreamId); auto physicalCameraIdPresent = parcel->readBool(); if (physicalCameraIdPresent) { String16 cameraId; status_t res = OK; if ((res = parcel->readString16(&cameraId)) != OK) { ALOGE("%s: Failed to read camera id: %d", __FUNCTION__, res); return res; } errorPhysicalCameraId = cameraId; } return OK; } Loading @@ -56,6 +66,16 @@ status_t CaptureResultExtras::writeToParcel(android::Parcel *parcel) const { parcel->writeInt64(frameNumber); parcel->writeInt32(partialResultCount); parcel->writeInt32(errorStreamId); if (errorPhysicalCameraId.size() > 0) { parcel->writeBool(true); status_t res = OK; if ((res = parcel->writeString16(errorPhysicalCameraId)) != OK) { ALOGE("%s: Failed to write physical camera ID to parcel: %d", __FUNCTION__, res); return res; } } else { parcel->writeBool(false); } return OK; } Loading
camera/include/camera/CaptureResult.h +9 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,13 @@ struct CaptureResultExtras : public android::Parcelable { */ int32_t errorStreamId; /** * For capture result errors, the physical camera ID in case the respective request contains * a reference to physical camera device. * Empty otherwise. */ String16 errorPhysicalCameraId; /** * Constructor initializes object as invalid by setting requestId to be -1. */ Loading @@ -79,7 +86,8 @@ struct CaptureResultExtras : public android::Parcelable { precaptureTriggerId(0), frameNumber(0), partialResultCount(0), errorStreamId(-1) { errorStreamId(-1), errorPhysicalCameraId() { } /** Loading
camera/ndk/impl/ACameraDevice.cpp +50 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ const char* CameraDevice::kCaptureFailureKey = "CaptureFailure"; const char* CameraDevice::kSequenceIdKey = "SequenceId"; const char* CameraDevice::kFrameNumberKey = "FrameNumber"; const char* CameraDevice::kAnwKey = "Anw"; const char* CameraDevice::kFailingPhysicalCameraId= "FailingPhysicalCameraId"; /** * CameraDevice Implementation Loading Loading @@ -867,10 +868,19 @@ CameraDevice::onCaptureErrorLocked( failure->wasImageCaptured = (errorCode == hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_RESULT); sp<AMessage> msg = new AMessage(kWhatCaptureFail, mHandler); sp<AMessage> msg = new AMessage(cbh.mIsLogicalCameraCallback ? kWhatLogicalCaptureFail : kWhatCaptureFail, mHandler); msg->setPointer(kContextKey, cbh.mContext); msg->setObject(kSessionSpKey, session); if (cbh.mIsLogicalCameraCallback) { if (resultExtras.errorPhysicalCameraId.size() > 0) { String8 cameraId(resultExtras.errorPhysicalCameraId); msg->setString(kFailingPhysicalCameraId, cameraId.string(), cameraId.size()); } msg->setPointer(kCallbackFpKey, (void*) cbh.mOnLogicalCameraCaptureFailed); } else { msg->setPointer(kCallbackFpKey, (void*) onError); } msg->setObject(kCaptureRequestKey, request); msg->setObject(kCaptureFailureKey, failure); postSessionMsgAndCleanup(msg); Loading @@ -895,6 +905,7 @@ void CameraDevice::CallbackHandler::onMessageReceived( case kWhatCaptureResult: case kWhatLogicalCaptureResult: case kWhatCaptureFail: case kWhatLogicalCaptureFail: case kWhatCaptureSeqEnd: case kWhatCaptureSeqAbort: case kWhatCaptureBufferLost: Loading Loading @@ -966,6 +977,7 @@ void CameraDevice::CallbackHandler::onMessageReceived( case kWhatCaptureResult: case kWhatLogicalCaptureResult: case kWhatCaptureFail: case kWhatLogicalCaptureFail: case kWhatCaptureSeqEnd: case kWhatCaptureSeqAbort: case kWhatCaptureBufferLost: Loading @@ -984,6 +996,7 @@ void CameraDevice::CallbackHandler::onMessageReceived( case kWhatCaptureResult: case kWhatLogicalCaptureResult: case kWhatCaptureFail: case kWhatLogicalCaptureFail: case kWhatCaptureBufferLost: found = msg->findObject(kCaptureRequestKey, &obj); if (!found) { Loading Loading @@ -1138,6 +1151,39 @@ void CameraDevice::CallbackHandler::onMessageReceived( freeACaptureRequest(request); break; } case kWhatLogicalCaptureFail: { ACameraCaptureSession_logicalCamera_captureCallback_failed onFail; found = msg->findPointer(kCallbackFpKey, (void**) &onFail); if (!found) { ALOGE("%s: Cannot find capture fail callback!", __FUNCTION__); return; } if (onFail == nullptr) { return; } found = msg->findObject(kCaptureFailureKey, &obj); if (!found) { ALOGE("%s: Cannot find capture failure!", __FUNCTION__); return; } sp<CameraCaptureFailure> failureSp( static_cast<CameraCaptureFailure*>(obj.get())); ALogicalCameraCaptureFailure failure; AString physicalCameraId; found = msg->findString(kFailingPhysicalCameraId, &physicalCameraId); if (found && !physicalCameraId.empty()) { failure.physicalCameraId = physicalCameraId.c_str(); } else { failure.physicalCameraId = nullptr; } failure.captureFailure = *failureSp; ACaptureRequest* request = allocateACaptureRequest(requestSp, mId); (*onFail)(context, session.get(), request, &failure); freeACaptureRequest(request); break; } case kWhatCaptureSeqEnd: { ACameraCaptureSession_captureCallback_sequenceEnd onSeqEnd; Loading Loading @@ -1233,6 +1279,7 @@ CameraDevice::CallbackHolder::CallbackHolder( if (cbs != nullptr) { mOnCaptureCompleted = cbs->onCaptureCompleted; mOnCaptureFailed = cbs->onCaptureFailed; } } Loading @@ -1248,6 +1295,7 @@ CameraDevice::CallbackHolder::CallbackHolder( if (lcbs != nullptr) { mOnLogicalCameraCaptureCompleted = lcbs->onLogicalCameraCaptureCompleted; mOnLogicalCameraCaptureFailed = lcbs->onLogicalCameraCaptureFailed; } } Loading
camera/ndk/impl/ACameraDevice.h +4 −1 Original line number Diff line number Diff line Loading @@ -214,6 +214,7 @@ class CameraDevice final : public RefBase { kWhatCaptureResult, // onCaptureProgressed, onCaptureCompleted kWhatLogicalCaptureResult, // onLogicalCameraCaptureCompleted kWhatCaptureFail, // onCaptureFailed kWhatLogicalCaptureFail, // onLogicalCameraCaptureFailed kWhatCaptureSeqEnd, // onCaptureSequenceCompleted kWhatCaptureSeqAbort, // onCaptureSequenceAborted kWhatCaptureBufferLost,// onCaptureBufferLost Loading @@ -233,6 +234,7 @@ class CameraDevice final : public RefBase { static const char* kSequenceIdKey; static const char* kFrameNumberKey; static const char* kAnwKey; static const char* kFailingPhysicalCameraId; class CallbackHandler : public AHandler { public: Loading Loading @@ -281,6 +283,7 @@ class CameraDevice final : public RefBase { mOnCaptureProgressed = nullptr; mOnCaptureCompleted = nullptr; mOnLogicalCameraCaptureCompleted = nullptr; mOnLogicalCameraCaptureFailed = nullptr; mOnCaptureFailed = nullptr; mOnCaptureSequenceCompleted = nullptr; mOnCaptureSequenceAborted = nullptr; Loading @@ -289,7 +292,6 @@ class CameraDevice final : public RefBase { mContext = cbs->context; mOnCaptureStarted = cbs->onCaptureStarted; mOnCaptureProgressed = cbs->onCaptureProgressed; mOnCaptureFailed = cbs->onCaptureFailed; mOnCaptureSequenceCompleted = cbs->onCaptureSequenceCompleted; mOnCaptureSequenceAborted = cbs->onCaptureSequenceAborted; mOnCaptureBufferLost = cbs->onCaptureBufferLost; Loading @@ -305,6 +307,7 @@ class CameraDevice final : public RefBase { ACameraCaptureSession_captureCallback_result mOnCaptureProgressed; ACameraCaptureSession_captureCallback_result mOnCaptureCompleted; ACameraCaptureSession_logicalCamera_captureCallback_result mOnLogicalCameraCaptureCompleted; ACameraCaptureSession_logicalCamera_captureCallback_failed mOnLogicalCameraCaptureFailed; ACameraCaptureSession_captureCallback_failed mOnCaptureFailed; ACameraCaptureSession_captureCallback_sequenceEnd mOnCaptureSequenceCompleted; ACameraCaptureSession_captureCallback_sequenceAbort mOnCaptureSequenceAborted; Loading
camera/ndk/include/camera/NdkCameraCaptureSession.h +51 −1 Original line number Diff line number Diff line Loading @@ -676,6 +676,41 @@ typedef void (*ACameraCaptureSession_logicalCamera_captureCallback_result)( size_t physicalResultCount, const char** physicalCameraIds, const ACameraMetadata** physicalResults); /// Struct to describe a logical camera capture failure typedef struct ALogicalCameraCaptureFailure { /** * The {@link ACameraCaptureFailure} contains information about regular logical device capture * failure. */ struct ACameraCaptureFailure captureFailure; /** * The physical camera device ID in case the capture failure comes from a capture request * with configured physical camera streams for a logical camera. physicalCameraId will be set * to NULL in case the capture request has no associated physical camera device. * */ const char* physicalCameraId; } ALogicalCameraCaptureFailure; /** * The definition of logical camera capture failure callback. * * @param context The optional application context provided by user in * {@link ACameraCaptureSession_captureCallbacks}. * @param session The camera capture session of interest. * @param request The capture request of interest. Note that this pointer points to a copy of * capture request sent by application, so the address is different to what * application sent but the content will match. This request will be freed by * framework immediately after this callback returns. * @param failure The {@link ALogicalCameraCaptureFailure} desribes the capture failure. The memory * is managed by camera framework. Do not access this pointer after this callback * returns. */ typedef void (*ACameraCaptureSession_logicalCamera_captureCallback_failed)( void* context, ACameraCaptureSession* session, ACaptureRequest* request, ALogicalCameraCaptureFailure* failure); /** * This has the same functionality as ACameraCaptureSession_captureCallbacks, * with the exception that an onLogicalCameraCaptureCompleted callback is Loading Loading @@ -707,10 +742,25 @@ typedef struct ACameraCaptureSession_logicalCamera_captureCallbacks { */ ACameraCaptureSession_logicalCamera_captureCallback_result onLogicalCameraCaptureCompleted; /** * This callback is called instead of {@link onLogicalCameraCaptureCompleted} when the * camera device failed to produce a capture result for the * request. * * <p>Other requests are unaffected, and some or all image buffers from * the capture may have been pushed to their respective output * streams.</p> * * <p>Note that the ACaptureRequest pointer in the callback will not match what application has * submitted, but the contents the ACaptureRequest will match what application submitted.</p> * * @see ALogicalCameraCaptureFailure */ ACameraCaptureSession_logicalCamera_captureCallback_failed onLogicalCameraCaptureFailed; /** * Same as ACameraCaptureSession_captureCallbacks */ ACameraCaptureSession_captureCallback_failed onCaptureFailed; ACameraCaptureSession_captureCallback_sequenceEnd onCaptureSequenceCompleted; ACameraCaptureSession_captureCallback_sequenceAbort onCaptureSequenceAborted; ACameraCaptureSession_captureCallback_bufferLost onCaptureBufferLost; Loading