@@ -81,6 +81,7 @@ async def _print_debug_stats(self):
8181 )
8282
8383 # Try to get WebRTC stats if peer connection is available
84+
8485 if self .peer_connection :
8586 try :
8687 logger .debug ("🔍 Attempting to get WebRTC stats..." )
@@ -97,21 +98,21 @@ async def _print_debug_stats(self):
9798
9899 for stat in stats .values ():
99100 if hasattr (stat , "type" ):
100- if stat .type == "outbound-rtp" and hasattr (stat , "mediaType" ) and stat .mediaType == "audio" :
101+ # Audio outbound RTP stats
102+ if stat .type == "outbound-rtp" and hasattr (stat , "kind" ) and stat .kind == "audio" :
101103 found_audio_stats = True
102104 logger .info (
103105 f"📡 WebRTC Audio Out - Packets sent: { getattr (stat , 'packetsSent' , 'N/A' )} , "
104- f"Bytes sent: { getattr (stat , 'bytesSent' , 'N/A' )} , "
105- f"Packets lost: { getattr (stat , 'packetsLost' , 'N/A' )} "
106+ f"Bytes sent: { getattr (stat , 'bytesSent' , 'N/A' )} "
106107 )
107- elif stat .type == "candidate-pair" and hasattr (stat , "state" ) and stat .state == "succeeded" :
108+ # Network stats from remote inbound RTP (has RTT and jitter)
109+ elif stat .type == "remote-inbound-rtp" :
108110 found_network_stats = True
109- rtt = getattr (stat , "currentRoundTripTime" , None )
111+ rtt = getattr (stat , "roundTripTime" , None )
112+ jitter = getattr (stat , "jitter" , None )
113+ packets_lost = getattr (stat , "packetsLost" , None )
110114 if rtt is not None :
111- logger .info (
112- f"🌐 Network - RTT: { rtt * 1000 :.1f} ms, "
113- f"Available outgoing bitrate: { getattr (stat , 'availableOutgoingBitrate' , 'N/A' )} "
114- )
115+ logger .info (f"🌐 Network - RTT: { rtt * 1000 :.1f} ms, " f"Jitter: { jitter } , Packets lost: { packets_lost } " )
115116
116117 if not found_audio_stats :
117118 logger .debug ("⚠️ No outbound audio RTP stats found" )
0 commit comments