diff --git a/multimedia/gst1-plugins-base/Makefile b/multimedia/gst1-plugins-base/Makefile index 5949d2cb0953b..d2e2ba78c5576 100644 --- a/multimedia/gst1-plugins-base/Makefile +++ b/multimedia/gst1-plugins-base/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gst1-plugins-base PKG_VERSION:=1.28.7 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=gst-plugins-base-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://gstreamer.freedesktop.org/src/gst-plugins-base diff --git a/multimedia/gst1-plugins-base/patches/010-rtsp-watch-heap-arrays.patch b/multimedia/gst1-plugins-base/patches/010-rtsp-watch-heap-arrays.patch new file mode 100644 index 0000000000000..4f04d94dc4888 --- /dev/null +++ b/multimedia/gst1-plugins-base/patches/010-rtsp-watch-heap-arrays.patch @@ -0,0 +1,75 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sat, 17 Oct 2026 03:20:00 +0100 +Subject: [PATCH] rtsp: allocate the message arrays of the watch on the heap + +gst_rtsp_watch_send_messages() and gst_rtsp_watch_write_serialized_messages() +allocate arrays on the stack that grow with the number of messages and +of memories in them. An RTSP server sending a video frame over TCP +passes every RTP packet of the frame in one call, which are several +hundred for a 4K frame, and the arrays took 150 KiB of the stack of the +sending thread. A thread stack of 128 KiB, the default of musl, was +overrun and the server crashed with a segmentation fault. Use the heap +for these arrays. + +Link: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/work_items/5358 +Assisted-by: LLM +Signed-off-by: Daniel Golle +--- +--- a/gst-libs/gst/rtsp/gstrtspconnection.c ++++ b/gst-libs/gst/rtsp/gstrtspconnection.c +@@ -4778,8 +4778,8 @@ gst_rtsp_watch_write_serialized_messages + } + } + +- vectors = g_newa (GOutputVector, n_vectors); +- map_infos = n_memories ? g_newa (GstMapInfo, n_memories) : NULL; ++ vectors = g_new (GOutputVector, n_vectors); ++ map_infos = n_memories ? g_new (GstMapInfo, n_memories) : NULL; + + for (i = 0, j = 0, k = 0, bytes_to_write = 0; i < n_messages; i++) { + vectors[j].buffer = messages[i].data_is_data_header ? +@@ -4827,6 +4827,8 @@ gst_rtsp_watch_write_serialized_messages + for (k = 0; k < n_memories; k++) { + gst_memory_unmap (map_infos[k].memory, &map_infos[k]); + } ++ g_free (map_infos); ++ g_free (vectors); + + if (res != GST_RTSP_EINTR) { + /* actual error or done completely */ +@@ -5073,27 +5075,30 @@ gst_rtsp_watch_send_messages (GstRTSPWat + guint n_messages, guint * id) + { + GstRTSPSerializedMessage *serialized_messages; ++ GstRTSPResult res; + gint i; + + g_return_val_if_fail (watch != NULL, GST_RTSP_EINVAL); + g_return_val_if_fail (messages != NULL || n_messages == 0, GST_RTSP_EINVAL); + +- serialized_messages = g_newa (GstRTSPSerializedMessage, n_messages); +- memset (serialized_messages, 0, +- sizeof (GstRTSPSerializedMessage) * n_messages); ++ serialized_messages = g_new0 (GstRTSPSerializedMessage, n_messages); + + for (i = 0; i < n_messages; i++) { + if (!serialize_message (watch->conn, &messages[i], &serialized_messages[i])) + goto error; + } + +- return gst_rtsp_watch_write_serialized_messages (watch, serialized_messages, ++ res = gst_rtsp_watch_write_serialized_messages (watch, serialized_messages, + n_messages, id); ++ g_free (serialized_messages); ++ ++ return res; + + error: + for (i = 0; i < n_messages; i++) { + gst_rtsp_serialized_message_clear (&serialized_messages[i]); + } ++ g_free (serialized_messages); + + return GST_RTSP_EINVAL; + } diff --git a/multimedia/gst1-rtsp-server/Makefile b/multimedia/gst1-rtsp-server/Makefile new file mode 100644 index 0000000000000..635e822ccf823 --- /dev/null +++ b/multimedia/gst1-rtsp-server/Makefile @@ -0,0 +1,110 @@ +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=gst1-rtsp-server +PKG_VERSION:=1.28.7 +PKG_RELEASE:=1 + +PKG_SOURCE:=gst-rtsp-server-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=https://gstreamer.freedesktop.org/src/gst-rtsp-server +PKG_HASH:=de43a59a0c89a14eb1c14ae8e81e5b45c4e9d7b1f930b0ebaad360f9b5e0b5c4 +PKG_BUILD_DIR:=$(BUILD_DIR)/gst-rtsp-server-$(PKG_VERSION) + +PKG_MAINTAINER:=Daniel Golle +PKG_LICENSE:=LGPL-2.0-or-later +PKG_LICENSE_FILES:=COPYING COPYING.LIB + +GST_VERSION:=1.0 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk +include $(INCLUDE_DIR)/meson.mk + +define Package/gst1-rtsp-server/Default + SECTION:=multimedia + CATEGORY:=Multimedia + URL:=https://gstreamer.freedesktop.org/modules/gst-rtsp-server.html +endef + +define Package/libgst1rtspserver + $(call Package/gst1-rtsp-server/Default) + TITLE:=GStreamer RTSP server library + DEPENDS:=+libgstreamer1 +glib2 +libgst1app +libgst1net +libgst1rtp \ + +libgst1rtsp +libgst1sdp +libgst1video +endef + +define Package/libgst1rtspserver/description + A library to build RTSP servers on top of GStreamer pipelines. +endef + +define Package/gst1-mod-rtspclientsink + $(call Package/gst1-rtsp-server/Default) + TITLE:=GStreamer RTSP client sink (rtspclientsink) + DEPENDS:=+libgstreamer1 +libgst1net +libgst1rtp +libgst1rtsp +libgst1sdp \ + +libgst1rtspserver +gst1-mod-rtpmanager +gst1-mod-rtsp +endef + +define Package/gst1-mod-rtspclientsink/description + The rtspclientsink element, which pushes a stream to an RTSP server. +endef + +define Package/gst1-rtsp-launch + $(call Package/gst1-rtsp-server/Default) + TITLE:=Serve a GStreamer pipeline over RTSP + DEPENDS:=+libgst1rtspserver +gstreamer1-plugins-base +gst1-mod-rtp \ + +gst1-mod-rtpmanager +gst1-mod-udp +gst1-mod-videoparsersbad +endef + +define Package/gst1-rtsp-launch/description + The test-launch example of gst-rtsp-server. It takes a gst-launch style + pipeline ending in a payloader named pay0 and serves it at + rtsp://:8554/test. +endef + +MESON_ARGS += \ + -Dexamples=enabled \ + -Dtests=disabled \ + -Ddoc=disabled \ + -Dintrospection=disabled \ + -Drtspclientsink=enabled \ + -Dglib_debug=disabled \ + -Dglib_assert=false \ + -Dglib_checks=false + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/gstreamer-$(GST_VERSION) + $(CP) $(PKG_INSTALL_DIR)/usr/include/gstreamer-$(GST_VERSION)/gst \ + $(1)/usr/include/gstreamer-$(GST_VERSION)/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libgstrtspserver-$(GST_VERSION).so* \ + $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/gstreamer-rtsp-server-$(GST_VERSION).pc \ + $(1)/usr/lib/pkgconfig/ +endef + +define Package/libgst1rtspserver/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libgstrtspserver-$(GST_VERSION).so.* \ + $(1)/usr/lib/ +endef + +define Package/gst1-mod-rtspclientsink/install + $(INSTALL_DIR) $(1)/usr/lib/gstreamer-$(GST_VERSION) + $(CP) $(PKG_INSTALL_DIR)/usr/lib/gstreamer-$(GST_VERSION)/libgstrtspclientsink.so \ + $(1)/usr/lib/gstreamer-$(GST_VERSION)/ +endef + +define Package/gst1-rtsp-launch/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(MESON_BUILD_DIR)/examples/test-launch \ + $(1)/usr/bin/gst-rtsp-launch +endef + +$(eval $(call BuildPackage,libgst1rtspserver)) +$(eval $(call BuildPackage,gst1-mod-rtspclientsink)) +$(eval $(call BuildPackage,gst1-rtsp-launch)) diff --git a/multimedia/gst1-rtsp-server/patches/001-rtsp-client-do_send_data_list-heap-messages.patch b/multimedia/gst1-rtsp-server/patches/001-rtsp-client-do_send_data_list-heap-messages.patch new file mode 100644 index 0000000000000..fdaa814f66549 --- /dev/null +++ b/multimedia/gst1-rtsp-server/patches/001-rtsp-client-do_send_data_list-heap-messages.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sat, 17 Oct 2026 03:10:00 +0100 +Subject: [PATCH] rtsp-client: allocate the data list messages on the heap + +do_send_data_list() allocates one GstRTSPMessage per buffer of the list +on the stack. The list holds all RTP packets of a video frame, which are +several hundred for a 4K frame, and the send thread then goes through +gst_rtsp_watch_send_messages() and gst_rtsp_watch_write_serialized_messages() +which allocate their arrays on the stack as well. On systems whose +default thread stack is small, such as musl with 128 KiB, a large frame +overflows the stack and the server crashes. Use the heap. + +Link: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/work_items/5358 +Assisted-by: LLM +Signed-off-by: Daniel Golle +--- +--- a/gst/rtsp-server/rtsp-client.c ++++ b/gst/rtsp-server/rtsp-client.c +@@ -1289,8 +1289,7 @@ do_send_data_list (GstBufferList * buffe + return FALSE; + } + +- messages = g_newa (GstRTSPMessage, n); +- memset (messages, 0, sizeof (GstRTSPMessage) * n); ++ messages = g_new0 (GstRTSPMessage, n); + for (i = 0; i < n; i++) { + GstBuffer *buffer = gst_buffer_list_get (buffer_list, i); + gst_rtsp_message_init_data (&messages[i], channel); +@@ -1312,6 +1311,7 @@ do_send_data_list (GstBufferList * buffe + for (i = 0; i < n; i++) { + gst_rtsp_message_unset (&messages[i]); + } ++ g_free (messages); + + if (!ret) { + GSource *idle_src;