[{"id":24629,"web_url":"https://patchwork.libcamera.org/comment/24629/","msgid":"<d406f369-5405-ea21-f0a2-fe0806b0a20a@ideasonboard.com>","date":"2022-08-18T12:06:08","subject":"Re: [libcamera-devel] [PATCH v3 00/17] Python bindings event\n\thandling","submitter":{"id":109,"url":"https://patchwork.libcamera.org/api/people/109/","name":"Tomi Valkeinen","email":"tomi.valkeinen@ideasonboard.com"},"content":"On 01/07/2022 11:45, Tomi Valkeinen wrote:\n> Hi,\n> \n> v3 introduces an alternative new event system compared to the v2. I like\n> this one much better. It's much simpler and more understandable.\n> \n> The series has been re-arranged a bit so that up to, and including, the\n> \"py: Switch to non-blocking eventfd\" patch, there are no API changes.\n> Except a small thing, the change to non-blocking. Afaik this should not\n> cause breakage in picamera2. These can be merged after reviews.\n\nPing. It would be very nice to get the above mentioned patches merged, \nas they do cleanups and fix issues.\n\n  Tomi\n\n> Then we break the API with the use of exceptions instead of return\n> codes. And continue by adding the new API for the events, but keeping\n> the deprecated get_ready_requests.\n> \n> One particular thing I want to mention about the new event system is\n> that most of the events are always subscribed, so the user will e.g. get\n> CameraAdded event without specifically subscribing to it. The only\n> exception is the BufferCompleted event, and I had no other reason for\n> this than I just thought it's rarely used (?), we get it every frame,\n> and thus making it opt-in reduces the extra overhead. But I really have\n> no idea if it's really rarely used, and if the overhead is even\n> noticeable.\n> \n> I first tried with a full opt-in approach, but I'm not sure what would\n> be a good API for that. I tried with a setEvents(event_mask) but that's\n> not very nice to use. We could perhaps have a container struct with a\n> bool for each event type, so that you'd do something like:\n> \n> cm.enabled_events.buffer_completed = True\n> cm.enabled_events.camera_added = True\n> \n> Or we could add a parameter to camera.start() to define which events the\n> user is interested in (but this wouldn't cover Camera Added/Removed).\n> \n>   Tomi\n> \n> Tomi Valkeinen (17):\n>    py: cam.py: Fix multi camera capture without -C\n>    py: Add Python logging category\n>    py: Move ControlValue helpers to py_helpers.cpp\n>    py: cam.py: Remove todo comment\n>    py: Create PyCameraManager\n>    py: Use UniqueFD\n>    py: Set EFD_CLOEXEC on eventfd to avoid fd leaking\n>    py: Use libcamera's Mutex classes\n>    py: Switch to non-blocking eventfd\n>    py: Use exceptions instead of returning error codes\n>    py: New event handling\n>    py: cam.py: Use new events support\n>    py: unittests.py: Use new events support\n>    py: simple-capture.py: Use new events support\n>    py: simple-continuous-capture.py: Use new events support\n>    py: simple-cam.py: Use new events support\n>    py: Add hotplug-monitor.py\n> \n>   src/py/cam/cam.py                            |  55 ++--\n>   src/py/examples/hotplug-monitor.py           |  39 +++\n>   src/py/examples/simple-cam.py                |  31 +-\n>   src/py/examples/simple-capture.py            |  41 +--\n>   src/py/examples/simple-continuous-capture.py |  37 +--\n>   src/py/libcamera/meson.build                 |   2 +\n>   src/py/libcamera/py_camera_manager.cpp       | 286 ++++++++++++++++++\n>   src/py/libcamera/py_camera_manager.h         |  95 ++++++\n>   src/py/libcamera/py_helpers.cpp              |  97 ++++++\n>   src/py/libcamera/py_helpers.h                |  13 +\n>   src/py/libcamera/py_main.cpp                 | 297 +++++++------------\n>   src/py/libcamera/py_main.h                   |  14 +\n>   test/py/unittests.py                         |  93 +++---\n>   13 files changed, 781 insertions(+), 319 deletions(-)\n>   create mode 100644 src/py/examples/hotplug-monitor.py\n>   create mode 100644 src/py/libcamera/py_camera_manager.cpp\n>   create mode 100644 src/py/libcamera/py_camera_manager.h\n>   create mode 100644 src/py/libcamera/py_helpers.cpp\n>   create mode 100644 src/py/libcamera/py_helpers.h\n>   create mode 100644 src/py/libcamera/py_main.h\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C38E9BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Aug 2022 12:06:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0EE4361FC0;\n\tThu, 18 Aug 2022 14:06:14 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 35D5061FA7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Aug 2022 14:06:12 +0200 (CEST)","from [192.168.1.111] (91-158-154-79.elisa-laajakaista.fi\n\t[91.158.154.79])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6F0668B;\n\tThu, 18 Aug 2022 14:06:11 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660824374;\n\tbh=5nt0tbP5I11vLo0Ge7Cgt8UHOg/Nf36Z5qCYx8G9Vro=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=oiStOU2LJ6BtR4salCeZ0mrrJzwOv1ovvlKFWZPKaXcqG+VcTjaBnaIFx6N0xJqMf\n\tP4oCiO8FWdGcYA6ra3d0zg0L011aipFPrc/F5uQpLDmLYsYe9HQUyBRhBj4ElB4SmF\n\tBTBnUekDEMLNbwEP+VbHZCdj4njOJG/jBG0IyPbJprSemMfDlovggpKknTDZ4wx1tu\n\t+arbM0E61PfOUS/yGTnAGqZmIs0b80/Y3afUD6Jr3ej1qy3DeVortZO+gTLzGkSL5M\n\tldpQcGjFTO8tCtsrFfxIoXQBb9dW96bS9GKu9Tk3y2/xm3AQrNj6Z5zuc7DWpZUacH\n\txhsotuSytJatQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660824371;\n\tbh=5nt0tbP5I11vLo0Ge7Cgt8UHOg/Nf36Z5qCYx8G9Vro=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=O0UreOXWF7jI2QP+NKrKEPiAA1Tk4n02vN8nXA7nx7loK1pIPm42CYmGiwRVxj3WY\n\tpwK7lX5QfWX3+ShDd6UTB0JSyjqciV/Be7it4TaEFU9f/MASeweOEJTEdJib9iXPyt\n\tv9H6JFZDhonVDvUP+j2DWzAHes1ZDLxF/zlIgRdM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"O0UreOXW\"; dkim-atps=neutral","Message-ID":"<d406f369-5405-ea21-f0a2-fe0806b0a20a@ideasonboard.com>","Date":"Thu, 18 Aug 2022 15:06:08 +0300","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.11.0","Content-Language":"en-US","To":"libcamera-devel@lists.libcamera.org,\n\tDavid Plowman <david.plowman@raspberrypi.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tJacopo Mondi <jacopo@jmondi.org>","References":"<20220701084521.31831-1-tomi.valkeinen@ideasonboard.com>","In-Reply-To":"<20220701084521.31831-1-tomi.valkeinen@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 00/17] Python bindings event\n\thandling","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24693,"web_url":"https://patchwork.libcamera.org/comment/24693/","msgid":"<Yv6qek2qO03HtWnJ@pendragon.ideasonboard.com>","date":"2022-08-18T21:09:14","subject":"Re: [libcamera-devel] [PATCH v3 00/17] Python bindings event\n\thandling","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Tomi,\n\nOn Fri, Jul 01, 2022 at 11:45:04AM +0300, Tomi Valkeinen wrote:\n> Hi,\n> \n> v3 introduces an alternative new event system compared to the v2. I like\n> this one much better. It's much simpler and more understandable.\n> \n> The series has been re-arranged a bit so that up to, and including, the\n> \"py: Switch to non-blocking eventfd\" patch, there are no API changes.\n> Except a small thing, the change to non-blocking. Afaik this should not\n> cause breakage in picamera2. These can be merged after reviews.\n> \n> Then we break the API with the use of exceptions instead of return\n> codes. And continue by adding the new API for the events, but keeping\n> the deprecated get_ready_requests.\n> \n> One particular thing I want to mention about the new event system is\n> that most of the events are always subscribed, so the user will e.g. get\n> CameraAdded event without specifically subscribing to it. The only\n> exception is the BufferCompleted event, and I had no other reason for\n> this than I just thought it's rarely used (?), we get it every frame,\n> and thus making it opt-in reduces the extra overhead. But I really have\n> no idea if it's really rarely used, and if the overhead is even\n> noticeable.\n> \n> I first tried with a full opt-in approach, but I'm not sure what would\n> be a good API for that. I tried with a setEvents(event_mask) but that's\n> not very nice to use. We could perhaps have a container struct with a\n> bool for each event type, so that you'd do something like:\n> \n> cm.enabled_events.buffer_completed = True\n> cm.enabled_events.camera_added = True\n> \n> Or we could add a parameter to camera.start() to define which events the\n> user is interested in (but this wouldn't cover Camera Added/Removed).\n\nHow about enableEvents() and disableEvents() methods that take a bitmask\nof events to enable or disable ?\n\n> Tomi Valkeinen (17):\n>   py: cam.py: Fix multi camera capture without -C\n>   py: Add Python logging category\n>   py: Move ControlValue helpers to py_helpers.cpp\n>   py: cam.py: Remove todo comment\n>   py: Create PyCameraManager\n>   py: Use UniqueFD\n>   py: Set EFD_CLOEXEC on eventfd to avoid fd leaking\n>   py: Use libcamera's Mutex classes\n>   py: Switch to non-blocking eventfd\n>   py: Use exceptions instead of returning error codes\n>   py: New event handling\n>   py: cam.py: Use new events support\n>   py: unittests.py: Use new events support\n>   py: simple-capture.py: Use new events support\n>   py: simple-continuous-capture.py: Use new events support\n>   py: simple-cam.py: Use new events support\n>   py: Add hotplug-monitor.py\n> \n>  src/py/cam/cam.py                            |  55 ++--\n>  src/py/examples/hotplug-monitor.py           |  39 +++\n>  src/py/examples/simple-cam.py                |  31 +-\n>  src/py/examples/simple-capture.py            |  41 +--\n>  src/py/examples/simple-continuous-capture.py |  37 +--\n>  src/py/libcamera/meson.build                 |   2 +\n>  src/py/libcamera/py_camera_manager.cpp       | 286 ++++++++++++++++++\n>  src/py/libcamera/py_camera_manager.h         |  95 ++++++\n>  src/py/libcamera/py_helpers.cpp              |  97 ++++++\n>  src/py/libcamera/py_helpers.h                |  13 +\n>  src/py/libcamera/py_main.cpp                 | 297 +++++++------------\n>  src/py/libcamera/py_main.h                   |  14 +\n>  test/py/unittests.py                         |  93 +++---\n>  13 files changed, 781 insertions(+), 319 deletions(-)\n>  create mode 100644 src/py/examples/hotplug-monitor.py\n>  create mode 100644 src/py/libcamera/py_camera_manager.cpp\n>  create mode 100644 src/py/libcamera/py_camera_manager.h\n>  create mode 100644 src/py/libcamera/py_helpers.cpp\n>  create mode 100644 src/py/libcamera/py_helpers.h\n>  create mode 100644 src/py/libcamera/py_main.h","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0E6E0C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Aug 2022 21:09:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5EF7F61FC0;\n\tThu, 18 Aug 2022 23:09:20 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 948E261FA7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Aug 2022 23:09:18 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DFE018B;\n\tThu, 18 Aug 2022 23:09:17 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660856960;\n\tbh=4eqKlDtxjdhtybgx+0t/nFpeMBLBpJKWERqJjONiN+A=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=N6xsOL+f/OrAiXgVd5kAE/ucBbnWbyLu7ULEtJG6DhWni+qZSUea8CduVrJirDNm9\n\tdgkEsDXd/Q78E+Z6e3WD8/v78I2yIe25z9tiLUEgciXq70LLJ5JhM+AE0odONAmBgT\n\tBZwsB+sthjvVle3ek0pjRaLQDe5vEWhxhQzSIDkoKzAQDPdjUsLYfPCWLkoFMenD0x\n\tdvIjkcgWklu7VTmmSMjrj0rexWJkyQBwrWcd6nFuv3bxrODZLaCb56Ak5JQMpo5MyD\n\tKVI+rVz1fHtJryFQnu/8FdsuLu3pRukhLUXjQ3UmmD3GDOw0uY/nTF4tPhr1PgVSYY\n\tWEHXjSbRC4DDQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660856958;\n\tbh=4eqKlDtxjdhtybgx+0t/nFpeMBLBpJKWERqJjONiN+A=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=XXdu/L43IPSEjzdMx4LZldNi3gBrqpWfSdtJwJjJjTRAGRY+sXP+hqWzJAlWJRVcY\n\txNZ4b0iODdPuCz/4nuNFyTJ81ROpRNq86bOzDM8pwg835oBSyFl38UG+B3nF2OOVbC\n\tegU7O4mjC72F8eK7cf35rxnIfmQYygq7WLLskxFE="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"XXdu/L43\"; dkim-atps=neutral","Date":"Fri, 19 Aug 2022 00:09:14 +0300","To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Message-ID":"<Yv6qek2qO03HtWnJ@pendragon.ideasonboard.com>","References":"<20220701084521.31831-1-tomi.valkeinen@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220701084521.31831-1-tomi.valkeinen@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 00/17] Python bindings event\n\thandling","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]