@@ -233,6 +233,13 @@ CameraDevice::~CameraDevice()
delete it.second;
}
+std::shared_ptr<CameraDevice> CameraDevice::create(unsigned int id,
+ const std::shared_ptr<Camera> &cam)
+{
+ CameraDevice *camera = new CameraDevice(id, cam);
+ return std::shared_ptr<CameraDevice>(camera);
+}
+
/*
* Initialize the camera static information.
* This method is called before the camera device is opened.
@@ -47,7 +47,8 @@ struct CameraStream {
class CameraDevice : protected libcamera::Loggable
{
public:
- CameraDevice(unsigned int id, const std::shared_ptr<libcamera::Camera> &camera);
+ static std::shared_ptr<CameraDevice> create(unsigned int id,
+ const std::shared_ptr<libcamera::Camera> &cam);
~CameraDevice();
int initialize();
@@ -72,6 +73,8 @@ protected:
std::string logPrefix() const override;
private:
+ CameraDevice(unsigned int id, const std::shared_ptr<libcamera::Camera> &camera);
+
struct Camera3RequestDescriptor {
Camera3RequestDescriptor(unsigned int frameNumber,
unsigned int numBuffers);
@@ -64,12 +64,12 @@ int CameraHalManager::init()
*/
unsigned int index = 0;
for (auto &cam : cameraManager_->cameras()) {
- CameraDevice *camera = new CameraDevice(index, cam);
+ std::shared_ptr<CameraDevice> camera = CameraDevice::create(index, cam);
ret = camera->initialize();
if (ret)
continue;
- cameras_.emplace_back(camera);
+ cameras_.emplace_back(std::move(camera));
++index;
}
@@ -36,7 +36,7 @@ private:
libcamera::CameraManager *cameraManager_;
const camera_module_callbacks_t *callbacks_;
- std::vector<std::unique_ptr<CameraDevice>> cameras_;
+ std::vector<std::shared_ptr<CameraDevice>> cameras_;
};
#endif /* __ANDROID_CAMERA_MANAGER_H__ */