Шифрование тест
This commit is contained in:
@@ -12,7 +12,7 @@ import { modals } from "@mantine/modals";
|
||||
import { Button, Flex, Text } from "@mantine/core";
|
||||
import { useSound } from "@/app/hooks/useSound";
|
||||
import useWindow from "@/app/hooks/useWindow";
|
||||
import { enableAudioE2EE } from "./audioE2EE";
|
||||
import { attachReceiverE2EE, attachSenderE2EE } from "./audioE2EE";
|
||||
|
||||
export interface CallContextValue {
|
||||
call: (callable: string) => void;
|
||||
@@ -298,7 +298,9 @@ export function CallProvider(props : CallProviderProps) {
|
||||
* Нужно отправить свой SDP оффер другой стороне, чтобы установить WebRTC соединение
|
||||
*/
|
||||
peerConnectionRef.current = new RTCPeerConnection({
|
||||
iceServers: iceServersRef.current
|
||||
iceServers: iceServersRef.current,
|
||||
// @ts-ignore
|
||||
encodedInsertableStreams: true
|
||||
});
|
||||
/**
|
||||
* Подписываемся на ICE кандидат
|
||||
@@ -340,14 +342,18 @@ export function CallProvider(props : CallProviderProps) {
|
||||
* Запрашиваем Аудио поток с микрофона и добавляем его в PeerConnection, чтобы другая сторона могла его получить и воспроизвести,
|
||||
* когда мы установим WebRTC соединение
|
||||
*/
|
||||
const localStream = await navigator.mediaDevices.getUserMedia({
|
||||
audio: true
|
||||
});
|
||||
localStream.getTracks().forEach(track => {
|
||||
peerConnectionRef.current?.addTrack(track, localStream);
|
||||
const localStream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||
const audioTrack = localStream.getAudioTracks()[0];
|
||||
|
||||
|
||||
const tx = peerConnectionRef.current.addTransceiver(audioTrack, {
|
||||
direction: "sendrecv",
|
||||
streams: [localStream]
|
||||
});
|
||||
|
||||
await enableAudioE2EE(peerConnectionRef.current, Buffer.from(sharedSecret, 'hex'));
|
||||
await attachSenderE2EE(tx.sender, Buffer.from(sharedSecret, "hex"));
|
||||
|
||||
await attachReceiverE2EE(tx.receiver, Buffer.from(sharedSecret, "hex"));
|
||||
/**
|
||||
* Отправляем свой оффер другой стороне
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user