NDKCamera::~NDKCamera() { valid_ = false; // stop session if it is on: if (captureSessionState_ == CaptureSessionState::ACTIVE) { ACameraCaptureSession_stopRepeating(captureSession_); } ACameraCaptureSession_close(captureSession_); for (auto& req : requests_) { CALL_REQUEST(removeTarget(req.request_, req.target_)); ACaptureRequest_free(req.request_); ACameraOutputTarget_free(req.target_); CALL_CONTAINER(remove(outputContainer_, req.sessionOutput_)); ACaptureSessionOutput_free(req.sessionOutput_); ANativeWindow_release(req.outputNativeWindow_); } requests_.resize(0); ACaptureSessionOutputContainer_free(outputContainer_); for (auto& cam : cameras_) { if (cam.second.device_) { CALL_DEV(close(cam.second.device_)); } } cameras_.clear(); if (cameraMgr_) { CALL_MGR(unregisterAvailabilityCallback(cameraMgr_, GetManagerListener())); ACameraManager_delete(cameraMgr_); cameraMgr_ = nullptr; } }
CaptureNdkCameraPrivate::CaptureNdkCameraPrivate(CaptureNdkCamera *self): self(self) { this->m_manager = CameraManagerPtr(ACameraManager_create(), [] (ACameraManager *manager) { ACameraManager_delete(manager); }); }