monitorStats method
void
monitorStats(
- WebRTCVideoStats stats, {
- required WebRTCAudioStats audioStats,
- required dynamic onLevelChanged(),
- required String id,
- required bool isMe,
Implementation
void monitorStats(
WebRTCVideoStats stats, {
required WebRTCAudioStats audioStats,
required Function(AudioLevel) onLevelChanged,
required String id,
required bool isMe,
}) {
onIceConnectionState = (state) async {
switch (state) {
case RTCIceConnectionState.RTCIceConnectionStateConnected:
if (isMe) {
final senders = await getSenders();
stats.addSenders(id, senders);
audioStats.setSender = AudioStatsParams(
peerConnection: this,
callBack: onLevelChanged,
);
} else {
final receivers = await getReceivers();
stats.addReceivers(id, receivers);
audioStats.addReceiver(
AudioStatsParams(
peerConnection: this,
callBack: onLevelChanged,
receivers: receivers,
),
);
}
break;
case RTCIceConnectionState.RTCIceConnectionStateClosed:
if (isMe) {
stats.removeSenders();
audioStats.setSender = null;
} else {
stats.removeReceivers(id);
audioStats.removeReceiver(peerConnectionId);
}
break;
default:
break;
}
};
}