Cameras are listed through a double indirection, first iterating over all available pipeline handlers, and then listing the cameras they each support. To simplify the API make the pipeline handlers register the cameras with the camera manager directly, which lets the camera manager easily expose the list of all available cameras. The PipelineHandler API gets simplified as the handlers don't need to expose the list of cameras they have created. 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>
50 lines
677 B
C++
50 lines
677 B
C++
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (C) 2018, Google Inc.
|
|
*
|
|
* list.cpp - camera list tests
|
|
*/
|
|
|
|
#include <iostream>
|
|
|
|
#include <libcamera/camera.h>
|
|
#include <libcamera/camera_manager.h>
|
|
|
|
#include "test.h"
|
|
|
|
using namespace std;
|
|
using namespace libcamera;
|
|
|
|
class ListTest : public Test
|
|
{
|
|
protected:
|
|
int init()
|
|
{
|
|
cm = CameraManager::instance();
|
|
cm->start();
|
|
|
|
return 0;
|
|
}
|
|
|
|
int run()
|
|
{
|
|
unsigned int count = 0;
|
|
|
|
for (Camera *camera : cm->cameras()) {
|
|
cout << "- " << camera->name() << endl;
|
|
count++;
|
|
}
|
|
|
|
return count ? 0 : -ENODEV;
|
|
}
|
|
|
|
void cleanup()
|
|
{
|
|
cm->stop();
|
|
}
|
|
|
|
private:
|
|
CameraManager *cm;
|
|
};
|
|
|
|
TEST_REGISTER(ListTest)
|