Loading camera/ndk/NdkCameraDevice.cpp +13 −0 Original line number Original line Diff line number Diff line Loading @@ -287,3 +287,16 @@ camera_status_t ACameraDevice_createCaptureSessionWithSessionParameters( } } return device->createCaptureSession(outputs, sessionParameters, callbacks, session); return device->createCaptureSession(outputs, sessionParameters, callbacks, session); } } EXPORT camera_status_t ACameraDevice_isSessionConfigurationSupported( const ACameraDevice* device, const ACaptureSessionOutputContainer* sessionOutputContainer) { ATRACE_CALL(); if (device == nullptr || sessionOutputContainer == nullptr) { ALOGE("%s: Error: invalid input: device %p, sessionOutputContainer %p", __FUNCTION__, device, sessionOutputContainer); return ACAMERA_ERROR_INVALID_PARAMETER; } return device->isSessionConfigurationSupported(sessionOutputContainer); } camera/ndk/impl/ACameraDevice.cpp +49 −0 Original line number Original line Diff line number Diff line Loading @@ -227,6 +227,55 @@ CameraDevice::createCaptureSession( return ACAMERA_OK; return ACAMERA_OK; } } camera_status_t CameraDevice::isSessionConfigurationSupported( const ACaptureSessionOutputContainer* sessionOutputContainer) const { Mutex::Autolock _l(mDeviceLock); camera_status_t ret = checkCameraClosedOrErrorLocked(); if (ret != ACAMERA_OK) { return ret; } SessionConfiguration sessionConfiguration(0 /*inputWidth*/, 0 /*inputHeight*/, -1 /*inputFormat*/, CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE); for (const auto& output : sessionOutputContainer->mOutputs) { sp<IGraphicBufferProducer> iGBP(nullptr); ret = getIGBPfromAnw(output.mWindow, iGBP); if (ret != ACAMERA_OK) { ALOGE("Camera device %s failed to extract graphic producer from native window", getId()); return ret; } String16 physicalId16(output.mPhysicalCameraId.c_str()); OutputConfiguration outConfig(iGBP, output.mRotation, physicalId16, OutputConfiguration::INVALID_SET_ID, true); for (auto& anw : output.mSharedWindows) { ret = getIGBPfromAnw(anw, iGBP); if (ret != ACAMERA_OK) { ALOGE("Camera device %s failed to extract graphic producer from native window", getId()); return ret; } outConfig.addGraphicProducer(iGBP); } sessionConfiguration.addOutputConfiguration(outConfig); } bool supported = false; binder::Status remoteRet = mRemote->isSessionConfigurationSupported( sessionConfiguration, &supported); if (remoteRet.serviceSpecificErrorCode() == hardware::ICameraService::ERROR_INVALID_OPERATION) { return ACAMERA_ERROR_UNSUPPORTED_OPERATION; } else if (!remoteRet.isOk()) { return ACAMERA_ERROR_UNKNOWN; } else { return supported ? ACAMERA_OK : ACAMERA_ERROR_STREAM_CONFIGURE_FAIL; } } camera_status_t CameraDevice::updateOutputConfigurationLocked(ACaptureSessionOutput *output) { camera_status_t CameraDevice::updateOutputConfigurationLocked(ACaptureSessionOutput *output) { camera_status_t ret = checkCameraClosedOrErrorLocked(); camera_status_t ret = checkCameraClosedOrErrorLocked(); if (ret != ACAMERA_OK) { if (ret != ACAMERA_OK) { Loading camera/ndk/impl/ACameraDevice.h +9 −0 Original line number Original line Diff line number Diff line Loading @@ -35,6 +35,7 @@ #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/foundation/AMessage.h> #include <camera/CaptureResult.h> #include <camera/CaptureResult.h> #include <camera/camera2/OutputConfiguration.h> #include <camera/camera2/OutputConfiguration.h> #include <camera/camera2/SessionConfiguration.h> #include <camera/camera2/CaptureRequest.h> #include <camera/camera2/CaptureRequest.h> #include <camera/NdkCameraManager.h> #include <camera/NdkCameraManager.h> Loading Loading @@ -77,6 +78,9 @@ class CameraDevice final : public RefBase { const ACameraCaptureSession_stateCallbacks* callbacks, const ACameraCaptureSession_stateCallbacks* callbacks, /*out*/ACameraCaptureSession** session); /*out*/ACameraCaptureSession** session); camera_status_t isSessionConfigurationSupported( const ACaptureSessionOutputContainer* sessionOutputContainer) const; // Callbacks from camera service // Callbacks from camera service class ServiceCallback : public hardware::camera2::BnCameraDeviceCallbacks { class ServiceCallback : public hardware::camera2::BnCameraDeviceCallbacks { public: public: Loading Loading @@ -369,6 +373,11 @@ struct ACameraDevice { return mDevice->createCaptureSession(outputs, sessionParameters, callbacks, session); return mDevice->createCaptureSession(outputs, sessionParameters, callbacks, session); } } camera_status_t isSessionConfigurationSupported( const ACaptureSessionOutputContainer* sessionOutputContainer) const { return mDevice->isSessionConfigurationSupported(sessionOutputContainer); } /*********************** /*********************** * Device interal APIs * * Device interal APIs * ***********************/ ***********************/ Loading camera/ndk/include/camera/NdkCameraDevice.h +37 −0 Original line number Original line Diff line number Diff line Loading @@ -845,6 +845,43 @@ camera_status_t ACameraDevice_createCaptureRequest_withPhysicalIds( const ACameraIdList* physicalIdList, const ACameraIdList* physicalIdList, /*out*/ACaptureRequest** request) __INTRODUCED_IN(29); /*out*/ACaptureRequest** request) __INTRODUCED_IN(29); /** * Check whether a particular {@ACaptureSessionOutputContainer} is supported by * the camera device. * * <p>This method performs a runtime check of a given {@link * ACaptureSessionOutputContainer}. The result confirms whether or not the * passed CaptureSession outputs can be successfully used to create a camera * capture session using {@link ACameraDevice_createCaptureSession}.</p> * * <p>This method can be called at any point before, during and after active * capture session. It must not impact normal camera behavior in any way and * must complete significantly faster than creating a capture session.</p> * * <p>Although this method is faster than creating a new capture session, it is not intended * to be used for exploring the entire space of supported stream combinations.</p> * * @param device the camera device of interest * @param sessionOutputContainer the {@link ACaptureSessionOutputContainer} of * interest. * * @return <ul> * <li>{@link ACAMERA_OK} if the given {@link ACaptureSessionOutputContainer} * is supported by the camera device.</li> * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if device, or sessionOutputContainer * is NULL.</li> * <li>{@link ACAMERA_ERROR_STREAM_CONFIGURE_FAIL} if the given * {@link ACaptureSessionOutputContainer} * is not supported by * the camera * device.</li> * <li>{@link ACAMERA_ERROR_UNSUPPORTED_OPERATION} if the query operation is not * supported by the camera device.</li> */ camera_status_t ACameraDevice_isSessionConfigurationSupported( const ACameraDevice* device, const ACaptureSessionOutputContainer* sessionOutputContainer) __INTRODUCED_IN(29); #endif /* __ANDROID_API__ >= 29 */ #endif /* __ANDROID_API__ >= 29 */ __END_DECLS __END_DECLS Loading camera/ndk/include/camera/NdkCameraError.h +7 −1 Original line number Original line Diff line number Diff line Loading @@ -106,7 +106,8 @@ typedef enum { /** /** * Camera device does not support the stream configuration provided by application in * Camera device does not support the stream configuration provided by application in * {@link ACameraDevice_createCaptureSession}. * {@link ACameraDevice_createCaptureSession} or {@link * ACameraDevice_isSessionConfigurationSupported}. */ */ ACAMERA_ERROR_STREAM_CONFIGURE_FAIL = ACAMERA_ERROR_BASE - 9, ACAMERA_ERROR_STREAM_CONFIGURE_FAIL = ACAMERA_ERROR_BASE - 9, Loading @@ -130,6 +131,11 @@ typedef enum { * The application does not have permission to open camera. * The application does not have permission to open camera. */ */ ACAMERA_ERROR_PERMISSION_DENIED = ACAMERA_ERROR_BASE - 13, ACAMERA_ERROR_PERMISSION_DENIED = ACAMERA_ERROR_BASE - 13, /** * The operation is not supported by the camera device. */ ACAMERA_ERROR_UNSUPPORTED_OPERATION = ACAMERA_ERROR_BASE - 14, } camera_status_t; } camera_status_t; #endif /* __ANDROID_API__ >= 24 */ #endif /* __ANDROID_API__ >= 24 */ Loading Loading
camera/ndk/NdkCameraDevice.cpp +13 −0 Original line number Original line Diff line number Diff line Loading @@ -287,3 +287,16 @@ camera_status_t ACameraDevice_createCaptureSessionWithSessionParameters( } } return device->createCaptureSession(outputs, sessionParameters, callbacks, session); return device->createCaptureSession(outputs, sessionParameters, callbacks, session); } } EXPORT camera_status_t ACameraDevice_isSessionConfigurationSupported( const ACameraDevice* device, const ACaptureSessionOutputContainer* sessionOutputContainer) { ATRACE_CALL(); if (device == nullptr || sessionOutputContainer == nullptr) { ALOGE("%s: Error: invalid input: device %p, sessionOutputContainer %p", __FUNCTION__, device, sessionOutputContainer); return ACAMERA_ERROR_INVALID_PARAMETER; } return device->isSessionConfigurationSupported(sessionOutputContainer); }
camera/ndk/impl/ACameraDevice.cpp +49 −0 Original line number Original line Diff line number Diff line Loading @@ -227,6 +227,55 @@ CameraDevice::createCaptureSession( return ACAMERA_OK; return ACAMERA_OK; } } camera_status_t CameraDevice::isSessionConfigurationSupported( const ACaptureSessionOutputContainer* sessionOutputContainer) const { Mutex::Autolock _l(mDeviceLock); camera_status_t ret = checkCameraClosedOrErrorLocked(); if (ret != ACAMERA_OK) { return ret; } SessionConfiguration sessionConfiguration(0 /*inputWidth*/, 0 /*inputHeight*/, -1 /*inputFormat*/, CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE); for (const auto& output : sessionOutputContainer->mOutputs) { sp<IGraphicBufferProducer> iGBP(nullptr); ret = getIGBPfromAnw(output.mWindow, iGBP); if (ret != ACAMERA_OK) { ALOGE("Camera device %s failed to extract graphic producer from native window", getId()); return ret; } String16 physicalId16(output.mPhysicalCameraId.c_str()); OutputConfiguration outConfig(iGBP, output.mRotation, physicalId16, OutputConfiguration::INVALID_SET_ID, true); for (auto& anw : output.mSharedWindows) { ret = getIGBPfromAnw(anw, iGBP); if (ret != ACAMERA_OK) { ALOGE("Camera device %s failed to extract graphic producer from native window", getId()); return ret; } outConfig.addGraphicProducer(iGBP); } sessionConfiguration.addOutputConfiguration(outConfig); } bool supported = false; binder::Status remoteRet = mRemote->isSessionConfigurationSupported( sessionConfiguration, &supported); if (remoteRet.serviceSpecificErrorCode() == hardware::ICameraService::ERROR_INVALID_OPERATION) { return ACAMERA_ERROR_UNSUPPORTED_OPERATION; } else if (!remoteRet.isOk()) { return ACAMERA_ERROR_UNKNOWN; } else { return supported ? ACAMERA_OK : ACAMERA_ERROR_STREAM_CONFIGURE_FAIL; } } camera_status_t CameraDevice::updateOutputConfigurationLocked(ACaptureSessionOutput *output) { camera_status_t CameraDevice::updateOutputConfigurationLocked(ACaptureSessionOutput *output) { camera_status_t ret = checkCameraClosedOrErrorLocked(); camera_status_t ret = checkCameraClosedOrErrorLocked(); if (ret != ACAMERA_OK) { if (ret != ACAMERA_OK) { Loading
camera/ndk/impl/ACameraDevice.h +9 −0 Original line number Original line Diff line number Diff line Loading @@ -35,6 +35,7 @@ #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/foundation/AMessage.h> #include <camera/CaptureResult.h> #include <camera/CaptureResult.h> #include <camera/camera2/OutputConfiguration.h> #include <camera/camera2/OutputConfiguration.h> #include <camera/camera2/SessionConfiguration.h> #include <camera/camera2/CaptureRequest.h> #include <camera/camera2/CaptureRequest.h> #include <camera/NdkCameraManager.h> #include <camera/NdkCameraManager.h> Loading Loading @@ -77,6 +78,9 @@ class CameraDevice final : public RefBase { const ACameraCaptureSession_stateCallbacks* callbacks, const ACameraCaptureSession_stateCallbacks* callbacks, /*out*/ACameraCaptureSession** session); /*out*/ACameraCaptureSession** session); camera_status_t isSessionConfigurationSupported( const ACaptureSessionOutputContainer* sessionOutputContainer) const; // Callbacks from camera service // Callbacks from camera service class ServiceCallback : public hardware::camera2::BnCameraDeviceCallbacks { class ServiceCallback : public hardware::camera2::BnCameraDeviceCallbacks { public: public: Loading Loading @@ -369,6 +373,11 @@ struct ACameraDevice { return mDevice->createCaptureSession(outputs, sessionParameters, callbacks, session); return mDevice->createCaptureSession(outputs, sessionParameters, callbacks, session); } } camera_status_t isSessionConfigurationSupported( const ACaptureSessionOutputContainer* sessionOutputContainer) const { return mDevice->isSessionConfigurationSupported(sessionOutputContainer); } /*********************** /*********************** * Device interal APIs * * Device interal APIs * ***********************/ ***********************/ Loading
camera/ndk/include/camera/NdkCameraDevice.h +37 −0 Original line number Original line Diff line number Diff line Loading @@ -845,6 +845,43 @@ camera_status_t ACameraDevice_createCaptureRequest_withPhysicalIds( const ACameraIdList* physicalIdList, const ACameraIdList* physicalIdList, /*out*/ACaptureRequest** request) __INTRODUCED_IN(29); /*out*/ACaptureRequest** request) __INTRODUCED_IN(29); /** * Check whether a particular {@ACaptureSessionOutputContainer} is supported by * the camera device. * * <p>This method performs a runtime check of a given {@link * ACaptureSessionOutputContainer}. The result confirms whether or not the * passed CaptureSession outputs can be successfully used to create a camera * capture session using {@link ACameraDevice_createCaptureSession}.</p> * * <p>This method can be called at any point before, during and after active * capture session. It must not impact normal camera behavior in any way and * must complete significantly faster than creating a capture session.</p> * * <p>Although this method is faster than creating a new capture session, it is not intended * to be used for exploring the entire space of supported stream combinations.</p> * * @param device the camera device of interest * @param sessionOutputContainer the {@link ACaptureSessionOutputContainer} of * interest. * * @return <ul> * <li>{@link ACAMERA_OK} if the given {@link ACaptureSessionOutputContainer} * is supported by the camera device.</li> * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if device, or sessionOutputContainer * is NULL.</li> * <li>{@link ACAMERA_ERROR_STREAM_CONFIGURE_FAIL} if the given * {@link ACaptureSessionOutputContainer} * is not supported by * the camera * device.</li> * <li>{@link ACAMERA_ERROR_UNSUPPORTED_OPERATION} if the query operation is not * supported by the camera device.</li> */ camera_status_t ACameraDevice_isSessionConfigurationSupported( const ACameraDevice* device, const ACaptureSessionOutputContainer* sessionOutputContainer) __INTRODUCED_IN(29); #endif /* __ANDROID_API__ >= 29 */ #endif /* __ANDROID_API__ >= 29 */ __END_DECLS __END_DECLS Loading
camera/ndk/include/camera/NdkCameraError.h +7 −1 Original line number Original line Diff line number Diff line Loading @@ -106,7 +106,8 @@ typedef enum { /** /** * Camera device does not support the stream configuration provided by application in * Camera device does not support the stream configuration provided by application in * {@link ACameraDevice_createCaptureSession}. * {@link ACameraDevice_createCaptureSession} or {@link * ACameraDevice_isSessionConfigurationSupported}. */ */ ACAMERA_ERROR_STREAM_CONFIGURE_FAIL = ACAMERA_ERROR_BASE - 9, ACAMERA_ERROR_STREAM_CONFIGURE_FAIL = ACAMERA_ERROR_BASE - 9, Loading @@ -130,6 +131,11 @@ typedef enum { * The application does not have permission to open camera. * The application does not have permission to open camera. */ */ ACAMERA_ERROR_PERMISSION_DENIED = ACAMERA_ERROR_BASE - 13, ACAMERA_ERROR_PERMISSION_DENIED = ACAMERA_ERROR_BASE - 13, /** * The operation is not supported by the camera device. */ ACAMERA_ERROR_UNSUPPORTED_OPERATION = ACAMERA_ERROR_BASE - 14, } camera_status_t; } camera_status_t; #endif /* __ANDROID_API__ >= 24 */ #endif /* __ANDROID_API__ >= 24 */ Loading