From 3555a2f580bf87b6fb635cbf3c425166d3666715 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 11 Jan 2024 13:16:43 +0100 Subject: [PATCH] Update version to 1.0.1 Add patch to support libcamera 0.2 --- 0001-gst-keep-track-of-node-ports.patch | 98 ------------------- ...-use-CameraConfiguration-orientation.patch | 80 +++++++++++++++ pipewire.spec | 10 +- 3 files changed, 87 insertions(+), 101 deletions(-) delete mode 100644 0001-gst-keep-track-of-node-ports.patch create mode 100644 0001-spa-libcamera-use-CameraConfiguration-orientation.patch diff --git a/0001-gst-keep-track-of-node-ports.patch b/0001-gst-keep-track-of-node-ports.patch deleted file mode 100644 index 255689e..0000000 --- a/0001-gst-keep-track-of-node-ports.patch +++ /dev/null @@ -1,98 +0,0 @@ -From ecf4b071e5e474a362cde42dfdc8713da4a5b550 Mon Sep 17 00:00:00 2001 -From: Wim Taymans -Date: Thu, 14 Dec 2023 13:00:00 +0100 -Subject: [PATCH] gst: keep track of node ports - -Keep a list of ports for the node. When the node goes away, clear the -port links to the node. Handle the case where the port no longer has a -node. - -This avoids a crash when, for example, the node permission is removed -and the port points to the now freed node_data. - -Fixes #3708 ---- - src/gst/gstpipewiredeviceprovider.c | 17 +++++++++++++++++ - 1 file changed, 17 insertions(+) - -diff --git a/src/gst/gstpipewiredeviceprovider.c b/src/gst/gstpipewiredeviceprovider.c -index 03d763f40..30c436e52 100644 ---- a/src/gst/gstpipewiredeviceprovider.c -+++ b/src/gst/gstpipewiredeviceprovider.c -@@ -180,9 +180,11 @@ struct node_data { - struct pw_node_info *info; - GstCaps *caps; - GstDevice *dev; -+ struct spa_list ports; - }; - - struct port_data { -+ struct spa_list link; - struct node_data *node_data; - struct pw_port *proxy; - struct spa_hook proxy_listener; -@@ -353,6 +355,9 @@ static void port_event_info(void *data, const struct pw_port_info *info) - - pw_log_debug("%p", port_data); - -+ if (node_data == NULL) -+ return; -+ - if (info->change_mask & PW_PORT_CHANGE_MASK_PARAMS) { - for (i = 0; i < info->n_params; i++) { - uint32_t id = info->params[i].id; -@@ -375,6 +380,9 @@ static void port_event_param(void *data, int seq, uint32_t id, - struct node_data *node_data = port_data->node_data; - GstCaps *c1; - -+ if (node_data == NULL) -+ return; -+ - c1 = gst_caps_from_format (param); - if (c1 && node_data->caps) - gst_caps_append (node_data->caps, c1); -@@ -438,11 +446,17 @@ static void - destroy_node (void *data) - { - struct node_data *nd = data; -+ struct port_data *pd; - GstPipeWireDeviceProvider *self = nd->self; - GstDeviceProvider *provider = GST_DEVICE_PROVIDER (self); - - pw_log_debug("destroy %p", nd); - -+ spa_list_consume(pd, &nd->ports, link) { -+ spa_list_remove(&pd->link); -+ pd->node_data = NULL; -+ } -+ - if (nd->dev != NULL) { - gst_device_provider_device_remove (provider, GST_DEVICE (nd->dev)); - } -@@ -472,6 +486,7 @@ destroy_port (void *data) - { - struct port_data *pd = data; - pw_log_debug("destroy %p", pd); -+ spa_list_remove(&pd->link); - } - - static const struct pw_proxy_events proxy_port_events = { -@@ -515,6 +530,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, - nd->id = id; - if (!props || !spa_atou64(spa_dict_lookup(props, PW_KEY_OBJECT_SERIAL), &nd->serial, 0)) - nd->serial = SPA_ID_INVALID; -+ spa_list_init(&nd->ports); - spa_list_append(&self->nodes, &nd->link); - pw_node_add_listener(node, &nd->node_listener, &node_events, nd); - pw_proxy_add_listener((struct pw_proxy*)node, &nd->proxy_listener, &proxy_node_events, nd); -@@ -541,6 +557,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, - pd->id = id; - if (!props || !spa_atou64(spa_dict_lookup(props, PW_KEY_OBJECT_SERIAL), &pd->serial, 0)) - pd->serial = SPA_ID_INVALID; -+ spa_list_append(&nd->ports, &pd->link); - pw_port_add_listener(port, &pd->port_listener, &port_events, pd); - pw_proxy_add_listener((struct pw_proxy*)port, &pd->proxy_listener, &proxy_port_events, pd); - resync(self); --- -2.43.0 - diff --git a/0001-spa-libcamera-use-CameraConfiguration-orientation.patch b/0001-spa-libcamera-use-CameraConfiguration-orientation.patch new file mode 100644 index 0000000..471f7bf --- /dev/null +++ b/0001-spa-libcamera-use-CameraConfiguration-orientation.patch @@ -0,0 +1,80 @@ +From 268f4856f852d72a749932630223f928acd1a704 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= +Date: Sat, 28 Oct 2023 02:09:06 +0200 +Subject: [PATCH 1/2] spa: libcamera: use `CameraConfiguration::orientation` + +libcamera commit cc65629b68d49d ("libcamera: camera: Introduce Orientation") [0] +introduced to the `CameraConfiguration::orientation` member to describe the +orientation of the image in the received memory buffers. + +Then c65e40b8480ffb ("libcamera: Use CameraConfiguration::orientation") [1] +removed `CameraConfiguration::transform`, which broke the libcamera plugin. + +Fix that by using the new `orientation` member. + +[0]: https://git.linuxtv.org/libcamera.git/commit/?id=cc65629b68d49d5f2a4d61537584c56ba510a335 +[1]: https://git.linuxtv.org/libcamera.git/commit/?id=c65e40b8480ffb5f50e01a4e6713164c7194a937 +--- + spa/plugins/libcamera/libcamera-utils.cpp | 36 +++++++++++------------ + 1 file changed, 17 insertions(+), 19 deletions(-) + +diff --git a/spa/plugins/libcamera/libcamera-utils.cpp b/spa/plugins/libcamera/libcamera-utils.cpp +index 2b1aea5a7..c197248d3 100644 +--- a/spa/plugins/libcamera/libcamera-utils.cpp ++++ b/spa/plugins/libcamera/libcamera-utils.cpp +@@ -716,25 +716,23 @@ static int spa_libcamera_use_buffers(struct impl *impl, struct port *port, + } + + static const struct { +- Transform libcamera_transform; +- uint32_t spa_transform_value; +-} transform_map[] = { +- { Transform::Identity, SPA_META_TRANSFORMATION_None }, +- { Transform::Rot0, SPA_META_TRANSFORMATION_None }, +- { Transform::HFlip, SPA_META_TRANSFORMATION_Flipped }, +- { Transform::VFlip, SPA_META_TRANSFORMATION_Flipped180 }, +- { Transform::HVFlip, SPA_META_TRANSFORMATION_180 }, +- { Transform::Rot180, SPA_META_TRANSFORMATION_180 }, +- { Transform::Transpose, SPA_META_TRANSFORMATION_Flipped90 }, +- { Transform::Rot90, SPA_META_TRANSFORMATION_90 }, +- { Transform::Rot270, SPA_META_TRANSFORMATION_270 }, +- { Transform::Rot180Transpose, SPA_META_TRANSFORMATION_Flipped270 }, ++ Orientation libcamera_orientation; /* clockwise rotation then horizontal mirroring */ ++ uint32_t spa_transform_value; /* horizontal mirroring then counter-clockwise rotation */ ++} orientation_map[] = { ++ { Orientation::Rotate0, SPA_META_TRANSFORMATION_None }, ++ { Orientation::Rotate0Mirror, SPA_META_TRANSFORMATION_Flipped }, ++ { Orientation::Rotate90, SPA_META_TRANSFORMATION_270 }, ++ { Orientation::Rotate90Mirror, SPA_META_TRANSFORMATION_Flipped90 }, ++ { Orientation::Rotate180, SPA_META_TRANSFORMATION_180 }, ++ { Orientation::Rotate180Mirror, SPA_META_TRANSFORMATION_Flipped180 }, ++ { Orientation::Rotate270, SPA_META_TRANSFORMATION_90 }, ++ { Orientation::Rotate270Mirror, SPA_META_TRANSFORMATION_Flipped270 }, + }; + +-static uint32_t libcamera_transform_to_spa_transform_value(Transform transform) ++static uint32_t libcamera_orientation_to_spa_transform_value(Orientation orientation) + { +- for (const auto& t : transform_map) { +- if (t.libcamera_transform == transform) ++ for (const auto& t : orientation_map) { ++ if (t.libcamera_orientation == orientation) + return t.spa_transform_value; + } + return SPA_META_TRANSFORMATION_None; +@@ -788,9 +786,9 @@ mmap_init(struct impl *impl, struct port *port, + buffers[i], SPA_META_VideoTransform, sizeof(*b->videotransform)); + if (b->videotransform) { + b->videotransform->transform = +- libcamera_transform_to_spa_transform_value(impl->config->transform); +- spa_log_debug(impl->log, "Setting videotransform for buffer %d to %u (from %s)", +- i, b->videotransform->transform, transformToString(impl->config->transform)); ++ libcamera_orientation_to_spa_transform_value(impl->config->orientation); ++ spa_log_debug(impl->log, "Setting videotransform for buffer %u to %u", ++ i, b->videotransform->transform); + + } + +-- +2.43.0 + diff --git a/pipewire.spec b/pipewire.spec index feb20e5..8e63bde 100644 --- a/pipewire.spec +++ b/pipewire.spec @@ -1,6 +1,6 @@ %global majorversion 1 %global minorversion 0 -%global microversion 0 +%global microversion 1 %global apiversion 0.3 %global spaversion 0.2 @@ -9,7 +9,7 @@ %global ms_version 0.4.2 # For rpmdev-bumpspec and releng automation -%global baserelease 2 +%global baserelease 1 #global snapdate 20210107 #global gitcommit b17db2cebc1a5ab2c01851d29c05f79cd2f262bb @@ -77,7 +77,7 @@ Source0: https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/%{ver Source1: pipewire.sysusers ## upstream patches -Patch0001: 0001-gst-keep-track-of-node-ports.patch +Patch0001: 0001-spa-libcamera-use-CameraConfiguration-orientation.patch ## upstreamable patches @@ -812,6 +812,10 @@ systemctl --no-reload preset --global pipewire.socket >/dev/null 2>&1 || : %endif %changelog +* Thu Jan 11 2024 Wim Taymans - 1.0.1-1 +- Update version to 1.0.1 +- Add patch to support libcamera 0.2 + * Thu Dec 14 2023 Wim Taymans - 1.0.0-2 - Add patch to avoid crash in deviceprovider.