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,