import React, { useState, useEffect, useRef, useCallback, useContext } from "react"; import Moveable from "react-moveable"; import "./MediaControl.css"; import VolumeOff from "@mui/icons-material/VolumeOff"; import VolumeUp from "@mui/icons-material/VolumeUp"; import MicOff from "@mui/icons-material/MicOff"; import Mic from "@mui/icons-material/Mic"; import VideocamOff from "@mui/icons-material/VideocamOff"; import Videocam from "@mui/icons-material/Videocam"; import { GlobalContext } from "./GlobalContext"; import Box from "@mui/material/Box"; const debug = true; // Types for peer and track context interface Peer { sessionId: string; peerName: string; hasAudio: boolean; hasVideo: boolean; attributes: Record; muted: boolean; videoOn: boolean; local: boolean; dead: boolean; connection?: RTCPeerConnection; } interface TrackContext { media: MediaStream; audio: boolean; video: boolean; } interface AddPeerConfig { peer_id: string; peer_name: string; hasAudio: boolean; hasVideo: boolean; should_create_offer?: boolean; } interface SessionDescriptionData { peer_id: string; session_description: RTCSessionDescriptionInit; } interface IceCandidateData { peer_id: string; candidate: RTCIceCandidateInit; } interface RemovePeerData { peer_id: string; } interface VideoProps extends React.VideoHTMLAttributes { srcObject: MediaProvider; local?: boolean; } const Video: React.FC = ({ srcObject, local, ...props }) => { const refVideo = useRef(null); useEffect(() => { if (!refVideo.current) { return; } const ref = refVideo.current; if (debug) console.log("media-control - video