WASM для ускорения шифрования звонков, тест
This commit is contained in:
@@ -98,6 +98,67 @@ export function CallProvider(props : CallProviderProps) {
|
||||
}
|
||||
}, [callState]);
|
||||
|
||||
// ...existing code...
|
||||
const checkWebRTCStats = async () => {
|
||||
if (!peerConnectionRef.current) return;
|
||||
|
||||
const stats = await peerConnectionRef.current.getStats();
|
||||
|
||||
stats.forEach(report => {
|
||||
// Исходящий аудио
|
||||
if (report.type === "outbound-rtp" && report.mediaType === "audio") {
|
||||
console.info("[WebRTC OUT]", {
|
||||
bytesSent: report.bytesSent,
|
||||
packetsSent: report.packetsSent,
|
||||
timestamp: report.timestamp
|
||||
});
|
||||
}
|
||||
|
||||
// Входящий аудио
|
||||
if (report.type === "inbound-rtp" && report.mediaType === "audio") {
|
||||
console.info("[WebRTC IN]", {
|
||||
bytesReceived: report.bytesReceived,
|
||||
packetsReceived: report.packetsReceived,
|
||||
jitter: report.jitter,
|
||||
packetsLost: report.packetsLost,
|
||||
timestamp: report.timestamp
|
||||
});
|
||||
}
|
||||
|
||||
// RTT и задержка
|
||||
if (report.type === "candidate-pair" && report.state === "succeeded") {
|
||||
console.info("[WebRTC RTT]", {
|
||||
currentRoundTripTime: (report.currentRoundTripTime * 1000).toFixed(2) + "ms",
|
||||
availableOutgoingBitrate: (report.availableOutgoingBitrate / 1024 / 1024).toFixed(2) + " Mbps",
|
||||
availableIncomingBitrate: (report.availableIncomingBitrate / 1024 / 1024).toFixed(2) + " Mbps"
|
||||
});
|
||||
}
|
||||
|
||||
// Codec info
|
||||
if (report.type === "codec") {
|
||||
if (report.mediaType === "audio") {
|
||||
console.info("[WebRTC Codec]", {
|
||||
mimeType: report.mimeType,
|
||||
channels: report.channels,
|
||||
clockRate: report.clockRate
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Вызываем каждые 2 секунды при активном звонке
|
||||
useEffect(() => {
|
||||
if (callState !== CallState.ACTIVE) return;
|
||||
|
||||
const interval = setInterval(() => {
|
||||
void checkWebRTCStats();
|
||||
}, 2000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [callState]);
|
||||
// ...existing code...
|
||||
|
||||
useEffect(() => {
|
||||
/**
|
||||
* Нам нужно получить ICE серверы для установки соединения из разных сетей
|
||||
|
||||
Reference in New Issue
Block a user