mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-25 17:45:06 +03:00
libcamera: stream: Add and use toString() method to StreamConfiguration
Add a toString() method to the StreamConfiguration class, and replace all manually coded implementations through the source code. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
8cf52e378d
commit
0af0fb9ca9
5 changed files with 27 additions and 15 deletions
|
@ -7,6 +7,8 @@
|
|||
#ifndef __LIBCAMERA_STREAM_H__
|
||||
#define __LIBCAMERA_STREAM_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <libcamera/buffer.h>
|
||||
#include <libcamera/geometry.h>
|
||||
|
||||
|
@ -20,6 +22,8 @@ struct StreamConfiguration {
|
|||
unsigned int pixelFormat;
|
||||
|
||||
unsigned int bufferCount;
|
||||
|
||||
std::string toString() const;
|
||||
};
|
||||
|
||||
class StreamUsage
|
||||
|
|
|
@ -596,9 +596,7 @@ int Camera::configureStreams(const CameraConfiguration &config)
|
|||
return -EINVAL;
|
||||
|
||||
const StreamConfiguration &cfg = config[stream];
|
||||
msg << " (" << index << ") " << cfg.width << "x"
|
||||
<< cfg.height << "-0x" << std::hex << std::setfill('0')
|
||||
<< std::setw(8) << cfg.pixelFormat;
|
||||
msg << " (" << index << ") " << cfg.toString();
|
||||
|
||||
index++;
|
||||
}
|
||||
|
|
|
@ -224,10 +224,7 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera,
|
|||
config->pixelFormat = V4L2_PIX_FMT_NV12;
|
||||
config->bufferCount = IPU3_BUFFER_COUNT;
|
||||
|
||||
LOG(IPU3, Debug)
|
||||
<< "Stream format set to " << config->width << "x"
|
||||
<< config->height << "-0x" << std::hex << std::setfill('0')
|
||||
<< std::setw(8) << config->pixelFormat;
|
||||
LOG(IPU3, Debug) << "Stream format set to " << config->toString();
|
||||
|
||||
return configs;
|
||||
}
|
||||
|
|
|
@ -124,10 +124,7 @@ CameraConfiguration PipelineHandlerRkISP1::streamConfiguration(Camera *camera,
|
|||
|
||||
configs[&data->stream_] = config;
|
||||
|
||||
LOG(RkISP1, Debug)
|
||||
<< "Stream format set to " << config.width << "x"
|
||||
<< config.height << "-0x" << std::hex << std::setfill('0')
|
||||
<< std::setw(8) << config.pixelFormat;
|
||||
LOG(RkISP1, Debug) << "Stream format set to " << config.toString();
|
||||
|
||||
return configs;
|
||||
}
|
||||
|
@ -234,10 +231,7 @@ int PipelineHandlerRkISP1::configureStreams(Camera *camera,
|
|||
outputFormat.height != cfg.height ||
|
||||
outputFormat.fourcc != cfg.pixelFormat) {
|
||||
LOG(RkISP1, Error)
|
||||
<< "Unable to configure capture in " << cfg.width
|
||||
<< "x" << cfg.height << "-0x"
|
||||
<< std::hex << std::setfill('0') << std::setw(8)
|
||||
<< cfg.pixelFormat;
|
||||
<< "Unable to configure capture in " << cfg.toString();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
* stream.cpp - Video stream for a Camera
|
||||
*/
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include <libcamera/stream.h>
|
||||
|
||||
/**
|
||||
|
@ -60,6 +63,22 @@ namespace libcamera {
|
|||
* \brief Requested number of buffers to allocate for the stream
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Assemble and return a string describing the configuration
|
||||
*
|
||||
* \return A string describing the StreamConfiguration
|
||||
*/
|
||||
std::string StreamConfiguration::toString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss.fill(0);
|
||||
ss << width << "x" << height << "-0x" << std::hex
|
||||
<< std::setw(8) << pixelFormat;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* \class StreamUsage
|
||||
* \brief Stream usage information
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue