From patchwork Wed Jun 14 16:21:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 18736 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 09BACBD78E for ; Wed, 14 Jun 2023 16:22:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 42BB361E4D; Wed, 14 Jun 2023 18:22:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1686759773; bh=EvgLNcsfi1kumBXgx++fm7GpEvviOWhaMyY/etDgtiE=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=3kQ7lW8P3bg+o+wSlzxzgZ6sme3mrLTRxIfgTtoi0hEvMZJgUK+YMG/HlZa215gHb gVWF6GMFzTWIeJkcPnf+Ea5cm6syhFVZRffbsU5mZ3ciWyuea15maQnBX24Y/mQPtZ MSNjh9wBeWo4d8cdPEqT+Pg36L9k7bpzhW5EY/S24MNKUNvLJW+/4fjrdf5PB79Ete 19E/q7DH8V6sI5mGMwj1VrWh5JLPmnKqaEhb8SLUofz0OJLSO6FWlQVFMQ0rQ12V9G 3W5WmzMNJdyO9c3jROJAwy+xi9Ca++/BGs9af1rwj7sT/8ttjFZ9W0b/zFmr33qKbq HOujsHhvCi59g== Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 54C0161E4A for ; Wed, 14 Jun 2023 18:22:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="SSvSBxd8"; dkim-atps=neutral Received: from thinkpad-t460p.fritz.box (unknown [IPv6:2001:4090:a243:8015:93c:83c3:533:d433]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: rmader) by madras.collabora.co.uk (Postfix) with ESMTPSA id D633F6606F52; Wed, 14 Jun 2023 17:22:50 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686759771; bh=EvgLNcsfi1kumBXgx++fm7GpEvviOWhaMyY/etDgtiE=; h=From:To:Cc:Subject:Date:From; b=SSvSBxd8JeYKCTl57Q79ssoMTSRQRnhfKY9S6I4WXfSFIfJFwUCWM4e0Eh9JLNpOn qIDyrs35jFtRSR6WQmDhITZiqGmaEDQEu9PfDyzKvgWNc5ENJ2sc0CX5aMXclss9gz 2hd5AVay0jyFzJpSltquG0C1Wrl+T7ZLTLlhlqSBtXMEwyIbO0qc4QIyri+zPk1IRz HRtCg8tfcRhaK/6wN+Tac4w/gZ7dq9KiW/tEGyDaTO/3mxN7lfAcDDSrKg8w+YzPOQ 7VLxAaMVNYq8R4hWpzNiRXKb/iWgTorPVpbE3nC9z8A8J3txUTYalFK9KHJAUwxtdn q7rBK6ytE7tfw== To: libcamera-devel@lists.libcamera.org Date: Wed, 14 Jun 2023 18:21:53 +0200 Message-ID: <20230614162222.20943-1-robert.mader@collabora.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] gstreamer: src: Send image-orientation tag 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: Robert Mader via libcamera-devel From: Robert Mader Reply-To: Robert Mader Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Matching the validated Transform of the configuration, if the transform is not the Identity. As we currently always request a configuration with `Identity` transform, this can be the case if camera has a rotation property (90/180/270 degree) and the sensor can't do rotation in question. Sending the orientation-tag allows downstream elements to compensate accordingly. This matches current pipewiresrc behavior and can be tested with e.g.: gst-launch-1.0 libcamerasrc ! videoconvert ! videoflip video-direction=auto ! gtksink Signed-off-by: Robert Mader --- src/gstreamer/gstlibcamera-utils.cpp | 24 ++++++++++++++++++++++++ src/gstreamer/gstlibcamera-utils.h | 3 +++ src/gstreamer/gstlibcamerasrc.cpp | 11 +++++++++++ 3 files changed, 38 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 750ec351..3bfbc354 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -553,3 +553,27 @@ gst_libcamera_get_camera_manager(int &ret) return cm; } + +const char * +gst_libcamera_transform_to_tag_string(libcamera::Transform transform) +{ + switch (transform) { + case Transform::Rot90: + return "rotate-90"; + case Transform::Rot180: + return "rotate-180"; + case Transform::Rot270: + return "rotate-270"; + case Transform::HFlip: + return "flip-rotate-0"; + case Transform::VFlip: + return "flip-rotate-180"; + case Transform::Transpose: + return "flip-rotate-270"; + case Transform::Rot180Transpose: + return "flip-rotate-90"; + case Transform::Identity: + default: + return "rotate-0"; + } +} diff --git a/src/gstreamer/gstlibcamera-utils.h b/src/gstreamer/gstlibcamera-utils.h index fd304a8b..499533c4 100644 --- a/src/gstreamer/gstlibcamera-utils.h +++ b/src/gstreamer/gstlibcamera-utils.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -30,6 +31,8 @@ gboolean gst_task_resume(GstTask *task); #endif std::shared_ptr gst_libcamera_get_camera_manager(int &ret); +const char *gst_libcamera_transform_to_tag_string(libcamera::Transform transform); + /** * \class GLibLocker * \brief A simple scoped mutex locker for GMutex diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index a10cbd4f..b41f52d7 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -461,6 +461,7 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread, GLibRecLocker lock(&self->stream_lock); GstLibcameraSrcState *state = self->state; GstFlowReturn flow_ret = GST_FLOW_OK; + const char *transform_tag; gint ret; g_autoptr(GstStructure) element_caps = gst_structure_new_empty("caps"); @@ -519,6 +520,16 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread, goto done; } + transform_tag = gst_libcamera_transform_to_tag_string(state->config_->transform); + for (gsize i = 0; i < state->srcpads_.size(); i++) { + GstPad *srcpad = state->srcpads_[i]; + GstEvent *tag_event; + + tag_event = gst_event_new_tag(gst_tag_list_new(GST_TAG_IMAGE_ORIENTATION, + transform_tag, NULL)); + gst_pad_push_event(srcpad, tag_event); + } + ret = state->cam_->configure(state->config_.get()); if (ret) { GST_ELEMENT_ERROR(self, RESOURCE, SETTINGS,