Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

Commit 8738b5d

Browse files
committed
Fix camera track
1 parent b8c037f commit 8738b5d

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

assets/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/src/features/devices/LocalPeerMediaContext.tsx

+10-11
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import {
55
VIDEO_TRACK_CONSTRAINTS
66
} from "../../pages/room/consts";
77
import { PeerMetadata, TrackMetadata, useCamera, useClient, useMicrophone, useSetupMedia } from "../../jellyfish.types";
8-
import { ClientEvents, UseCameraResult } from "@jellyfish-dev/react-client-sdk";
8+
import { ClientEvents, UseCameraResult, SimulcastConfig } from "@jellyfish-dev/react-client-sdk";
99
import { BlurProcessor } from "./BlurProcessor";
1010
import { selectBandwidthLimit } from "../../pages/room/bandwidth.tsx";
1111
import { useDeveloperInfo } from "../../contexts/DeveloperInfoContext.tsx";
1212
import EmptyVideoWorker from "./emptyVideoWorker.ts?worker";
13-
import { SimulcastConfig } from "@jellyfish-dev/ts-client-sdk";
1413

1514
export type LocalPeerContext = {
1615
video: UseCameraResult<TrackMetadata>;
@@ -74,10 +73,6 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
7473
const { simulcast } = useDeveloperInfo();
7574
const simulcastEnabled = simulcast.status;
7675

77-
useEffect(() => {
78-
console.log({ simulcastEnabled });
79-
}, []);
80-
8176
const blurRef = useRef<boolean>(false);
8277

8378
const [stream, setStream] = useState<MediaStream | null>(null);
@@ -128,9 +123,13 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
128123
}
129124

130125
if (client.status === "joined") {
131-
if (!remoteTrackIdRef.current && streamRef.current && trackRef.current) {
126+
const lastCameraTrack = Object.values(client?.local?.tracks || {})
127+
.some((track) => track?.metadata?.type === "camera");
128+
129+
const newTrack = trackRef.current;
130+
if (!lastCameraTrack && streamRef.current && newTrack) {
132131
const mediaStream = new MediaStream();
133-
mediaStream.addTrack(trackRef.current);
132+
mediaStream.addTrack(newTrack);
134133

135134
broadcastedStreamRef.current = mediaStream;
136135

@@ -140,7 +139,7 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
140139
: undefined;
141140

142141
remoteTrackIdRef.current = await client.addTrack(
143-
trackRef.current,
142+
newTrack,
144143
mediaStream,
145144
{ active: metadataActive, type: "camera" },
146145
simulcastConfig,
@@ -331,7 +330,7 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
331330
const microphone = useMicrophone();
332331

333332
const setDevice = useCallback(async (cameraId: string | null, microphoneId: string | null, blur: boolean) => {
334-
if (microphoneId) {
333+
if (microphoneId && microphoneIntentionRef.current) {
335334
microphone.start(microphoneId);
336335
}
337336

@@ -347,7 +346,7 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
347346
}
348347
}
349348

350-
if (cameraId) {
349+
if (cameraId && cameraIntentionRef.current) {
351350
video.start(cameraId);
352351
}
353352
}, [video]);

assets/vite.config.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineConfig } from "vite";
22
import react from "@vitejs/plugin-react";
3+
import checker from "vite-plugin-checker";
34

45
// https://vitejs.dev/config/
56
export default defineConfig({
@@ -24,11 +25,11 @@ export default defineConfig({
2425
},
2526
plugins: [
2627
react(),
27-
// checker({
28-
// typescript: true,
29-
// eslint: {
30-
// lintCommand: "eslint --ext .ts,.tsx",
31-
// },
32-
// }),
28+
checker({
29+
typescript: true,
30+
eslint: {
31+
lintCommand: "eslint --ext .ts,.tsx",
32+
},
33+
}),
3334
],
3435
});

0 commit comments

Comments
 (0)