Files
external_libcamera/include/libcamera/camera.h
Niklas Söderlund 20a6455e0b libcamera: camera: Add support for stream usages
Instead of requesting the default configuration for a set of streams
where the application has to figure out which streams provided by the
camera is best suited for its intended usage, have the library figure
this out by using stream usages.

The application asks the library for a list of streams and a suggested
default configuration for them by supplying a list of stream usages.
Once the list is retrieved the application can fine-tune the returned
configuration and then try to apply it to the camera.

Currently no pipeline handler is prepared to handle stream usages but
nor did it make use of the list of Stream IDs which was the previous
interface. The main reason for this is that all cameras currently only
provide one stream each. This will still be the case but the API will be
prepared to expand both pipeline handlers and applications to support
streams usages.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-05 22:07:47 +02:00

92 lines
1.9 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2018, Google Inc.
*
* camera.h - Camera object interface
*/
#ifndef __LIBCAMERA_CAMERA_H__
#define __LIBCAMERA_CAMERA_H__
#include <map>
#include <memory>
#include <set>
#include <string>
#include <libcamera/request.h>
#include <libcamera/signal.h>
namespace libcamera {
class Buffer;
class PipelineHandler;
class Request;
class Stream;
class StreamConfiguration;
class StreamUsage;
class Camera final
{
public:
static std::shared_ptr<Camera> create(PipelineHandler *pipe,
const std::string &name,
const std::set<Stream *> &streams);
Camera(const Camera &) = delete;
Camera &operator=(const Camera &) = delete;
const std::string &name() const;
Signal<Request *, Buffer *> bufferCompleted;
Signal<Request *, const std::map<Stream *, Buffer *> &> requestCompleted;
Signal<Camera *> disconnected;
int acquire();
int release();
const std::set<Stream *> &streams() const;
std::map<Stream *, StreamConfiguration>
streamConfiguration(const std::vector<StreamUsage> &usage);
int configureStreams(std::map<Stream *, StreamConfiguration> &config);
int allocateBuffers();
int freeBuffers();
Request *createRequest();
int queueRequest(Request *request);
int start();
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();
void requestComplete(Request *request);
std::shared_ptr<PipelineHandler> pipe_;
std::string name_;
std::set<Stream *> streams_;
std::set<Stream *> activeStreams_;
bool disconnected_;
State state_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_CAMERA_H__ */