libcamera: Switch to CameraConfiguration
Implement the camera configuration thru out the library, tests, cam and qcam tools. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
@@ -45,21 +45,3 @@ void CameraTest::cleanup()
|
||||
|
||||
cm_->stop();
|
||||
};
|
||||
|
||||
bool CameraTest::configurationValid(const std::map<Stream *, StreamConfiguration> &config) const
|
||||
{
|
||||
/* Test that the configuration is not empty. */
|
||||
if (config.empty())
|
||||
return false;
|
||||
|
||||
/* Test that configuration is valid. */
|
||||
for (auto const &it : config) {
|
||||
const StreamConfiguration &conf = it.second;
|
||||
|
||||
if (conf.width == 0 || conf.height == 0 ||
|
||||
conf.pixelFormat == 0 || conf.bufferCount == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ protected:
|
||||
int init();
|
||||
void cleanup();
|
||||
|
||||
bool configurationValid(const std::map<Stream *, StreamConfiguration> &config) const;
|
||||
|
||||
std::shared_ptr<Camera> camera_;
|
||||
|
||||
private:
|
||||
|
||||
@@ -42,12 +42,12 @@ protected:
|
||||
|
||||
int run()
|
||||
{
|
||||
std::map<Stream *, StreamConfiguration> conf =
|
||||
CameraConfiguration conf =
|
||||
camera_->streamConfiguration({ Stream::VideoRecording() });
|
||||
Stream *stream = conf.begin()->first;
|
||||
StreamConfiguration *sconf = &conf.begin()->second;
|
||||
Stream *stream = conf.front();
|
||||
StreamConfiguration *sconf = &conf[stream];
|
||||
|
||||
if (!configurationValid(conf)) {
|
||||
if (!conf.isValid()) {
|
||||
cout << "Failed to read default configuration" << endl;
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
@@ -18,17 +18,11 @@ class ConfigurationDefault : public CameraTest
|
||||
protected:
|
||||
int run()
|
||||
{
|
||||
std::map<Stream *, StreamConfiguration> conf;
|
||||
CameraConfiguration conf;
|
||||
|
||||
/* Test asking for configuration for a video stream. */
|
||||
conf = camera_->streamConfiguration({ Stream::VideoRecording() });
|
||||
if (conf.empty()) {
|
||||
cout << "Failed to retrieve configuration for video streams"
|
||||
<< endl;
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
if (!configurationValid(conf)) {
|
||||
if (!conf.isValid()) {
|
||||
cout << "Default configuration invalid" << endl;
|
||||
return TestFail;
|
||||
}
|
||||
@@ -38,7 +32,7 @@ protected:
|
||||
* stream usages returns an empty list of configurations.
|
||||
*/
|
||||
conf = camera_->streamConfiguration({});
|
||||
if (!conf.empty()) {
|
||||
if (conf.isValid()) {
|
||||
cout << "Failed to retrieve configuration for empty usage list"
|
||||
<< endl;
|
||||
return TestFail;
|
||||
|
||||
@@ -18,11 +18,11 @@ class ConfigurationSet : public CameraTest
|
||||
protected:
|
||||
int run()
|
||||
{
|
||||
std::map<Stream *, StreamConfiguration> conf =
|
||||
CameraConfiguration conf =
|
||||
camera_->streamConfiguration({ Stream::VideoRecording() });
|
||||
StreamConfiguration *sconf = &conf.begin()->second;
|
||||
StreamConfiguration *sconf = &conf[conf.front()];
|
||||
|
||||
if (!configurationValid(conf)) {
|
||||
if (!conf.isValid()) {
|
||||
cout << "Failed to read default configuration" << endl;
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ protected:
|
||||
return TestPass;
|
||||
}
|
||||
|
||||
std::map<Stream *, StreamConfiguration> defconf_;
|
||||
CameraConfiguration defconf_;
|
||||
};
|
||||
|
||||
} /* namespace */
|
||||
|
||||
Reference in New Issue
Block a user