Aligned with ai-voicebot
This commit is contained in:
parent
b3386bab1d
commit
5acf71b2a3
@ -9,6 +9,7 @@ import Videocam from "@mui/icons-material/Videocam";
|
|||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import useWebSocket, { ReadyState } from "react-use-websocket";
|
import useWebSocket, { ReadyState } from "react-use-websocket";
|
||||||
|
import { Session } from "./GlobalContext";
|
||||||
import WebRTCStatus from "./WebRTCStatus";
|
import WebRTCStatus from "./WebRTCStatus";
|
||||||
import Moveable from "react-moveable";
|
import Moveable from "react-moveable";
|
||||||
import { flushSync } from "react-dom";
|
import { flushSync } from "react-dom";
|
||||||
@ -17,15 +18,6 @@ const debug = true;
|
|||||||
// When true, do not send host candidates to the signaling server. Keeps TURN relays preferred.
|
// When true, do not send host candidates to the signaling server. Keeps TURN relays preferred.
|
||||||
const FILTER_HOST_CANDIDATES = false; // Temporarily disabled to test direct connections
|
const FILTER_HOST_CANDIDATES = false; // Temporarily disabled to test direct connections
|
||||||
|
|
||||||
export type Session = {
|
|
||||||
session_id: string;
|
|
||||||
peer_name: string;
|
|
||||||
has_media?: boolean; // Whether this user provides audio/video streams
|
|
||||||
attributes?: Record<string, any>;
|
|
||||||
name: string;
|
|
||||||
id: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ---------- Synthetic Tracks Helpers ---------- */
|
/* ---------- Synthetic Tracks Helpers ---------- */
|
||||||
|
|
||||||
// Helper to hash a string to a color
|
// Helper to hash a string to a color
|
||||||
@ -1130,13 +1122,12 @@ const MediaAgent = (props: MediaAgentProps) => {
|
|||||||
|
|
||||||
// Join lobby when media is ready
|
// Join lobby when media is ready
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!session) return;
|
|
||||||
if (media && joinStatus.status === "Not joined" && readyState === ReadyState.OPEN) {
|
if (media && joinStatus.status === "Not joined" && readyState === ReadyState.OPEN) {
|
||||||
console.log(`media-agent - Initiating media join for ${session.name}`);
|
console.log(`media-agent - Initiating media join for ${session.name}`);
|
||||||
setJoinStatus({ status: "Joining" });
|
setJoinStatus({ status: "Joining" });
|
||||||
sendJsonMessage({ type: "join", data: {} });
|
sendJsonMessage({ type: "join", data: {} });
|
||||||
}
|
}
|
||||||
}, [media, joinStatus.status, sendJsonMessage, readyState, session]);
|
}, [media, joinStatus.status, sendJsonMessage, readyState, session.name]);
|
||||||
|
|
||||||
// Update local peer in peers list
|
// Update local peer in peers list
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -1190,7 +1181,6 @@ const MediaAgent = (props: MediaAgentProps) => {
|
|||||||
console.log(`media-agent - Requesting access to local audio/video`);
|
console.log(`media-agent - Requesting access to local audio/video`);
|
||||||
const attempt = { get_audio: true, get_video: true };
|
const attempt = { get_audio: true, get_video: true };
|
||||||
let media = null;
|
let media = null;
|
||||||
if (!session) { return new MediaStream(); }
|
|
||||||
|
|
||||||
// Try to get user media with fallback
|
// Try to get user media with fallback
|
||||||
while (attempt.get_audio || attempt.get_video) {
|
while (attempt.get_audio || attempt.get_video) {
|
||||||
@ -1271,7 +1261,7 @@ const MediaAgent = (props: MediaAgentProps) => {
|
|||||||
hasRealVideo,
|
hasRealVideo,
|
||||||
});
|
});
|
||||||
return finalMedia;
|
return finalMedia;
|
||||||
}, [session]);
|
}, [session.name]);
|
||||||
|
|
||||||
// Initialize media once
|
// Initialize media once
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user