Финальная часть после тестов скорости шифрования кадров (frames)
This commit is contained in:
@@ -74,8 +74,7 @@ export function CallProvider(props : CallProviderProps) {
|
||||
const roomIdRef = useRef<string>("");
|
||||
|
||||
const roleRef = useRef<CallRole | null>(null);
|
||||
//const [sharedSecret, setSharedSecret] = useState<string>("");
|
||||
const sharedSecretRef = useRef<string>("");
|
||||
const sharedSecretRef = useRef<string>("");
|
||||
const iceServersRef = useRef<RTCIceServer[]>([]);
|
||||
const remoteAudioRef = useRef<HTMLAudioElement | null>(null);
|
||||
const iceCandidatesBufferRef = useRef<RTCIceCandidate[]>([]);
|
||||
@@ -98,67 +97,6 @@ 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 серверы для установки соединения из разных сетей
|
||||
|
||||
@@ -22,12 +22,9 @@ function toUint8Array(input: KeyInput): Uint8Array {
|
||||
|
||||
function fillNonceFromTimestamp(nonce: Uint8Array, tsRaw: unknown): void {
|
||||
nonce.fill(0);
|
||||
|
||||
let ts = 0n;
|
||||
if (typeof tsRaw === "bigint") ts = tsRaw;
|
||||
else if (typeof tsRaw === "number" && Number.isFinite(tsRaw)) ts = BigInt(Math.floor(tsRaw));
|
||||
|
||||
// Записываем 64-bit timestamp в первые 8 байт nonce (BE)
|
||||
nonce[0] = Number((ts >> 56n) & 0xffn);
|
||||
nonce[1] = Number((ts >> 48n) & 0xffn);
|
||||
nonce[2] = Number((ts >> 40n) & 0xffn);
|
||||
|
||||
Reference in New Issue
Block a user