From patchwork Sun Aug 1 18:51:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vedant Paranjape X-Patchwork-Id: 13174 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 ECF04BD878 for ; Sun, 1 Aug 2021 18:52:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 43352687B1; Sun, 1 Aug 2021 20:52:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OamRZLaC"; dkim-atps=neutral Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C2EB6687B1 for ; Sun, 1 Aug 2021 20:52:07 +0200 (CEST) Received: by mail-pj1-x1031.google.com with SMTP id j1so22322771pjv.3 for ; Sun, 01 Aug 2021 11:52:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SBH+mi43u+IxJlu4Rvq9i0XtiCXwKHN3d7cn6OkBSpw=; b=OamRZLaC5EC7J0WNaGaESQlF5wj+atFMrcQ9lexZ+ui9jqcUHR4ZAF5VWdPqrk4hOP 3cx73kYOX0xdGlTzpNu8HNaVld1eWYSjM+chgiQRb48Ph5ciyNbGiBOaEy2MBiO6f0xF 1uZL+icktv5mEs8SQepbRkQgz4Wff2s1bJD26yLj6+Gq1FLT5GWmcWJ3A08SfpASBd+0 0ucWf8OeNIJqawOAdyHP1dy8d8oTlErX5UmKJ3vBVjXJK2BfMKpkuLt1UHgNIh3ll6D0 3mzBswBca/vCFktp8ux4d1mrhxH+bsIij/59j4dVNRWNC4iV1eemzJiWjDf/ea8n6bnn 0D1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SBH+mi43u+IxJlu4Rvq9i0XtiCXwKHN3d7cn6OkBSpw=; b=pERx1WgOmI+T6OXnyEkZyEHvu0jH/vL+N8g0lF+gEtrJTzEfJb5QyWHRbkrw/cpLVt +O3BCb573aDnW+kj9T4dCtWqbYF+khM+sd3S2xMAcJMfrq6JaSDAiKitQ6jntBQQnaLL PP7cn+wm+L9g6Uecw6lQeNwWpbJf9CwsQKhpdJf5XlchA7m1YlOnXU8OiZ1IzUXiTk0p EXMLFM3ezhp7NkM7QDs7i6hCYPQJCpFyaamKT5odHMf+d7Zmu4MXcxNVNbAHJvTQmVnK k6JBWoPSRoB+C8qEhtXILNgi4Enwuj4JmLl7nL1Ad4UXYH1nUmvy9dwrMU2O1noBtevB WSnA== X-Gm-Message-State: AOAM533NVxDhr8hK6Lp59uuh0SlpUifOrHRzSEpzOaSDePT+F+8jqWrd +b190G3RsPXC+PmCBgyj90++mDcyZD83Lg== X-Google-Smtp-Source: ABdhPJwCxOsd+7qmmwbXuR9+CDUBBl3hbPY5nwK+T9YhuAt2rEycjfnHO4x3gQOelKyDcZ6p8Rvofw== X-Received: by 2002:a05:6a00:1245:b029:30f:2098:fcf4 with SMTP id u5-20020a056a001245b029030f2098fcf4mr13233997pfi.66.1627843925443; Sun, 01 Aug 2021 11:52:05 -0700 (PDT) Received: from localhost.localdomain ([1.186.166.116]) by smtp.googlemail.com with ESMTPSA id d9sm9968311pgm.89.2021.08.01.11.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Aug 2021 11:52:05 -0700 (PDT) From: Vedant Paranjape To: libcamera-devel@lists.libcamera.org Date: Mon, 2 Aug 2021 00:21:44 +0530 Message-Id: <20210801185144.21572-1-vedantparanjape160201@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2] gstreamer: Factor out _pad_push_stream_start from _task_enter 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: , Cc: Vedant Paranjape Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This patch creates gst_libcamera_pad_push_stream_start function to create stream id and to push the stream start. Update functional code in gst_libcamera_src_task_enter(), which creates stream id and pushes the stream start with the refactored function gst_libcamera_pad_push_stream_start(). Signed-off-by: Vedant Paranjape --- src/gstreamer/gstlibcamerapad.cpp | 19 +++++++++++++++++++ src/gstreamer/gstlibcamerapad.h | 2 ++ src/gstreamer/gstlibcamerasrc.cpp | 7 +------ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/gstreamer/gstlibcamerapad.cpp b/src/gstreamer/gstlibcamerapad.cpp index c00e81c8..d4211050 100644 --- a/src/gstreamer/gstlibcamerapad.cpp +++ b/src/gstreamer/gstlibcamerapad.cpp @@ -20,6 +20,7 @@ struct _GstLibcameraPad { GstLibcameraPool *pool; GQueue pending_buffers; GstClockTime latency; + gint stream_id_num; }; enum { @@ -81,6 +82,7 @@ static void gst_libcamera_pad_init(GstLibcameraPad *self) { GST_PAD_QUERYFUNC(self) = gst_libcamera_pad_query; + self->stream_id_num = 0; } static GType @@ -155,6 +157,23 @@ gst_libcamera_pad_get_stream(GstPad *pad) return nullptr; } +void +gst_libcamera_pad_push_stream_start(GstPad *pad, const guint group_id) +{ + auto *self = GST_LIBCAMERA_PAD(pad); + { + GLibLocker lock(GST_OBJECT(self)); + self->stream_id_num++; + } + + g_autoptr(GstElement) element = gst_pad_get_parent_element(pad); + g_autofree gchar *stream_id_intermediate = g_strdup_printf("%i%i", group_id, self->stream_id_num); + g_autofree gchar *stream_id = gst_pad_create_stream_id(pad, element, stream_id_intermediate); + GstEvent *event = gst_event_new_stream_start(stream_id); + gst_event_set_group_id(event, group_id); + gst_pad_push_event(pad, event); +} + void gst_libcamera_pad_queue_buffer(GstPad *pad, GstBuffer *buffer) { diff --git a/src/gstreamer/gstlibcamerapad.h b/src/gstreamer/gstlibcamerapad.h index 779f2d13..7693374f 100644 --- a/src/gstreamer/gstlibcamerapad.h +++ b/src/gstreamer/gstlibcamerapad.h @@ -26,6 +26,8 @@ void gst_libcamera_pad_set_pool(GstPad *pad, GstLibcameraPool *pool); libcamera::Stream *gst_libcamera_pad_get_stream(GstPad *pad); +void gst_libcamera_pad_push_stream_start(GstPad *pad, const guint group_id); + void gst_libcamera_pad_queue_buffer(GstPad *pad, GstBuffer *buffer); GstFlowReturn gst_libcamera_pad_push_pending(GstPad *pad); diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index b18f1efb..bb8ea07a 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -361,15 +361,10 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread, GST_DEBUG_OBJECT(self, "Streaming thread has started"); - gint stream_id_num = 0; StreamRoles roles; for (GstPad *srcpad : state->srcpads_) { /* Create stream-id and push stream-start. */ - g_autofree gchar *stream_id_intermediate = g_strdup_printf("%i%i", state->group_id_, stream_id_num++); - g_autofree gchar *stream_id = gst_pad_create_stream_id(srcpad, GST_ELEMENT(self), stream_id_intermediate); - GstEvent *event = gst_event_new_stream_start(stream_id); - gst_event_set_group_id(event, state->group_id_); - gst_pad_push_event(srcpad, event); + gst_libcamera_pad_push_stream_start(srcpad, state->group_id_); /* Collect the streams roles for the next iteration. */ roles.push_back(gst_libcamera_pad_get_role(srcpad));