Files
external_libcamera/include/libcamera/internal/camera.h
Laurent Pinchart 32b8832e38 libcamera: camera: Pass Private pointer to Camera constructor
In order to allow subclassing Camera::Private in pipeline handlers, pass
the pointer to the private data to the Camera constructor, and to the
Camera::createCamera() function.

The Camera::Private id_ and streams_ members now need to be initialized
by the Camera constructor instead of the Camera::Private constructor, to
allow storage of the streams in a pipeline handler-specific subclass of
Camera::Private.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-08-16 23:57:28 +03:00

63 lines
1.2 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2021, Google Inc.
*
* camera.h - Camera private data
*/
#ifndef __LIBCAMERA_INTERNAL_CAMERA_H__
#define __LIBCAMERA_INTERNAL_CAMERA_H__
#include <atomic>
#include <memory>
#include <set>
#include <string>
#include <libcamera/base/class.h>
#include <libcamera/camera.h>
namespace libcamera {
class PipelineHandler;
class Stream;
class Camera::Private : public Extensible::Private
{
LIBCAMERA_DECLARE_PUBLIC(Camera)
public:
Private(PipelineHandler *pipe);
~Private();
private:
enum State {
CameraAvailable,
CameraAcquired,
CameraConfigured,
CameraStopping,
CameraRunning,
};
bool isRunning() const;
int isAccessAllowed(State state, bool allowDisconnected = false,
const char *from = __builtin_FUNCTION()) const;
int isAccessAllowed(State low, State high,
bool allowDisconnected = false,
const char *from = __builtin_FUNCTION()) const;
void disconnect();
void setState(State state);
std::shared_ptr<PipelineHandler> pipe_;
std::string id_;
std::set<Stream *> streams_;
std::set<const Stream *> activeStreams_;
bool disconnected_;
std::atomic<State> state_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_CAMERA_H__ */