tcpclientsrc: Fix compilation on FreeBSD
authorVivia Nikolaidou <vivia@ahiru.eu>
Tue, 3 Mar 2020 13:19:21 +0000 (15:19 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Sun, 8 Mar 2020 10:45:57 +0000 (10:45 +0000)
The members of the tcp_info struct are prefixed with a double
underscore, as reported in
https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/584#note_423487

gst/tcp/gsttcpclientsrc.c
meson.build

index b236e1a..b007650 100644 (file)
@@ -585,6 +585,16 @@ gst_tcp_client_src_get_stats (GstTCPClientSrc * src)
     fd = g_socket_get_fd (src->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,
+          "reordering", G_TYPE_UINT, info.__tcpi_reordering,
+          "unacked", G_TYPE_UINT, info.__tcpi_unacked,
+          "sacked", G_TYPE_UINT, info.__tcpi_sacked,
+          "lost", G_TYPE_UINT, info.__tcpi_lost,
+          "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,
           "reordering", G_TYPE_UINT, info.tcpi_reordering,
           "unacked", G_TYPE_UINT, info.tcpi_unacked,
@@ -592,6 +602,7 @@ gst_tcp_client_src_get_stats (GstTCPClientSrc * src)
           "lost", G_TYPE_UINT, info.tcpi_lost,
           "retrans", G_TYPE_UINT, info.tcpi_retrans,
           "fackets", G_TYPE_UINT, info.tcpi_fackets, NULL);
+#endif
     }
   }
 #endif
index 967fdab..92958ed 100644 (file)
@@ -375,6 +375,14 @@ else
     endif
 endif
 
+if cc.has_member('struct tcp_info', '__tcpi_reordering', prefix: '#include <netinet/tcp.h>')
+  core_conf.set('HAVE_BSD_TCP_INFO', true)
+endif
+
+if cc.has_member('struct tcp_info', 'tcpi_reordering', prefix: '#include <netinet/tcp.h>')
+  core_conf.set('HAVE_LINUX_TCP_INFO', true)
+endif
+
 gir = find_program('g-ir-scanner', required : get_option('introspection'))
 gnome = import('gnome')
 build_gir = gir.found() and (not meson.is_cross_build() or get_option('introspection').enabled())