From patchwork Thu Mar 9 14:25:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 18361 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 1D861BDE17 for ; Thu, 9 Mar 2023 14:26:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BB868626D9; Thu, 9 Mar 2023 15:26:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678371977; bh=r/9svRpZCV5oNpOpCHa+gjKbiDmbgttK0xpLggiSp8c=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=knvM0MKcYU8jSFD8WLt77bqwi4VGdvpbzwCkPHRt9vefPBgfD0/aCtK5hc/sG89TG m/y/i20YywjxyLAgvAnYTNQFldckbNvtQe2e4DMYf5rEJ9pAAxz7QPlC10/5d04CeH ykqhV59jQarAH5EotSuU8IXZOA8IFP8Jan7GG8SEBrJM8NM8HcQ9kwwb0or6v/FvOI 42hmrFf11C7LzvaHfwndKtDoB0q1/BlXL7mZQ61rqCTYUcd8MmOf1Jo687EHih+UyF R8GwqdzixST5KRdGzHHJqB848Nc/9mj0MgcpS9QtleG/Y5Jxd/kc0HaacBFcXNh+T4 beHb15dZwIzDA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 572EB61ED7 for ; Thu, 9 Mar 2023 15:26:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fqB0DI60"; dkim-atps=neutral Received: from desky.lan (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C3CAD589; Thu, 9 Mar 2023 15:26:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1678371976; bh=r/9svRpZCV5oNpOpCHa+gjKbiDmbgttK0xpLggiSp8c=; h=From:To:Cc:Subject:Date:From; b=fqB0DI60qecGXt9XhJGIYqREpANf1wfRNh+h20A355ZGCn4FYzfYk8/KCktpApbxL /sI1MtQxnf4MEL/cdw4ygWX243FfrRug7AxNaNKiTi2CZ+64aujIsSzoJqX6JFsCGc esoxlu0wZiaeVfnKqOWYcGHHtctFnM/iX30P8DQw= To: libcamera-devel@lists.libcamera.org Date: Thu, 9 Mar 2023 16:25:46 +0200 Message-Id: <20230309142601.70556-1-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 00/15] py: New python bindings event handling 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: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi, I sent the v3 of the series ("[PATCH v3 00/17] Python bindings event handling") more than half a year ago. I've addressed the review comments which I think make sense and are more or less obvious. In fact, I made those changes quite soon after receiving them, again over half a year ago. I also added some additional patches on top (the unittest improvements). But then I never had time to work on the biggest question, how to handle the events, and so I never sent the v4. And then recently I added even more patches on top. So I tought I'll just do a bit of work on the series to introduce another way to manage the events, just as a hackish RFC, and send the series. Perhaps there are more people interested in the py bindings now, and we will get more discussion and ideas. I don't want us to totally forget this series =). So, here it is. The "py: New event handling" patch adds the events as in v3. But in the topmost patch, "py: Hack for different event enable mechanism" I draft another way we might handle the enabling and disabling of the events. One thing I didn't change was Laurent's comment that camera.stop() should not return the disconnect events, only the request and buffer completed events. I'm still not sure about that, but I think if we go with the method I introduce in the topmost patch, it probably makes sense to leave the disconnect events alone in camera.stop(). And, for those not familiar with the series: This changes the Python API in a breaking manner. Changes to scripts using the Python bindings are needed (see the "Use new events support" patches): - Many methods throw exceptions now, instead of returning an error value - The handling of events has changed. Previously it was all about request completed, and no other events. Now we support all the events. Tomi Tomi Valkeinen (15): py: Use exceptions instead of returning error codes py: New event handling py: cam.py: Use new events support py: unittests.py: Use new events support py: simple-capture.py: Use new events support py: simple-continuous-capture.py: Use new events support py: simple-cam.py: Use new events support py: Drop get_ready_requests() py: Add hotplug-monitor.py py: unittests.py: Add weakref helpers and use del py: unittests.py: Add test for refs & keep-alives py: unittests.py: Fix type checker warnings py: Move Color Space and Transform classes to separate files py: Improve stub type generation for PyCameraEvent py: Hack for different event enable mechanism src/py/cam/cam.py | 44 +-- src/py/examples/hotplug-monitor.py | 39 +++ src/py/examples/simple-cam.py | 34 +-- src/py/examples/simple-capture.py | 36 ++- src/py/examples/simple-continuous-capture.py | 38 +-- src/py/libcamera/meson.build | 2 + src/py/libcamera/py_camera_manager.cpp | 180 +++++++++-- src/py/libcamera/py_camera_manager.h | 68 ++++- src/py/libcamera/py_color_space.cpp | 71 +++++ src/py/libcamera/py_main.cpp | 303 +++++++++++-------- src/py/libcamera/py_transform.cpp | 81 +++++ test/py/unittests.py | 280 ++++++++++++----- 12 files changed, 853 insertions(+), 323 deletions(-) create mode 100644 src/py/examples/hotplug-monitor.py create mode 100644 src/py/libcamera/py_color_space.cpp create mode 100644 src/py/libcamera/py_transform.cpp