summaryrefslogtreecommitdiff
BranchCommit messageAuthorAge
masterlibcamera: software_isp: Improve wording in a commentMilan Zamazal25 hours
 
TagDownloadAuthorAge
v0.3.2commit 8bcec68734...Kieran Bingham10 days
v0.3.1commit 9c40320763...Kieran Bingham2 months
v0.3.0commit aee16c0691...Kieran Bingham5 months
v0.2.0commit 89227a428a...Kieran Bingham9 months
v0.1.0commit 668a5e674a...Kieran Bingham15 months
v0.0.5commit fb44403f1c...Kieran Bingham17 months
v0.0.4commit 6cf637eb25...Kieran Bingham20 months
v0.0.3commit f66a5c447b...Kieran Bingham22 months
v0.0.2commit 2b1e1cd1ab...Kieran Bingham23 months
v0.0.1commit a83aed77df...Kieran Bingham24 months
v0.0.0commit 87ba17ba41...Laurent Pinchart3 years
ef='#n119'>119 120 121 122 123 124 125 126 127 128
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2020, Umang Jain <email@uajain.com>
 *
 * hotplug-cameras.cpp - Test cameraAdded/cameraRemoved signals in CameraManager
 */

#include <dirent.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <unistd.h>

#include <libcamera/camera.h>
#include <libcamera/camera_manager.h>

#include <libcamera/base/event_dispatcher.h>
#include <libcamera/base/file.h>
#include <libcamera/base/thread.h>
#include <libcamera/base/timer.h>

#include "test.h"

using namespace libcamera;

class HotplugTest : public Test
{
protected:
	void cameraAddedHandler([[maybe_unused]] std::shared_ptr<Camera> cam)
	{
		cameraAdded_ = true;
	}

	void cameraRemovedHandler([[maybe_unused]] std::shared_ptr<Camera> cam)
	{
		cameraRemoved_ = true;
	}

	int init()
	{
		if (!File::exists("/sys/module/uvcvideo")) {
			std::cout << "uvcvideo driver is not loaded, skipping" << std::endl;
			return TestSkip;
		}

		if (geteuid() != 0) {
			std::cout << "This test requires root permissions, skipping" << std::endl;
			return TestSkip;
		}

		cm_ = new CameraManager();
		if (cm_->start()) {
			std::cout << "Failed to start camera manager" << std::endl;
			return TestFail;
		}

		cameraAdded_ = false;
		cameraRemoved_ = false;

		cm_->cameraAdded.connect(this, &HotplugTest::cameraAddedHandler);
		cm_->cameraRemoved.connect(this, &HotplugTest::cameraRemovedHandler);

		return 0;
	}