From patchwork Tue Jul 26 19:41:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 16811 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 556F5C3275 for ; Tue, 26 Jul 2022 19:41:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1EA0963317; Tue, 26 Jul 2022 21:41:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658864512; bh=zqUukScYu10qMuBjWoarzIHgUagwY2WlG1g02kH8NWs=; 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=dfRrer3PlnxLeZPTmebAFd6x6ltqHFKtwQ+NHjMYgyYr6dPvyHuVAC3a0Tix1w3SK bwcgktRwH+4xyLPXGI5NuTdCXFrAc7f7sux6fezmYClPN4PEWzEIujneXs8VJNN2EI i3/Gug/YedrA0Co8+OzTtmX3wuNiYP/rgp3Eyblzw2hB5Tsi1wrgvYa2u9WXelqH+T DMaJ/8TTY6BKczH29tRvuIS8iQUqAv1weBejaT4+933h7a6sZzu/UzHsT2HzUNPVoI Bb2Jo1W785Wy1qdGq82TKUrT0CIKLhNAsAqhlev5dYXashEk8ICabrFK621h4clC9u uKQWZ9fLJQaRA== Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2BE5C60487 for ; Tue, 26 Jul 2022 21:41:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="U7wQwO+Z"; dkim-atps=neutral Received: by mail-pl1-x62c.google.com with SMTP id z3so14274504plb.1 for ; Tue, 26 Jul 2022 12:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C9Qz3WEv8GHqsyhmoNi2/XFeD1co4638A+i8dJzm75o=; b=U7wQwO+ZsSJhl/O+08tUK2csulTtq8+YKvlHSXDKFf+GR22CNffvLn8tKNTF0qwrzk JGsuZudH1aTAJ1CdSvME6vbYUw9LYyfm9/s20C0skDpui8Ecs75kmH9F1aCI3jwz3JoJ vZJf1dzL/4kjq03My+9N61UTuj07lX2f12ONgifCDkynh9NEzluUrHQQtr+TRDbikDFw z/Q7bdMPFQjcT70Y+saz1cmdjRfyvdEeU5sOhtejsz4FGA0yIeWtmgFzORzU0zJbGn67 DPDr4+axzq5c1uZYTAgL/WHzfJtlGJBuUXsS9Np+C8PZ2Gsdoo5KbRh2MZbCpgdFZ1U1 9X1A== 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=C9Qz3WEv8GHqsyhmoNi2/XFeD1co4638A+i8dJzm75o=; b=wqDqhp6R5/WvzTAwmcjINf0BzOsAW9HDkM2Aki1IndjWZedGR89UpLqIU6j4a9QaZm 3rW+yQa69RDz7JMRHSVLFFrMPhouBE5W2OhYrbjLrrqmiOeVb4uoyKVsVvcYmpbBUC3P 2D48hkOaDZ1H1fiPBmqCbQ4IeoYpXpIURwcgHZ0J10B2z94JzI8EtQxETZMGkXFFHvSP XEeIXkhtGao/lYHOogRUJ2EOFshKOErHUyy0sLsldgJ5uAhK06/jpBiEIpuWVNYhVWFZ J/bsp9lghOF0R4xsT6nDic7ia20gbi5QUkWnwjQ/VKi1k4Kc6YxVaZEAhx6K+IuL6t98 J/WA== X-Gm-Message-State: AJIora/jWjXALSyjf/xX5mHos5ySt+9avR6cuB8Q2eh9JQhwRmL7tqq3 ZAidD+ebQeqN8BQVGKl4UjSMCNPaAUo= X-Google-Smtp-Source: AGRyM1vQrnGzlFbjN+GjjqF/0pStL4/3hH0KVpFYMzOEmW6wv6f5w6xviPj9+2ilq8XvGAwtMnGJqA== X-Received: by 2002:a17:902:8693:b0:16c:db86:1c86 with SMTP id g19-20020a170902869300b0016cdb861c86mr17803564plo.9.1658864509478; Tue, 26 Jul 2022 12:41:49 -0700 (PDT) Received: from localhost.localdomain ([2404:bd00:3:d6bf:24ea:3f52:4c78:7bd8]) by smtp.gmail.com with ESMTPSA id a5-20020aa794a5000000b0052ac1af926fsm12017782pfl.20.2022.07.26.12.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:41:49 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Jul 2022 01:11:23 +0530 Message-Id: <20220726194123.170208-3-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220726194123.170208-1-utkarsh02t@gmail.com> References: <20220726194123.170208-1-utkarsh02t@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 3/3] qcam: Add --script to load capture script 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: Utkarsh Tiwari via libcamera-devel From: Utkarsh Tiwari Reply-To: Utkarsh Tiwari Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add --script as an individual option to load capture scripts. Load the capture script before starting the capture. If an invalid capture script has been given, display a QMessageBox and print it on the console informing that the script is invalid. Do not start the capture. Signed-off-by: Utkarsh Tiwari Reviewed-by: Kieran Bingham --- Changes from v4 - Now when we have an invalid script we quit and don't start the capture. src/qcam/main.cpp | 3 +++ src/qcam/main_window.cpp | 20 ++++++++++++++++++++ src/qcam/main_window.h | 1 + 3 files changed, 24 insertions(+) diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp index d3f01a85..91166be5 100644 --- a/src/qcam/main.cpp +++ b/src/qcam/main.cpp @@ -43,6 +43,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[]) "Set configuration of a camera stream", "stream", true); parser.addOption(OptVerbose, OptionNone, "Print verbose log messages", "verbose"); + parser.addOption(OptCaptureScript, OptionString, + "Load a capture session configuration script from a file", + "script", ArgumentRequired, "script"); OptionsParser::Options options = parser.parse(argc, argv); if (options.isSet(OptHelp)) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 9dc96fbb..7b2bc84b 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -152,6 +152,26 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) return; } + if (options_.isSet(OptCaptureScript)) { + std::string scriptName = options_[OptCaptureScript].toString(); + script_ = std::make_unique(camera_, scriptName); + if (!script_->valid()) { + QMessageBox::critical(this, "Invalid Script", + "Couldn't load the capture script"); + qInfo() << "Invalid Capture Script"; + + script_.reset(); + + /* Do not start capture if invalid script. */ + quit(); + return; + } + + /* Show stopping availability. */ + scriptExecAction_->setIcon(QIcon(":x-square.svg")); + scriptExecAction_->setText("Stop Script execution"); + } + startStopAction_->setChecked(true); } diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index eb398c1d..59e50b5e 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -43,6 +43,7 @@ enum { OptRenderer = 'r', OptStream = 's', OptVerbose = 'v', + OptCaptureScript = 256, }; class MainWindow : public QMainWindow