summaryrefslogtreecommitdiff
path: root/test/libtest/camera_test.cpp
blob: fe13d6acf1650ca61572fb1f9bfc80a728930332 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * libcamera Camera API tests
 */

#include <iostream>

#include "camera_test.h"
#include "test.h"

using namespace libcamera;
using namespace std;

CameraTest::CameraTest(const char *name, bool isolate)
{
	cm_ = new CameraManager();

	if (isolate)
		setenv("LIBCAMERA_IPA_FORCE_ISOLATION", "1", 1);

	if (cm_->start()) {
		cerr << "Failed to start camera manager" << endl;
		status_ = TestFail;
		return;
	}

	camera_ = cm_->get(name);
	if (!camera_) {
		cerr << "Can not find '" << name << "' camera" << endl;
		status_ = TestSkip;
		return;
	}

	/* Sanity check that the camera has streams. */
	if (camera_->streams().empty()) {
		cerr << "Camera has no stream" << endl;
		status_ = TestFail;
		return;
	}

	status_ = TestPass;
}

CameraTest::~CameraTest()
{
	if (camera_) {
		camera_->release();
		camera_.reset();
	}

	cm_->stop();
	delete cm_;
}
implement concurrent viewfinder and video capture, or concurrent viewfinder, * video capture and still image capture. */ namespace libcamera { /** * \struct StreamConfiguration * \brief Configuration parameters for a stream * * The StreamConfiguration structure models all information which can be * configured for a single video stream. */ /** * \var StreamConfiguration::size * \brief Stream size in pixels */ /** * \var StreamConfiguration::pixelFormat * \brief Stream pixel format * * This is a little endian four character code representation of the pixel * format described in V4L2 using the V4L2_PIX_FMT_* definitions. */ /** * \var StreamConfiguration::bufferCount * \brief Requested number of buffers to allocate for the stream */ /** * \fn StreamConfiguration::stream() * \brief Retrieve the stream associated with the configuration * * When a camera is configured with Camera::configure() Stream instances are * associated with each stream configuration entry. This method retrieves the * associated Stream, which remains valid until the next call to * Camera::configure() or Camera::release(). * * \return The stream associated with the configuration */ /** * \fn StreamConfiguration::setStream() * \brief Associate a stream with a configuration * * This method is meant for the PipelineHandler::configure() method and shall * not be called by applications. * * \param[in] stream 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 << size.toString() << "-0x" << std::hex << std::setw(8) << pixelFormat; return ss.str(); } /** * \enum StreamRole * \brief Identify the role a stream is intended to play * * The StreamRole describes how an application intends to use a stream. Roles * are specified by applications and passed to cameras, that then select the * most appropriate streams and their default configurations. * * \var StillCapture * The stream is intended to capture high-resolution, high-quality still images * with low frame rate. The captured frames may be exposed with flash. * \var VideoRecording * The stream is intended to capture video for the purpose of recording or * streaming. The video stream may produce a high frame rate and may be * enhanced with video stabilization. * \var Viewfinder * The stream is intended to capture video for the purpose of display on the * local screen. Trade-offs between quality and usage of system resources are * acceptable. */ /** * \typedef StreamRoles * \brief A vector of StreamRole */ /** * \class Stream * \brief Video stream for a camera * * The Stream class models all static information which are associated with a * single video stream. Streams are exposed by the Camera object they belong to. * * Cameras may supply more than one stream from the same video source. In such * cases an application can inspect all available streams and select the ones * that best fit its use case. * * \todo Add capabilities to the stream API. Without this the Stream class only * serves to reveal how many streams of unknown capabilities a camera supports. * This in itself is productive as it allows applications to configure and * capture from one or more streams even if they won't be able to select the * optimal stream for the task. */ /** * \brief Construct a stream with default parameters */