diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-04-28 15:41:20 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-05-23 00:27:10 +0300 |
commit | 2ca2d658700c57c3d734d72b2148436907152257 (patch) | |
tree | fd1daddee8186b2a3324089a68607e3e020d40fc | |
parent | d8de003a0482c998c178151bd1e5684fef60b8be (diff) |
libcamera: camera: Rename configureStreams() and streamConfiguration()
Rename the configureStreams() and streamConfiguration() methods to
configure() and generateConfiguration() respectively in order to clarify
the API. Both methods deal with CameraConfiguration objects, and are
thus not limited to streams, even if a CameraConfiguration currently
contains streams only.
While at it, remove the qcam MainWindow::configureStreams() method that
is declared but never defined or used.
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>
-rw-r--r-- | include/libcamera/camera.h | 4 | ||||
-rw-r--r-- | src/cam/main.cpp | 6 | ||||
-rw-r--r-- | src/libcamera/camera.cpp | 28 | ||||
-rw-r--r-- | src/libcamera/include/pipeline_handler.h | 4 | ||||
-rw-r--r-- | src/libcamera/pipeline/ipu3/ipu3.cpp | 21 | ||||
-rw-r--r-- | src/libcamera/pipeline/rkisp1/rkisp1.cpp | 10 | ||||
-rw-r--r-- | src/libcamera/pipeline/uvcvideo.cpp | 16 | ||||
-rw-r--r-- | src/libcamera/pipeline/vimc.cpp | 16 | ||||
-rw-r--r-- | src/libcamera/pipeline_handler.cpp | 28 | ||||
-rw-r--r-- | src/libcamera/stream.cpp | 5 | ||||
-rw-r--r-- | src/qcam/main_window.cpp | 4 | ||||
-rw-r--r-- | src/qcam/main_window.h | 1 | ||||
-rw-r--r-- | test/camera/capture.cpp | 4 | ||||
-rw-r--r-- | test/camera/configuration_default.cpp | 4 | ||||
-rw-r--r-- | test/camera/configuration_set.cpp | 10 | ||||
-rw-r--r-- | test/camera/statemachine.cpp | 16 |
16 files changed, 87 insertions, 90 deletions
diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 777b7e4d..306739b7 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -75,8 +75,8 @@ public: const std::set<Stream *> &streams() const; CameraConfiguration - streamConfiguration(const std::vector<StreamUsage> &usage); - int configureStreams(const CameraConfiguration &config); + generateConfiguration(const std::vector<StreamUsage> &usage); + int configure(const CameraConfiguration &config); int allocateBuffers(); int freeBuffers(); diff --git a/src/cam/main.cpp b/src/cam/main.cpp index f03c32b3..6a2508dd 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -93,7 +93,7 @@ static int prepareCameraConfig(CameraConfiguration *config) /* If no configuration is provided assume a single video stream. */ if (!options.isSet(OptStream)) { - *config = camera->streamConfiguration({ Stream::VideoRecording() }); + *config = camera->generateConfiguration({ Stream::VideoRecording() }); streamInfo[config->front()] = "stream0"; return 0; } @@ -121,7 +121,7 @@ static int prepareCameraConfig(CameraConfiguration *config) } } - *config = camera->streamConfiguration(roles); + *config = camera->generateConfiguration(roles); if (!config->isValid()) { std::cerr << "Failed to get default stream configuration" @@ -211,7 +211,7 @@ static int capture() return ret; } - ret = camera->configureStreams(config); + ret = camera->configure(config); if (ret < 0) { std::cout << "Failed to configure camera" << std::endl; return ret; diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 1a21acac..359174a4 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -275,10 +275,10 @@ const StreamConfiguration &CameraConfiguration::operator[](Stream *stream) const * Available -> Acquired [label = "acquire()"]; * * Acquired -> Available [label = "release()"]; - * Acquired -> Configured [label = "configureStreams()"]; + * Acquired -> Configured [label = "configure()"]; * * Configured -> Available [label = "release()"]; - * Configured -> Configured [label = "configureStreams()"]; + * Configured -> Configured [label = "configure()"]; * Configured -> Prepared [label = "allocateBuffers()"]; * * Prepared -> Configured [label = "freeBuffers()"]; @@ -542,23 +542,23 @@ const std::set<Stream *> &Camera::streams() const } /** - * \brief Retrieve a group of stream configurations according to stream usages + * \brief Generate a default camera configuration according to stream usages * \param[in] usages A list of stream usages * - * Retrieve configuration for a set of desired usages. The caller specifies a - * list of stream usages and the camera returns a map of suitable streams and - * their suggested default configurations. + * Generate a camera configuration for a set of desired usages. The caller + * specifies a list of stream usages and the camera returns a configuration + * containing suitable streams and their suggested default configurations. * * \return A valid CameraConfiguration if the requested usages can be satisfied, * or a invalid one otherwise */ CameraConfiguration -Camera::streamConfiguration(const std::vector<StreamUsage> &usages) +Camera::generateConfiguration(const std::vector<StreamUsage> &usages) { if (disconnected_ || !usages.size() || usages.size() > streams_.size()) return CameraConfiguration(); - CameraConfiguration config = pipe_->streamConfiguration(this, usages); + CameraConfiguration config = pipe_->generateConfiguration(this, usages); std::ostringstream msg("streams configuration:", std::ios_base::ate); unsigned int index = 0; @@ -575,7 +575,7 @@ Camera::streamConfiguration(const std::vector<StreamUsage> &usages) } /** - * \brief Configure the camera's streams prior to capture + * \brief Configure the camera prior to capture * \param[in] config The camera configurations to setup * * Prior to starting capture, the camera must be configured to select a @@ -584,9 +584,9 @@ Camera::streamConfiguration(const std::vector<StreamUsage> &usages) * by populating \a config. * * The easiest way to populate the array of config is to fetch an initial - * configuration from the camera with streamConfiguration() and then change the - * parameters to fit the caller's need and once all the streams parameters are - * configured hand that over to configureStreams() to actually setup the camera. + * configuration from the camera with generateConfiguration() and then change + * the parameters to fit the caller's need and once all the streams parameters + * are configured hand that over to configure() to actually setup the camera. * * Exclusive access to the camera shall be ensured by a call to acquire() prior * to calling this function, otherwise an -EACCES error will be returned. @@ -598,7 +598,7 @@ Camera::streamConfiguration(const std::vector<StreamUsage> &usages) * \retval -EACCES The camera is not in a state where it can be configured * \retval -EINVAL The configuration is not valid */ -int Camera::configureStreams(const CameraConfiguration &config) +int Camera::configure(const CameraConfiguration &config) { int ret; @@ -629,7 +629,7 @@ int Camera::configureStreams(const CameraConfiguration &config) LOG(Camera, Info) << msg.str(); - ret = pipe_->configureStreams(this, config); + ret = pipe_->configure(this, config); if (ret) return ret; diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 9f5fe3d6..9cc11a8e 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -61,8 +61,8 @@ public: void unlock(); virtual CameraConfiguration - streamConfiguration(Camera *camera, const std::vector<StreamUsage> &usages) = 0; - virtual int configureStreams(Camera *camera, const CameraConfiguration &config) = 0; + generateConfiguration(Camera *camera, const std::vector<StreamUsage> &usages) = 0; + virtual int configure(Camera *camera, const CameraConfiguration &config) = 0; virtual int allocateBuffers(Camera *camera, const std::set<Stream *> &streams) = 0; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 75a70e66..ba0c708f 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -151,10 +151,10 @@ public: PipelineHandlerIPU3(CameraManager *manager); CameraConfiguration - streamConfiguration(Camera *camera, - const std::vector<StreamUsage> &usages) override; - int configureStreams(Camera *camera, - const CameraConfiguration &config) override; + generateConfiguration(Camera *camera, + const std::vector<StreamUsage> &usages) override; + int configure(Camera *camera, + const CameraConfiguration &config) override; int allocateBuffers(Camera *camera, const std::set<Stream *> &streams) override; @@ -210,8 +210,8 @@ PipelineHandlerIPU3::PipelineHandlerIPU3(CameraManager *manager) } CameraConfiguration -PipelineHandlerIPU3::streamConfiguration(Camera *camera, - const std::vector<StreamUsage> &usages) +PipelineHandlerIPU3::generateConfiguration(Camera *camera, + const std::vector<StreamUsage> &usages) { IPU3CameraData *data = cameraData(camera); CameraConfiguration config = {}; @@ -309,8 +309,8 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera, return config; } -int PipelineHandlerIPU3::configureStreams(Camera *camera, - const CameraConfiguration &config) +int PipelineHandlerIPU3::configure(Camera *camera, + const CameraConfiguration &config) { IPU3CameraData *data = cameraData(camera); IPU3Stream *outStream = &data->outStream_; @@ -631,11 +631,10 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator) * 1) Link enable/disable cannot be done at start/stop time as video * devices needs to be linked first before format can be configured on * them. - * 2) As link enable has to be done at the least in configureStreams, + * 2) As link enable has to be done at the least in configure(), * before configuring formats, the only place where to disable links * would be 'stop()', but the Camera class state machine allows - * start()<->stop() sequences without any streamConfiguration() in - * between. + * start()<->stop() sequences without any configure() in between. * * As of now, disable all links in the media graph at 'match()' time, * to allow testing different cameras in different test applications diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 96553bf2..4d02f960 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -34,9 +34,9 @@ public: PipelineHandlerRkISP1(CameraManager *manager); ~PipelineHandlerRkISP1(); - CameraConfiguration streamConfiguration(Camera *camera, + CameraConfiguration generateConfiguration(Camera *camera, const std::vector<StreamUsage> &usages) override; - int configureStreams(Camera *camera, + int configure(Camera *camera, const CameraConfiguration &config) override; int allocateBuffers(Camera *camera, @@ -106,7 +106,7 @@ PipelineHandlerRkISP1::~PipelineHandlerRkISP1() * Pipeline Operations */ -CameraConfiguration PipelineHandlerRkISP1::streamConfiguration(Camera *camera, +CameraConfiguration PipelineHandlerRkISP1::generateConfiguration(Camera *camera, const std::vector<StreamUsage> &usages) { RkISP1CameraData *data = cameraData(camera); @@ -122,8 +122,8 @@ CameraConfiguration PipelineHandlerRkISP1::streamConfiguration(Camera *camera, return config; } -int PipelineHandlerRkISP1::configureStreams(Camera *camera, - const CameraConfiguration &config) +int PipelineHandlerRkISP1::configure(Camera *camera, + const CameraConfiguration &config) { RkISP1CameraData *data = cameraData(camera); const StreamConfiguration &cfg = config[&data->stream_]; diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 351712cf..118b9745 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -26,10 +26,10 @@ public: PipelineHandlerUVC(CameraManager *manager); CameraConfiguration - streamConfiguration(Camera *camera, - const std::vector<StreamUsage> &usages) override; - int configureStreams(Camera *camera, - const CameraConfiguration &config) override; + generateConfiguration(Camera *camera, + const std::vector<StreamUsage> &usages) override; + int configure(Camera *camera, + const CameraConfiguration &config) override; int allocateBuffers(Camera *camera, const std::set<Stream *> &streams) override; @@ -76,8 +76,8 @@ PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager) } CameraConfiguration -PipelineHandlerUVC::streamConfiguration(Camera *camera, - const std::vector<StreamUsage> &usages) +PipelineHandlerUVC::generateConfiguration(Camera *camera, + const std::vector<StreamUsage> &usages) { UVCCameraData *data = cameraData(camera); CameraConfiguration config; @@ -92,8 +92,8 @@ PipelineHandlerUVC::streamConfiguration(Camera *camera, return config; } -int PipelineHandlerUVC::configureStreams(Camera *camera, - const CameraConfiguration &config) +int PipelineHandlerUVC::configure(Camera *camera, + const CameraConfiguration &config) { UVCCameraData *data = cameraData(camera); const StreamConfiguration *cfg = &config[&data->stream_]; diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 737d6df6..74959581 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -26,10 +26,10 @@ public: PipelineHandlerVimc(CameraManager *manager); CameraConfiguration - streamConfiguration(Camera *camera, - const std::vector<StreamUsage> &usages) override; - int configureStreams(Camera *camera, - const CameraConfiguration &config) override; + generateConfiguration(Camera *camera, + const std::vector<StreamUsage> &usages) override; + int configure(Camera *camera, + const CameraConfiguration &config) override; int allocateBuffers(Camera *camera, const std::set<Stream *> &streams) override; @@ -76,8 +76,8 @@ PipelineHandlerVimc::PipelineHandlerVimc(CameraManager *manager) } CameraConfiguration -PipelineHandlerVimc::streamConfiguration(Camera *camera, - const std::vector<StreamUsage> &usages) +PipelineHandlerVimc::generateConfiguration(Camera *camera, + const std::vector<StreamUsage> &usages) { VimcCameraData *data = cameraData(camera); CameraConfiguration config; @@ -92,8 +92,8 @@ PipelineHandlerVimc::streamConfiguration(Camera *camera, return config; } -int PipelineHandlerVimc::configureStreams(Camera *camera, - const CameraConfiguration &config) +int PipelineHandlerVimc::configure(Camera *camera, + const CameraConfiguration &config) { VimcCameraData *data = cameraData(camera); const StreamConfiguration *cfg = &config[&data->stream_]; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 1eeaf4bb..b9ac6432 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -218,26 +218,26 @@ void PipelineHandler::unlock() } /** - * \fn PipelineHandler::streamConfiguration() - * \brief Retrieve a group of stream configurations for a specified camera - * \param[in] camera The camera to fetch default configuration from + * \fn PipelineHandler::generateConfiguration() + * \brief Generate a camera configuration for a specified camera + * \param[in] camera The camera to generate a default configuration for * \param[in] usages A list of stream usages * - * Retrieve the species camera's default configuration for a specified group of - * use-cases. The caller shall populate the \a usages array with the use-cases it - * wishes to fetch the default configuration for. The map of streams and - * configurations returned can then be examined by the caller to learn about - * the default parameters for the specified streams. + * Generate a default configuration for the \a camera for a specified group of + * use-cases. The caller shall populate the \a usages array with the use-cases + * it wishes to fetch the default configuration for. The returned configuration + * can then be examined by the caller to learn about the selected streams and + * their default parameters. * - * The intended companion to this is \a configureStreams() which can be used to - * change the group of streams parameters. + * The intended companion to this is \a configure() which can be used to change + * the group of streams parameters. * * \return A valid CameraConfiguration if the requested usages can be satisfied, * or a invalid configuration otherwise */ /** - * \fn PipelineHandler::configureStreams() + * \fn PipelineHandler::configure() * \brief Configure a group of streams for capture * \param[in] camera The camera to configure * \param[in] config The camera configurations to setup @@ -293,9 +293,9 @@ void PipelineHandler::unlock() * \param[in] camera The camera to start * * Start the group of streams that have been configured for capture by - * \a configureStreams(). The intended caller of this method is the Camera - * class which will in turn be called from the application to indicate that it - * has configured the streams and is ready to capture. + * \a configure(). The intended caller of this method is the Camera class which + * will in turn be called from the application to indicate that it has + * configured the streams and is ready to capture. * * \return 0 on success or a negative error code otherwise */ diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 4ff296e3..af259510 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -218,9 +218,8 @@ Stream::Stream() * \brief The stream configuration * * The configuration for the stream is set by any successful call to - * Camera::configureStreams() that includes the stream, and remains valid until - * the next call to Camera::configureStreams() regardless of if it includes the - * stream. + * Camera::configure() that includes the stream, and remains valid until the + * next call to Camera::configure() regardless of if it includes the stream. */ } /* namespace libcamera */ diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index ee06d751..c91b8272 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -97,9 +97,9 @@ int MainWindow::startCapture() { int ret; - config_ = camera_->streamConfiguration({ Stream::VideoRecording() }); + config_ = camera_->generateConfiguration({ Stream::VideoRecording() }); Stream *stream = config_.front(); - ret = camera_->configureStreams(config_); + ret = camera_->configure(config_); if (ret < 0) { std::cout << "Failed to configure camera" << std::endl; return ret; diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 9b31da2b..143b5b08 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -35,7 +35,6 @@ private: int openCamera(); int startCapture(); - int configureStreams(Camera *camera, std::set<Stream *> &streams); void stopCapture(); void requestComplete(Request *request, diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp index 0101cc94..bc3a4d6c 100644 --- a/test/camera/capture.cpp +++ b/test/camera/capture.cpp @@ -43,7 +43,7 @@ protected: int run() { CameraConfiguration config = - camera_->streamConfiguration({ Stream::VideoRecording() }); + camera_->generateConfiguration({ Stream::VideoRecording() }); Stream *stream = config.front(); StreamConfiguration *cfg = &config[stream]; @@ -57,7 +57,7 @@ protected: return TestFail; } - if (camera_->configureStreams(config)) { + if (camera_->configure(config)) { cout << "Failed to set default configuration" << endl; return TestFail; } diff --git a/test/camera/configuration_default.cpp b/test/camera/configuration_default.cpp index 2a10ea50..340b5f58 100644 --- a/test/camera/configuration_default.cpp +++ b/test/camera/configuration_default.cpp @@ -21,7 +21,7 @@ protected: CameraConfiguration config; /* Test asking for configuration for a video stream. */ - config = camera_->streamConfiguration({ Stream::VideoRecording() }); + config = camera_->generateConfiguration({ Stream::VideoRecording() }); if (!config.isValid()) { cout << "Default configuration invalid" << endl; return TestFail; @@ -31,7 +31,7 @@ protected: * Test that asking for configuration for an empty array of * stream usages returns an empty list of configurations. */ - config = camera_->streamConfiguration({}); + config = camera_->generateConfiguration({}); if (config.isValid()) { cout << "Failed to retrieve configuration for empty usage list" << endl; diff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp index ca41ed68..24d5ca66 100644 --- a/test/camera/configuration_set.cpp +++ b/test/camera/configuration_set.cpp @@ -19,7 +19,7 @@ protected: int run() { CameraConfiguration config = - camera_->streamConfiguration({ Stream::VideoRecording() }); + camera_->generateConfiguration({ Stream::VideoRecording() }); StreamConfiguration *cfg = &config[config.front()]; if (!config.isValid()) { @@ -33,7 +33,7 @@ protected: } /* Test that setting the default configuration works. */ - if (camera_->configureStreams(config)) { + if (camera_->configure(config)) { cout << "Failed to set default configuration" << endl; return TestFail; } @@ -48,7 +48,7 @@ protected: return TestFail; } - if (!camera_->configureStreams(config)) { + if (!camera_->configure(config)) { cout << "Setting configuration on a camera not acquired succeeded when it should have failed" << endl; return TestFail; @@ -66,7 +66,7 @@ protected: */ cfg->size.width *= 2; cfg->size.height *= 2; - if (camera_->configureStreams(config)) { + if (camera_->configure(config)) { cout << "Failed to set modified configuration" << endl; return TestFail; } @@ -75,7 +75,7 @@ protected: * Test that setting an invalid configuration fails. */ cfg->size = { 0, 0 }; - if (!camera_->configureStreams(config)) { + if (!camera_->configure(config)) { cout << "Invalid configuration incorrectly accepted" << endl; return TestFail; } diff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp index 8ae93bee..bd2e61ff 100644 --- a/test/camera/statemachine.cpp +++ b/test/camera/statemachine.cpp @@ -19,7 +19,7 @@ protected: int testAvailable() { /* Test operations which should fail. */ - if (camera_->configureStreams(defconf_) != -EACCES) + if (camera_->configure(defconf_) != -EACCES) return TestFail; if (camera_->allocateBuffers() != -EACCES) @@ -84,7 +84,7 @@ protected: if (camera_->acquire()) return TestFail; - if (camera_->configureStreams(defconf_)) + if (camera_->configure(defconf_)) return TestFail; return TestPass; @@ -113,7 +113,7 @@ protected: return TestFail; /* Test operations which should pass. */ - if (camera_->configureStreams(defconf_)) + if (camera_->configure(defconf_)) return TestFail; /* Test valid state transitions, end in Prepared state. */ @@ -123,7 +123,7 @@ protected: if (camera_->acquire()) return TestFail; - if (camera_->configureStreams(defconf_)) + if (camera_->configure(defconf_)) return TestFail; if (camera_->allocateBuffers()) @@ -141,7 +141,7 @@ protected: if (camera_->release() != -EBUSY) return TestFail; - if (camera_->configureStreams(defconf_) != -EACCES) + if (camera_->configure(defconf_) != -EACCES) return TestFail; if (camera_->allocateBuffers() != -EACCES) @@ -172,7 +172,7 @@ protected: if (camera_->acquire()) return TestFail; - if (camera_->configureStreams(defconf_)) + if (camera_->configure(defconf_)) return TestFail; if (camera_->allocateBuffers()) @@ -193,7 +193,7 @@ protected: if (camera_->release() != -EBUSY) return TestFail; - if (camera_->configureStreams(defconf_) != -EACCES) + if (camera_->configure(defconf_) != -EACCES) return TestFail; if (camera_->allocateBuffers() != -EACCES) @@ -235,7 +235,7 @@ protected: int run() { - defconf_ = camera_->streamConfiguration({ Stream::VideoRecording() }); + defconf_ = camera_->generateConfiguration({ Stream::VideoRecording() }); if (testAvailable() != TestPass) { cout << "State machine in Available state failed" << endl; |