[libcamera-devel] [PATCH 1/8] cam: Pass stream roles to Capture class

Kieran Bingham kieran.bingham at ideasonboard.com
Tue May 19 11:24:38 CEST 2020


Hi Laurent,

On 19/05/2020 04:24, Laurent Pinchart wrote:
> The stream roles will be needed in the Capture class to verify the
> configuration. Store they in the CamApp class and pass them to the

s/they/them/

Other than that,

Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

> Capture class constructor.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>  src/cam/capture.cpp | 5 +++--
>  src/cam/capture.h   | 4 +++-
>  src/cam/main.cpp    | 9 +++++----
>  3 files changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp
> index 55fa2dabcee9..b7e06bcc9463 100644
> --- a/src/cam/capture.cpp
> +++ b/src/cam/capture.cpp
> @@ -16,8 +16,9 @@
>  
>  using namespace libcamera;
>  
> -Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config)
> -	: camera_(camera), config_(config), writer_(nullptr)
> +Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config,
> +		 const StreamRoles &roles)
> +	: camera_(camera), config_(config), roles_(roles), writer_(nullptr)
>  {
>  }
>  
> diff --git a/src/cam/capture.h b/src/cam/capture.h
> index 9bca5661070e..c0e697b831fb 100644
> --- a/src/cam/capture.h
> +++ b/src/cam/capture.h
> @@ -24,7 +24,8 @@ class Capture
>  {
>  public:
>  	Capture(std::shared_ptr<libcamera::Camera> camera,
> -		libcamera::CameraConfiguration *config);
> +		libcamera::CameraConfiguration *config,
> +		const libcamera::StreamRoles &roles);
>  
>  	int run(EventLoop *loop, const OptionsParser::Options &options);
>  private:
> @@ -35,6 +36,7 @@ private:
>  
>  	std::shared_ptr<libcamera::Camera> camera_;
>  	libcamera::CameraConfiguration *config_;
> +	libcamera::StreamRoles roles_;
>  
>  	std::map<libcamera::Stream *, std::string> streamName_;
>  	BufferWriter *writer_;
> diff --git a/src/cam/main.cpp b/src/cam/main.cpp
> index 2512fe9da782..cdd29d500202 100644
> --- a/src/cam/main.cpp
> +++ b/src/cam/main.cpp
> @@ -47,6 +47,7 @@ private:
>  	OptionsParser::Options options_;
>  	CameraManager *cm_;
>  	std::shared_ptr<Camera> camera_;
> +	StreamRoles roles_;
>  	std::unique_ptr<libcamera::CameraConfiguration> config_;
>  	EventLoop *loop_;
>  };
> @@ -194,10 +195,10 @@ int CamApp::parseOptions(int argc, char *argv[])
>  
>  int CamApp::prepareConfig()
>  {
> -	StreamRoles roles = StreamKeyValueParser::roles(options_[OptStream]);
> +	roles_ = StreamKeyValueParser::roles(options_[OptStream]);
>  
> -	config_ = camera_->generateConfiguration(roles);
> -	if (!config_ || config_->size() != roles.size()) {
> +	config_ = camera_->generateConfiguration(roles_);
> +	if (!config_ || config_->size() != roles_.size()) {
>  		std::cerr << "Failed to get default stream configuration"
>  			  << std::endl;
>  		return -EINVAL;
> @@ -326,7 +327,7 @@ int CamApp::run()
>  	}
>  
>  	if (options_.isSet(OptCapture)) {
> -		Capture capture(camera_, config_.get());
> +		Capture capture(camera_, config_.get(), roles_);
>  		return capture.run(loop_, options_);
>  	}
>  
> 

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list