From patchwork Thu Jan 5 04:37:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 18092 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 7CA83C322E for ; Thu, 5 Jan 2023 04:38:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EE5D3625F3; Thu, 5 Jan 2023 05:38:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1672893485; bh=8tx+Ta0U0Hr9zT1hQ96lmBQ3IGWjpjxzTmFKfRIMDKg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Ey6nUb+yTXakdoR461aYr4l2gcX6I9ZuAB7LbH+SvC2FJyphnDGr+nSWWUHICQOOy v/LWLM3vSbhPsmh9lM5Q36i8DV2itkyOmzvtIs/aGU6Bbg8Hl4I0KQ2Bb9ITiiIsFz AvlHHDGxsL1ARnkT+KHlfOmv5VsazRfG8VTAS5dEzMbL1mv7SwFcgQKP/Fq1YtUCJ/ CsnSVE4ySBDdZBubVc/E35yae2z95H6iG7EI+vE0jRiwciQKZMPF5437/7XUXD18as I9Rx6BbVwfTG/B2zmSHNquje+i2ZjE7tkjSyxWJ4e+5WUkI8NQwlNWYjeja7/uByU4 AFjzvot5Kpi3A== Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 19F73625E0 for ; Thu, 5 Jan 2023 05:38:02 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="TBcRpZwk"; dkim-atps=neutral Received: by mail-pj1-x102f.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so865525pjj.4 for ; Wed, 04 Jan 2023 20:38:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J6oOo866++nJiEAfXkWSZqYz/D100v7GE53q9RtFW/E=; b=TBcRpZwkWEaAL96hfM/DeXb8hSg0nhZ90DbLyVVId7M7oDiwYvYJE7U6TEBGu9HuN8 /Rbv2ayz/95DxtqsPNDrCcNdVo4Atd8h5HxtX4mgDjVnkU+KTegO5nLKdmvXHAQ9+A0h iMNO5FM5BEILtzAmGH+j83w8bYXUx5/8AIKdM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J6oOo866++nJiEAfXkWSZqYz/D100v7GE53q9RtFW/E=; b=7V/UbFwE1r/ZaZPCmepZLheVz2HjXAwR7OxfpM2i5etv85TiSyYA498vmrWCIAOkAQ bViIadpWI9p/or5/kXPDg41PQKiK0gERIDe+EeuKrkPVM0g1HzRNAPdfBxVv6uLTfTIm et6cNMZVNY12lG2nOZ249iijNVbofoenMDwsm0GM3EQHfmNwy/4P4N8oKBEzS/VY6322 rDWmY9x4GAojUhxHYbaQQIWSEv5gqh7TdPMSKh7RBtoliZjgrL6shPLK54JHQDhqzR1T JydJnNwnfhSkBXGmmiI4jikXU1erb9W0SCzHiBS/exte0/jG8/pC5YPkkXsT/ThCnKmr Y9DA== X-Gm-Message-State: AFqh2krjQha5JCrw4zpXA3RsJLUvmBzcHuSeqbShsQsa7aIfmuQQssEd 6ZpKO3ntCTk+FnKrwRw2rHY4QMUV+6UzQ4S5 X-Google-Smtp-Source: AMrXdXunX/QN9W0rb/VT/5iuhm8gnNJTtb3Dx6EfOzXqh0blEpiumX8Xa015uJYc+bpNqd7vHNPHZQ== X-Received: by 2002:a17:903:1c3:b0:192:903f:7ac9 with SMTP id e3-20020a17090301c300b00192903f7ac9mr47906740plh.42.1672893480306; Wed, 04 Jan 2023 20:38:00 -0800 (PST) Received: from chenghaoyang-low.c.googlers.com.com (46.165.189.35.bc.googleusercontent.com. [35.189.165.46]) by smtp.gmail.com with ESMTPSA id x23-20020a170902b41700b00188c5f0f9e9sm25015200plr.199.2023.01.04.20.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 20:38:00 -0800 (PST) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Thu, 5 Jan 2023 04:37:23 +0000 Message-Id: <20230105043726.679968-7-chenghaoyang@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230105043726.679968-1-chenghaoyang@google.com> References: <20230105043726.679968-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/9] libcamera: pipeline: virtual: Create a Camera X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harvey Yang via libcamera-devel From: Harvey Yang Reply-To: Harvey Yang Cc: Harvey Yang , Harvey Yang Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Create a VirtualCameraData inheriting from the CameraData to handle camera specific data, and use it to create and register the camera with the CameraManager. This can now be tested to see that the camera becomes available to applications: """ build/src/apps/cam/cam -l [550:47:04.505850647] [1969734] INFO IPAManager ipa_manager.cpp:143 libcamera is not installed. Adding ... to the IPA search path [550:47:04.509307667] [1969734] INFO Camera camera_manager.cpp:293 libcamera v0.0.1+54-55fecb4d-dirty (2022-12-01T05:47:11+00:00) Available cameras: 1: (Virtual0) """ Signed-off-by: Harvey Yang --- src/libcamera/pipeline/virtual/virtual.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp index 6221196c..ba77d757 100644 --- a/src/libcamera/pipeline/virtual/virtual.cpp +++ b/src/libcamera/pipeline/virtual/virtual.cpp @@ -9,6 +9,7 @@ #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/media_device_virtual.h" #include "libcamera/internal/pipeline_handler.h" @@ -16,6 +17,19 @@ namespace libcamera { LOG_DEFINE_CATEGORY(VIRTUAL) +class VirtualCameraData : public Camera::Private +{ +public: + VirtualCameraData(PipelineHandler *pipe) + : Camera::Private(pipe) + { + } + + ~VirtualCameraData() = default; + + Stream stream_; +}; + class VirtualCameraConfiguration : public CameraConfiguration { public: @@ -109,6 +123,14 @@ bool PipelineHandlerVirtual::match(DeviceEnumerator *enumerator) { (void)enumerator; mediaDevices_.push_back(mediaDeviceVirtual_); + + std::unique_ptr data = std::make_unique(this); + /* Create and register the camera. */ + std::set streams{ &data->stream_ }; + const std::string id = "Virtual0"; + std::shared_ptr camera = Camera::create(std::move(data), id, streams); + registerCamera(std::move(camera)); + return false; // Prevent infinite loops for now }