Browse Source

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.
Richard Stanway 3 years ago
parent
commit
bf00ef1ea3
1 changed files with 30 additions and 10 deletions
  1. 30 10
      plugins/obs-outputs/rtmp-stream.c

+ 30 - 10
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);
 		}