import React, { useState, FC, useEffect } from 'react' import VideoContainer from '../components/VideoContainer' import { Icon, Popup, Button } from 'UI' import cn from 'classnames' import Counter from 'App/components/shared/SessionItem/Counter' import stl from './chatWindow.css' import ChatControls from '../ChatControls/ChatControls' import Draggable from 'react-draggable'; import type { LocalStream } from 'Player/MessageDistributor/managers/LocalStream'; export interface Props { remoteStream: MediaStream | null, localStream: LocalStream | null, userId: String, endCall: () => void } const ChatWindow: FC = function ChatWindow({ userId, remoteStream, localStream, endCall }) { const [localVideoEnabled, setLocalVideoEnabled] = useState(false) const [remoteVideoEnabled, setRemoteVideoEnabled] = useState(false) useEffect(() => { if (!remoteStream) { return } const iid = setInterval(() => { const settings = remoteStream.getVideoTracks()[0]?.getSettings() const isDummyVideoTrack = !!settings ? (settings.width === 2 || settings.frameRate === 0) : true console.log(isDummyVideoTrack, settings) const shouldBeEnabled = !isDummyVideoTrack if (shouldBeEnabled !== localVideoEnabled) { setRemoteVideoEnabled(shouldBeEnabled) } }, 1000) return () => clearInterval(iid) }, [ remoteStream, localVideoEnabled ]) const minimize = !localVideoEnabled && !remoteVideoEnabled return (
Meeting {userId}
) } export default ChatWindow