Время звонка начинается тогда, когда начинается аудио-дорожка, а не тогда, когда установлено соединение с SFU

This commit is contained in:
RoyceDa
2026-04-01 16:28:41 +02:00
parent 7e8d086a74
commit 92c9dc03c9

View File

@@ -84,6 +84,7 @@ export function CallProvider(props : CallProviderProps) {
const mutedRef = useRef<boolean>(false);
const soundRef = useRef<boolean>(true);
const {sendMessage} = useDeattachedSender();
const hasRemoteTrackRef = useRef<boolean>(false);
const {playSound, stopSound, stopLoopSound} = useSound();
const {setWindowPriority} = useWindow();
@@ -350,10 +351,7 @@ export function CallProvider(props : CallProviderProps) {
* WebRTC соединение установлено, звонок активен, останавливаем все остальные звуки
* системы
*/
stopLoopSound();
stopSound();
setCallState(CallState.ACTIVE);
tryActivateCall();
info("WebRTC connection established, call is active");
}
}
@@ -368,7 +366,8 @@ export function CallProvider(props : CallProviderProps) {
* При получении медиа-трека с другой стороны
*/
if(remoteAudioRef.current && event.streams[0]){
console.info(event.streams);
hasRemoteTrackRef.current = true;
tryActivateCall();
remoteAudioRef.current.srcObject = event.streams[0];
remoteAudioRef.current.muted = !soundRef.current;
void remoteAudioRef.current.play().catch((e) => {
@@ -405,6 +404,15 @@ export function CallProvider(props : CallProviderProps) {
}
}, [activeCall, sessionKeys, duration]);
const tryActivateCall = () => {
if(hasRemoteTrackRef.current && peerConnectionRef.current?.connectionState == "connected"){
stopLoopSound();
stopSound();
setCallState(CallState.ACTIVE);
info("Call is now active");
}
}
const openCallsModal = (text : string) => {
modals.open({
centered: true,