Patch Detail
Show a patch.
GET /api/patches/12544/?format=api
{ "id": 12544, "url": "https://patchwork.libcamera.org/api/patches/12544/?format=api", "web_url": "https://patchwork.libcamera.org/patch/12544/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210610080201.87151-1-vedantparanjape160201@gmail.com>", "date": "2021-06-10T08:02:01", "name": "[libcamera-devel,RFC,v3] gstreamer: Added virtual functions needed to support request pads", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "95d5ad911db8c422bd4dad37bbb1292a6fccd968", "submitter": { "id": 85, "url": "https://patchwork.libcamera.org/api/people/85/?format=api", "name": "Vedant Paranjape", "email": "vedantparanjape160201@gmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/12544/mbox/", "series": [ { "id": 2116, "url": "https://patchwork.libcamera.org/api/series/2116/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2116", "date": "2021-06-10T08:02:01", "name": "[libcamera-devel,RFC,v3] gstreamer: Added virtual functions needed to support request pads", "version": 3, "mbox": "https://patchwork.libcamera.org/series/2116/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/12544/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/12544/checks/", "tags": {}, "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 7DE17C320B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 10 Jun 2021 08:02:25 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BF8FC6892C;\n\tThu, 10 Jun 2021 10:02:24 +0200 (CEST)", "from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com\n\t[IPv6:2607:f8b0:4864:20::1036])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 581576892B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 10 Jun 2021 10:02:23 +0200 (CEST)", "by mail-pj1-x1036.google.com with SMTP id\n\tfy24-20020a17090b0218b029016c5a59021fso3286948pjb.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 10 Jun 2021 01:02:23 -0700 (PDT)", "from localhost.localdomain ([1.186.76.76])\n\tby smtp.googlemail.com with ESMTPSA id\n\th6sm1634843pfk.40.2021.06.10.01.02.19\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 10 Jun 2021 01:02:20 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"iNJNbH/+\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=qSPpFaDkOImbCrU3uKegSkTvSFR8BJwZwXsAe8WdFR8=;\n\tb=iNJNbH/+d0gGYg5ejQ0J3r1EKRzZOsfmMj5RWh8fr1KuL22MS69UOTdzGZDDwoRVTj\n\tpQhYP1uSCJjPFY1TX42MbmDD8YJEdGzDtHq1pY55PJ9nXqr8XGxPpBkUPiGheGgHEG3N\n\tSvWK/Q21qIbm60L1umBWi/9bjihdeAd3UwRYmCpRPnwz2JAK+b9Nxp/6XNGg1ZOPg1sY\n\tVvpxfHpZfrXJA7rcQIs390IHrT//72Ov9wL4p0wciOYfAMz5nMCE7SH1WD7VZWg1fXXZ\n\tvPNhRHSiNYWibUyYVtZG7voOluAcM/l7/NHVPvD9jSFEZmFL0ifEkpMtX94ACL4Z1yXC\n\tKDtg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=qSPpFaDkOImbCrU3uKegSkTvSFR8BJwZwXsAe8WdFR8=;\n\tb=Vx2B/t2YmioH89Jju/dqu6gixGiLIrj3SOJ+Gx39qid/dETEX4pKvw84tuHvi3Jn3h\n\tlcuKeTwDD7auXumViFmWROC/v41Bn0O3X1vdHsTmgJDcb7MPwQw9chM/pEyatkGjfyKi\n\tDx+vHgASOzh7OGrXs5alLgnzgsoFZJofMM8wj9O0N464HC8jy4nT70iAm/3KNb8OHzYk\n\t3GldqxTE47qpXpcbySXO+Ol9BNSHJovgznHJz9meaDPo10UFJdlVT0ApTyPNxICgayR/\n\tKmw3nwBSjOFrwZmDFBAqazC7/0upaELRkC1ERtWr3hUUp9o06pXGCbm+xFsNY5baX/Au\n\tRxGQ==", "X-Gm-Message-State": "AOAM530bCdgdOLA2Yml9U3klkd1HunQEyjHubdb9h0Xyf9j+cRSsvFgh\n\tcd+CGDq8sDG3Ua18T8P6nkHeVgC+THLGq/sSsLw=", "X-Google-Smtp-Source": "ABdhPJz0kKBifL1bHq3aQWdX4AIDSqy+KeJQr57vdG2RVfPqkhVQsO9IS5pc/URZeTJ9l49Qnp5K8w==", "X-Received": "by 2002:a17:90a:af85:: with SMTP id\n\tw5mr2058719pjq.235.1623312141365; \n\tThu, 10 Jun 2021 01:02:21 -0700 (PDT)", "From": "Vedant Paranjape <vedantparanjape160201@gmail.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 10 Jun 2021 13:32:01 +0530", "Message-Id": "<20210610080201.87151-1-vedantparanjape160201@gmail.com>", "X-Mailer": "git-send-email 2.25.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC PATCH v3] gstreamer: Added virtual functions\n\tneeded to support request pads", "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>", "Cc": "Vedant Paranjape <vedantparanjape160201@gmail.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Using request pads needs virtual functions to create new request pads and\nrelease the allocated pads. Added way to generate unique stream_id in\ngst_libcamera_src_task_enter(). It failed to execute when more than one\npad was added.\n\nThis patch defines the functions gst_libcamera_src_request_new_pad() and\ngst_libcamera_src_release_pad() which handle, creating and releasing\nrequest pads. Also assigns these functions to their callback\nhandlers in GstLibcameraSrcClass.\n\ngst_pad_create_stream_id() failed as this gstreamer element has more than 2\nsource pads, and a nullptr was passed to it's stream_id argument.\nThis function fails to auto generate a stream id for scenario of more\nthan one source pad present.\n\nUsed a gint which increments everytime new stream_id is requested and\ngroup_id to generate an unique stream_id by appending them togther as\n%i%i.\n\nThis doesn't enable request pad support in gstreamer element. This is\none of the series of changes needed to make it work.\n\nSigned-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n\nIn _request_new_pad and _release_pad, a GLibLock is taken on\nself->state. But since self->state is a C++ object,\nGST_OBJECT(self->state) fails and returns null, so GLibLocker throws a\nwarning \"invalid cast from '(null)' to 'GstObject'. This means that it\nactually fails to get lock the resource that needs to be protected,\ni.e., the srcpads_ vector.\n---\n src/gstreamer/gstlibcamerasrc.cpp | 56 ++++++++++++++++++++++++++++++-\n 1 file changed, 55 insertions(+), 1 deletion(-)", "diff": "diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex ccc61590..d8c17b9c 100644\n--- a/src/gstreamer/gstlibcamerasrc.cpp\n+++ b/src/gstreamer/gstlibcamerasrc.cpp\n@@ -361,10 +361,11 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread,\n \tGST_DEBUG_OBJECT(self, \"Streaming thread has started\");\n \n \tguint group_id = gst_util_group_id_next();\n+\tgint stream_id_num = 0;\n \tStreamRoles roles;\n \tfor (GstPad *srcpad : state->srcpads_) {\n \t\t/* Create stream-id and push stream-start. */\n-\t\tg_autofree gchar *stream_id = gst_pad_create_stream_id(srcpad, GST_ELEMENT(self), nullptr);\n+\t\tg_autofree gchar *stream_id = gst_pad_create_stream_id(srcpad, GST_ELEMENT(self), g_strdup_printf(\"%i%i\", group_id, stream_id_num++));\n \t\tGstEvent *event = gst_event_new_stream_start(stream_id);\n \t\tgst_event_set_group_id(event, group_id);\n \t\tgst_pad_push_event(srcpad, event);\n@@ -640,6 +641,57 @@ gst_libcamera_src_init(GstLibcameraSrc *self)\n \tself->state = state;\n }\n \n+static GstPad*\n+gst_libcamera_src_request_new_pad(GstElement *element, GstPadTemplate *templ,\n+\t\t\t\t\tconst gchar *name, [[maybe_unused]] const GstCaps *caps)\n+{\n+\tGstLibcameraSrc *self = GST_LIBCAMERA_SRC(element);\n+\tg_autoptr(GstPad) pad = NULL;\n+\n+\tGST_DEBUG_OBJECT(self, \"new request pad created\");\n+\n+\tpad = gst_pad_new_from_template(templ, name);\n+\tg_object_ref_sink(pad);\n+\t\n+\t{\n+\t\tGLibLocker lock(GST_OBJECT(self->state));\n+\t\tself->state->srcpads_.push_back(reinterpret_cast<GstPad*>(g_object_ref(pad)));\n+\n+\t\tif (!gst_element_add_pad(element, pad))\n+\t\t{\n+\t\t\tGST_ELEMENT_ERROR (element, STREAM, FAILED,\n+\t\t\t\t(\"Internal data stream error.\"), (\"Could not add pad to element\"));\n+\t\t\tself->state->srcpads_.pop_back();\n+\t\t\treturn NULL;\t\t\n+\t\t}\n+\t}\n+\t\n+\treturn reinterpret_cast<GstPad*>(g_steal_pointer(&pad));\n+}\n+\n+static void\n+gst_libcamera_src_release_pad(GstElement *element, GstPad *pad)\n+{\n+\tGstLibcameraSrc *self = GST_LIBCAMERA_SRC(element);\n+\t\n+\tGST_DEBUG_OBJECT (self, \"Pad %\" GST_PTR_FORMAT \" being released\", pad);\n+\n+\t{\n+\t\tGLibLocker lock(GST_OBJECT(self->state));\n+\t\tstd::vector<GstPad*> &pads = self->state->srcpads_;\n+\t\tauto begin_iterator = pads.begin();\n+\t\tauto end_iterator = pads.end();\n+\t\tauto pad_iterator = std::find(begin_iterator, end_iterator, pad);\n+\n+\t\tif (pad_iterator != end_iterator)\n+\t\t{\n+\t\t\tg_object_unref(*pad_iterator);\n+\t\t\tpads.erase(pad_iterator);\n+\t\t}\n+\t}\n+\tgst_element_remove_pad(element, pad);\n+}\t\n+\n static void\n gst_libcamera_src_class_init(GstLibcameraSrcClass *klass)\n {\n@@ -650,6 +702,8 @@ gst_libcamera_src_class_init(GstLibcameraSrcClass *klass)\n \tobject_class->get_property = gst_libcamera_src_get_property;\n \tobject_class->finalize = gst_libcamera_src_finalize;\n \n+\telement_class->request_new_pad = gst_libcamera_src_request_new_pad;\n+\telement_class->release_pad = gst_libcamera_src_release_pad;\n \telement_class->change_state = gst_libcamera_src_change_state;\n \n \tgst_element_class_set_metadata(element_class,\n", "prefixes": [ "libcamera-devel", "RFC", "v3" ] }