summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-02-26 01:37:53 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-03-01 00:28:17 +0100
commit77100a7578d8a0ccc56e6ab11a8dbe3c74665c4d (patch)
treec7fe5b995ee0cd8524839781e04be773a4bee795 /include
parent132ce9c1cf6951d8cba8ff6ff5fbccadead385c1 (diff)
libcamera: camera: add state machine to control access from applications
There is a need to better control the order of operations an application performs on a camera for it to function correctly. Add a basic state machine to ensure applications perform operations on the camera in good order. Internal to the Camera states are added; Available, Acquired, Configured, Prepared and Running. Each state represents a higher state of configuration of the camera ultimately leading to the highest state where the camera is capturing frames. Each state supports a subset of operations the application may perform. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/camera.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h
index 9c8ae01e..e5212cf0 100644
--- a/include/libcamera/camera.h
+++ b/include/libcamera/camera.h
@@ -39,7 +39,7 @@ public:
Signal<Camera *> disconnected;
int acquire();
- void release();
+ int release();
const std::set<Stream *> &streams() const;
std::map<Stream *, StreamConfiguration>
@@ -47,7 +47,7 @@ public:
int configureStreams(std::map<Stream *, StreamConfiguration> &config);
int allocateBuffers();
- void freeBuffers();
+ int freeBuffers();
Request *createRequest();
int queueRequest(Request *request);
@@ -56,20 +56,30 @@ public:
int stop();
private:
+ enum State {
+ CameraAvailable,
+ CameraAcquired,
+ CameraConfigured,
+ CameraPrepared,
+ CameraRunning,
+ };
+
Camera(PipelineHandler *pipe, const std::string &name);
~Camera();
+ bool stateBetween(State low, State high) const;
+ bool stateIs(State state) const;
+
friend class PipelineHandler;
void disconnect();
- int exclusiveAccess();
std::shared_ptr<PipelineHandler> pipe_;
std::string name_;
std::set<Stream *> streams_;
std::set<Stream *> activeStreams_;
- bool acquired_;
bool disconnected_;
+ State state_;
};
} /* namespace libcamera */