From b4bef7fd353aabf0f8f20d492d8dd4d0868a0c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 24 Dec 2024 18:24:08 +0100 Subject: [PATCH] tcpclientsrc, tcpserversrc: fix tcp stats gathering Fix-up after commit e56b78417. Unclear how that could ever have worked. Code only built because basically everything was disabled due to the missing config.h include. - Include config.h so that HAVE_* defines are available. - Fix missing variable declarations that somehow disappeared when moving the stats gathering code block into a separate function in a new file. - Fix structure variable modified to match name in new function. Part-of: --- .../gst-plugins-base/gst/tcp/gsttcpsrcstats.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-base/gst/tcp/gsttcpsrcstats.c b/subprojects/gst-plugins-base/gst/tcp/gsttcpsrcstats.c index d942cdcb47..2a15c482fd 100644 --- a/subprojects/gst-plugins-base/gst/tcp/gsttcpsrcstats.c +++ b/subprojects/gst-plugins-base/gst/tcp/gsttcpsrcstats.c @@ -1,3 +1,7 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + /* macOS and iOS have the .h files but the tcp_info struct is private API */ #if defined(HAVE_NETINET_TCP_H) && defined(HAVE_NETINET_IN_H) && defined(HAVE_SYS_SOCKET_H) #include @@ -14,10 +18,14 @@ void gst_tcp_stats_from_socket (GstStructure * structure, GSocket * socket) { #ifdef HAVE_SOCKET_METRIC_HEADERS + struct tcp_info info = { 0, }; + socklen_t info_len = sizeof (info); + int fd = g_socket_get_fd (socket); + if (getsockopt (fd, IPPROTO_TCP, TCP_INFO, &info, &info_len) == 0) { /* this is system-specific */ #ifdef HAVE_BSD_TCP_INFO - gst_structure_set (s, + gst_structure_set (structure, "reordering", G_TYPE_UINT, info.__tcpi_reordering, "unacked", G_TYPE_UINT, info.__tcpi_unacked, "sacked", G_TYPE_UINT, info.__tcpi_sacked, @@ -25,7 +33,7 @@ gst_tcp_stats_from_socket (GstStructure * structure, GSocket * socket) "retrans", G_TYPE_UINT, info.__tcpi_retrans, "fackets", G_TYPE_UINT, info.__tcpi_fackets, NULL); #elif defined(HAVE_LINUX_TCP_INFO) - gst_structure_set (s, + gst_structure_set (structure, "reordering", G_TYPE_UINT, info.tcpi_reordering, "unacked", G_TYPE_UINT, info.tcpi_unacked, "sacked", G_TYPE_UINT, info.tcpi_sacked,