Future<AudioSenderStats?>
getSenderStats()
Implementation
Future<AudioSenderStats?> getSenderStats() async {
if (sender == null) {
return null;
}
final stats = await sender!.getStats();
AudioSenderStats? senderStats;
for (var v in stats) {
if (v.type == 'outbound-rtp') {
senderStats ??= AudioSenderStats(v.id, v.timestamp);
senderStats.packetsSent = getNumValFromReport(v.values, 'packetsSent');
senderStats.packetsLost = getNumValFromReport(v.values, 'packetsLost');
senderStats.bytesSent = getNumValFromReport(v.values, 'bytesSent');
senderStats.roundTripTime =
getNumValFromReport(v.values, 'roundTripTime');
senderStats.jitter = getNumValFromReport(v.values, 'jitter');
final c = stats.firstWhereOrNull((element) => element.type == 'codec');
if (c != null) {
senderStats.mimeType = getStringValFromReport(c.values, 'mimeType');
senderStats.payloadType =
getNumValFromReport(c.values, 'payloadType');
senderStats.channels = getNumValFromReport(c.values, 'channels');
senderStats.clockRate = getNumValFromReport(c.values, 'clockRate');
}
break;
}
}
return senderStats;
}