From patchwork Fri Jun 17 14:35:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16266 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 2AB91C3273 for ; Fri, 17 Jun 2022 14:36:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B516E65633; Fri, 17 Jun 2022 16:36:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655476561; bh=bfC5m4po1aXHCHv8kSDq/G+Xmwx2dfvIIEqCdfLnAS8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=p0WT7IGMl6fgeSufBpCbbsua/QaKjISdQuginTi1R36oA6kg7X5lMjHWdO+FhDqLL cUlC7H5EpJi2I26GM2vrEa8IP/m2zbEG3y/0Db88KjfucxcVSd4uuSTSho6sYAXiND vdXVxzztyYFz6zJhG0oQAnRVN3bkpOcBgWH5A1zFiS4AxGA6YMp3ORUup9sOu3E/Eo I9oJeYO+g6M8In6P6+XvLVoR3PY7tDkCFJmsA3b0jHUM2/BDoVTWSJw1vND/Nl40/o Je8MGoL8tmwq7V9XtbuAepcq2O4KSN5YuDTmRhpZUHC+uAtWrbLB93iaBanbaU8Hnw RBz3RKDxAEjvg== Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BFC8465634 for ; Fri, 17 Jun 2022 16:35:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="lGWKN/pY"; dkim-atps=neutral Received: by mail-ej1-x630.google.com with SMTP id kq6so9131727ejb.11 for ; Fri, 17 Jun 2022 07:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oCovsv3VFF1beHyZ5aPXj8YqDmLQsuqKHjhWl1wvOrc=; b=lGWKN/pYNeq1c8YZ7SikO9RcsCpNZYHEueWjYce/OGhs6TNNmzI1kbslebAg/wtkWJ kt+Kldlwo79PxzQ8RYyjmsblL7KtC9cpzjG1EiCGu28bzNmx4sKJtA4vV+0+/Xco0XGq g2PUAbmMmyzwOvUXsBOBVv7y7ZTN7VrZRECbW2qCBXi9N8p9cbNk+9xfKsCSt2rCn8wS nKKEtLk16khZqfKXTCdT4DQ23pXIjlMHsJofsaspQmhCJ40WY1h/pyAlm0gnxOt9l/qc zHaTUBXCnFF6ttHLkoN0GJi8qF5wSxZyoBNbT+VEltcOZ3EKhzveUBkzwTL4Td6khAtH KECg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oCovsv3VFF1beHyZ5aPXj8YqDmLQsuqKHjhWl1wvOrc=; b=gpk4Cmrx5MLjW/I4AbFdZ02Sp39mftDxjQplf3ueZTQoaEbipnfkeKk9X9Gaf5wDPj VXfYZttU5jQNARfEUlIBKozz/KA0ORmRW7hJ68Tr3Xx0yfZX58AENBt0F/sImcncGuc7 DbE3pY/hHNiWduCi0/F8BnCSp+NYZKnQZGuhBxkhCqcAZJpnxGA0HnywKmBe3MfkmxKB GbQQykVcHXf2+ndzksuXH4UvLzZSGG96F9+5WoWCvgPyZ60kpVAxK9jASt18Z58QVXj/ xgF84nFNTXqhS6/dTbnD51MD2/29x7wzV/9qxCqXZ/x/eB0Ohtr0GY2HkEVJxke+hkF2 M07w== X-Gm-Message-State: AJIora8w7cQczDYwxCEUCeIgaMCEMD+HmcCS/yL4SONvZKTx9sZ8N69N ROWVPm2ErjGE4cM2AlP0MhfhVB1BaIAWFA== X-Google-Smtp-Source: AGRyM1sXuL+Yy/O43aosiDKPvuE6EBwMcboL27q5Yx/aLDN1ORH/KWy90tDzlT63frWWo4a918PhHA== X-Received: by 2002:a17:907:7fa5:b0:711:c8e2:2f4c with SMTP id qk37-20020a1709077fa500b00711c8e22f4cmr9599427ejc.49.1655476559291; Fri, 17 Jun 2022 07:35:59 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id u20-20020aa7d554000000b0042a2d9af0f8sm3746189edr.79.2022.06.17.07.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 07:35:58 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 17 Jun 2022 16:35:47 +0200 Message-Id: <20220617143549.35442-2-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220617143549.35442-1-dse@thaumatec.com> References: <20220617143549.35442-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] Documentation: Add the missing const to the example code 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: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Request::BufferMap key type is now const Signed-off-by: Daniel Semkowicz Reviewed-by: Laurent Pinchart --- Documentation/guides/application-developer.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index 8d12a208..6ab8b7e5 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -410,7 +410,7 @@ images. .. code:: cpp - const std::map &buffers = request->buffers(); + const std::map &buffers = request->buffers(); Iterating through the map allows applications to inspect each completed buffer in this request, and access the metadata associated to each frame. @@ -518,7 +518,7 @@ and queue all the previously created requests. camera->start(); for (std::unique_ptr &request : requests) - camera->queueRequest(request.get()); + camera->queueRequest(request.get()); Start an event loop ~~~~~~~~~~~~~~~~~~~ From patchwork Fri Jun 17 14:35:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16267 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 B7E1CC3274 for ; Fri, 17 Jun 2022 14:36:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3610B65640; Fri, 17 Jun 2022 16:36:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655476563; bh=KjH4tmNS63vJcpsSiWI8j5ifpvfdCF5cYnDJT1LX3ak=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=TLXW5mWKgT5n4cP0OLTcJAAbI0aZFf3NWi/+Y941pRzcR+BYijr4G2gJSG5ly7klC 7rqsgGEdSnXzI8QHPnbA0TIf3+KQLJ9RhqKqFZD1+xXNZdanBBgIxNlA4HgNcLYg77 ZPRx2c/tkM5wpMc/FHsamg7xzNDSk2uAFJS1q5TxlpF5hc5UnHi2Seg7+Ao7+1M91V DwAZR2DLvcat5EyCwPk+kYARXqCaFrhNpvAS5iZgO6tHw/8/vhv65pjfvPob08VUAe VphtqAT6N53bz276jr/oaauMqBlGWkXJH3+6I7eYTNV3zSqgbtOFhRVTHCQ0Jvh9Su VNGbVLm6NjOMw== Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EBC8E6563B for ; Fri, 17 Jun 2022 16:36:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="pmLe5vO0"; dkim-atps=neutral Received: by mail-ej1-x62b.google.com with SMTP id me5so9188986ejb.2 for ; Fri, 17 Jun 2022 07:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w0e7YC6nMwbowNG2N+5NhLg9552WzqKVUgC+4FV5e9E=; b=pmLe5vO03nAIs3I+ZJEihxykNgUldwtNef5tfjnmWqth5dYwXpGQx/sUaMx7JFYyjB 4RUg9EpTK5NAeEWNiIl48k7I8265U4PmYpFElQzk/56kfhvRC2ooW3BLhujce5mjeEhx pDKNGPKedAGdaRrfmv4F6AHi9RYI4RPZ+d+zdjHgDzvL86ErU0zsswlj0pEMkrhaTgnr JgYEtgZzuP8nVRlHAqoGtCucLJjr27DKrA3+VNCqXtWNLbLJmLS6tCJO5yPyzYq9d9eL tq+xPeR5fNHiGOkWPgb8iwzIQlHqxS/MVDA1y9SYbNk4qa/TLJ/Lt9kd3S3sLPBwCYM6 TGDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w0e7YC6nMwbowNG2N+5NhLg9552WzqKVUgC+4FV5e9E=; b=kDrfgTd6Ff8di63ROp/Wu4OpFx0JkPTbnAvoDdDbbNJbK1qxZJ8fEmntPR1RVFUT7h lu8qFHnG0uS8JeKDbfoOEXWNyIFtpXNfzj7SlKS1Y9TEuK+LYcsn3mZJjqzTD+7xgp71 V/4W9hfBqZdzJRy9yB+VpkAgka6YTWNdrsZzbULfJM9NuPu635bRnfgCDJ2En2UjF9Co MLPIPa5GeMbMYF8v9ok6w3EaSsQyi4gLzCrFkEJlEbMASwnsPcA1EiA5/KJn+zNw5cPr kUJs+LPwHaSnuI0lzSv7EVRubkRhLjz+V5oZCGQJaTaHiYCaI2n/Xas+mvX6GPi/ngZY WpUA== X-Gm-Message-State: AJIora96ztEIPGccCpV1zXTrYsBMO/P7LEyTT0VNnWPR7QjFbeVLqY/R +BwboacKj6h9nZRtkVtkUPX1TLIMASDJCg== X-Google-Smtp-Source: AGRyM1uJoEVwTRJGmUpg9Y6/pNsvQjH9yUExlajnSF4Zub0hWipZnys4vjx8F71aSQeadWDAXOPONw== X-Received: by 2002:a17:906:ece3:b0:6f3:da10:138a with SMTP id qt3-20020a170906ece300b006f3da10138amr9736427ejb.438.1655476561457; Fri, 17 Jun 2022 07:36:01 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id u20-20020aa7d554000000b0042a2d9af0f8sm3746189edr.79.2022.06.17.07.36.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 07:36:00 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 17 Jun 2022 16:35:48 +0200 Message-Id: <20220617143549.35442-3-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220617143549.35442-1-dse@thaumatec.com> References: <20220617143549.35442-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/3] Documentation: Update code examples to use the Request::reuse() method 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: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" After introduction of reuse(), there is no need of manual request reconfiguration. Furthermore, current example code does not work anymore. Signed-off-by: Daniel Semkowicz Reviewed-by: Laurent Pinchart --- .../guides/application-developer.rst | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index 6ab8b7e5..a5f363cf 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -480,26 +480,12 @@ libcamera repository. .. _FileSink class: https://git.libcamera.org/libcamera/libcamera.git/tree/src/cam/file_sink.cpp With the handling of this request completed, it is possible to re-use the -buffers by adding them to a new ``Request`` instance with their matching -streams, and finally, queue the new capture request to the camera device: +request and the associated buffers and re-queue it to the camera +device: .. code:: cpp - request = camera->createRequest(); - if (!request) - { - std::cerr << "Can't create request" << std::endl; - return; - } - - for (auto it = buffers.begin(); it != buffers.end(); ++it) - { - Stream *stream = it->first; - FrameBuffer *buffer = it->second; - - request->addBuffer(stream, buffer); - } - + request->reuse(Request::ReuseBuffers); camera->queueRequest(request); Request queueing From patchwork Fri Jun 17 14:35:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16268 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 EAB26C3275 for ; Fri, 17 Jun 2022 14:36:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5660B65632; Fri, 17 Jun 2022 16:36:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655476565; bh=hhnoCMzCfRivBh9MgDRXZ3EySgVnoGHUFnZUEy9Y1V8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Z0OFWPcfgRynrxTaXrruv4RE/wYav66+HAdPDb05/kGWSRVEYVYfgcBVYvIGLs1db sMS8c+VfOi/QvY/JmJuftgtkRNIrrgSdkrAHrHlUUCKk2rrjLZNis2LP1fpGj2S29t EfGoYSnYnO52klFH+gzttP/2yX6Q9N1JriE2Jx8e7wsdDKllbnJrvG/7WF1XrwObOv XPqhfJNbj0lypROx+aXUX0TJoJg5d1XhUyyr88FtYsYtLn/SZs9ldTSeIBJzT0f8Yk jO3hbg3SQB2Tv0nMp/CYtWyN9y7qLI2huI+q+uqLhEz0chFBjB7BE7VCzmQ2Vty2Kl YoVjaM0BjuM2g== Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B97D65634 for ; Fri, 17 Jun 2022 16:36:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="iDQg2qMY"; dkim-atps=neutral Received: by mail-ej1-x62e.google.com with SMTP id hj18so8551716ejb.0 for ; Fri, 17 Jun 2022 07:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ES6xm68K6Natf3Fld5kgrC9puFGuwBiA/I1sDxCCj00=; b=iDQg2qMYN5cjkqQZp1jJBDuUY7cc144998os75uMoaJ3S1+fwHErUYN8aJ+vCkoK7r Sr3qIfLBZYUhr19eewMwp4EZ/uNvbby1A4vrYrGm32v2YB5AuetZdU+zrHtvJQRWNMLE B9063sjyPDRTnooTvCWeFvKDgxIOCO/F4zSF+MD72mXSftt8zu5mlS6BUpF9PYVJ/V8+ EL0jwWkLvfSdiSAqbtMGGjqIKqwnChWh4AwNx06Mskq8v8jN+SBN56J1NTwX0RjlHAfc WlXdCcusNuJDsUYP3QOCdJ8hURMT2aClfg26eAj5uedbwv1z54yE3JAA3jIbulJA08PM pDFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ES6xm68K6Natf3Fld5kgrC9puFGuwBiA/I1sDxCCj00=; b=UVsj2d0lwiLw87kaapuzS2sx8pbV9GW3zfMCTs9AxH3HEaurYMSNyKem+HszDZjv5Y zabof/bxIeb9xPrcJXamPxRUJsPOrbNTRYMXDbrZCkALfgCL3vnfX74olnc/Br4Zc4Vy Vrdvi79Bc1Ct+LBnR9HgMnZcKVqAEkRcWJ+fE//M0Zs7ahMu2wXSrXG/1llkHTlKkHId kP0ujVcXIwnvGtqSx0gKLfTmm9HyyEF1Rkz1asHz5mlBQKygz/xE3MV2un6Ca1paos/+ iwxYkjigr7UMZ+2mZUeJw+DuviM0r3CZzO2Dy7soi2chTFvl1zXvm46dY/KB1zH2o9Nw Ix9g== X-Gm-Message-State: AJIora//LQefYx3ZjkQG/ujgQ9DXwP0Q5IJDchyvFfP9qr0dd8iiAvC4 faMNxTw1Nfi79Qqi73G8V1iK4bd5HvSbIg== X-Google-Smtp-Source: AGRyM1slK5lxJd4t+gZSLGP5/CCKoxWxDu5XKoQsmtdn16a4VLAH7uVyVtEjhn5LS41209UlwBR8uw== X-Received: by 2002:a17:906:4f:b0:712:af2:29d9 with SMTP id 15-20020a170906004f00b007120af229d9mr9676537ejg.751.1655476563865; Fri, 17 Jun 2022 07:36:03 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id u20-20020aa7d554000000b0042a2d9af0f8sm3746189edr.79.2022.06.17.07.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 07:36:03 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 17 Jun 2022 16:35:49 +0200 Message-Id: <20220617143549.35442-4-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220617143549.35442-1-dse@thaumatec.com> References: <20220617143549.35442-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] Documentation: Update the "Start an event loop" section 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: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Event loop was moved to be a part of CameraManager, so it is no longer a user responsibility to control the event dispatching. Signed-off-by: Daniel Semkowicz Reviewed-by: Laurent Pinchart --- .../guides/application-developer.rst | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index a5f363cf..f4551f58 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -27,10 +27,12 @@ defined names and types without the need of prefixing them. #include #include #include + #include #include using namespace libcamera; + using namespace std::chrono_literals; int main() { @@ -506,35 +508,27 @@ and queue all the previously created requests. for (std::unique_ptr &request : requests) camera->queueRequest(request.get()); -Start an event loop +Event processing ~~~~~~~~~~~~~~~~~~~ -The libcamera library needs an event loop to monitor and dispatch events -generated by the video devices part of the capture pipeline. libcamera provides -its own ``EventDispatcher`` class (inspired by the `Qt event system`_) to -process and deliver events generated by ``EventNotifiers``. +libcamera creates an internal execution thread at `CameraManager::start()`_ +time to decouple its own event processing from the application's main thread. +Applications are thus free to manage their own execution opportunely, and only +need to respond to events generated by libcamera emitted through signals. -.. _Qt event system: https://doc.qt.io/qt-5/eventsandfilters.html +.. _CameraManager::start(): https://libcamera.org/api-html/classlibcamera_1_1CameraManager.html#a49e322880a2a26013bb0076788b298c5 -The libcamera library implements this by creating instances of the -``EventNotifier`` class, which models a file descriptor event source registered -to an ``EventDispatcher``. Whenever the ``EventDispatcher`` detects an event on -a notifier it is monitoring, it emits the notifier's -``EventNotifier::activated`` signal. The libcamera components connect to the -notifiers' signals and emit application visible events, such as the -``Camera::bufferReady`` and ``Camera::requestCompleted`` signals. - -The code below retrieves a reference to the system-wide event dispatcher and for -the a fixed duration of 3 seconds, processes all the events detected in the -system. +Real-world applications will likely either integrate with the event loop of the +framework they use, or create their own event loop to respond to user events. +For the simple application presented in this example, it is enough to prevent +immediate termination by pausing for 3 seconds. During that time, the libcamera +thread will generate request completion events that the application will handle +in the ``requestComplete()`` slot connected to the ``Camera::requestCompleted`` +signal. .. code:: cpp - EventDispatcher *dispatcher = cm->eventDispatcher(); - Timer timer; - timer.start(3000); - while (timer.isRunning()) - dispatcher->processEvents(); + std::this_thread::sleep_for(3000ms); Clean up and stop the application ---------------------------------