From bf00ef1ea3c7103b53e6296ed2429cb95e80bbd4 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Thu, 29 Dec 2022 02:20:06 +0100 Subject: [PATCH] obs-outputs: Improvements to Windows interface logging Now uses GetIfEntry2 which supports 64-bit values for reporting speed, so 10+ gbps adapters are now reported correctly in the log. Also added an additional log line if the interface error counters are non-zero to possibly help identify physical faults. Finally the transmit and receive speeds are logged independently so that asynchronous mediums such as Wi-Fi that might have good RX but poor TX can be better diagnosed. --- plugins/obs-outputs/rtmp-stream.c | 40 +++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/plugins/obs-outputs/rtmp-stream.c b/plugins/obs-outputs/rtmp-stream.c index 8b1908f56..0d82c8c8a 100644 --- a/plugins/obs-outputs/rtmp-stream.c +++ b/plugins/obs-outputs/rtmp-stream.c @@ -1007,26 +1007,46 @@ static void win32_log_interface_type(struct rtmp_stream *stream) return; if (!GetBestRoute(dest_addr, source_addr, &route)) { - MIB_IFROW row; + MIB_IF_ROW2 row; memset(&row, 0, sizeof(row)); - row.dwIndex = route.dwForwardIfIndex; + row.InterfaceIndex = route.dwForwardIfIndex; - if (!GetIfEntry(&row)) { - uint32_t speed = row.dwSpeed / 1000000; + if (!GetIfEntry2(&row)) { + uint32_t rxSpeed = row.ReceiveLinkSpeed / 1000000; + uint32_t txSpeed = row.TransmitLinkSpeed / 1000000; char *type; struct dstr other = {0}; - if (row.dwType == IF_TYPE_ETHERNET_CSMACD) { + switch (row.PhysicalMediumType) { + case NdisPhysicalMedium802_3: type = "ethernet"; - } else if (row.dwType == IF_TYPE_IEEE80211) { + break; + case NdisPhysicalMediumWirelessLan: + case NdisPhysicalMediumNative802_11: type = "802.11"; - } else { - dstr_printf(&other, "type %lu", row.dwType); + break; + default: + dstr_printf(&other, "type %d", + (int)row.PhysicalMediumType); type = other.array; + break; } - info("Interface: %s (%s, %lu mbps)", row.bDescr, type, - speed); + char *desc; + os_wcs_to_utf8_ptr(row.Description, 0, &desc); + + info("Interface: %s (%s, %lu↓/%lu↑ mbps)", desc, type, + rxSpeed, txSpeed); + + bfree(desc); + + if (row.InErrors || row.OutErrors) { + warn("Interface has non-zero error counters (%" PRIu64 + "/%" PRIu64 " errors, %" PRIu64 "/%" PRIu64 + " discards)", + row.InErrors, row.OutErrors, + row.InDiscards, row.OutDiscards); + } dstr_free(&other); }