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