@@ -5,14 +5,14 @@ import {
5
5
VIDEO_TRACK_CONSTRAINTS
6
6
} from "../../pages/room/consts" ;
7
7
import { PeerMetadata , TrackMetadata , useCamera , useClient , useMicrophone , useSetupMedia } from "../../fishjam" ;
8
- import { ClientEvents , UseCameraResult , SimulcastConfig } from "@fishjam-dev/react-client" ;
8
+ import { ClientEvents , CameraAPI , SimulcastConfig } from "@fishjam-dev/react-client" ;
9
9
import { BlurProcessor } from "./BlurProcessor" ;
10
10
import { selectBandwidthLimit } from "../../pages/room/bandwidth.tsx" ;
11
11
import { useDeveloperInfo } from "../../contexts/DeveloperInfoContext.tsx" ;
12
12
import { useUser } from "../../contexts/UserContext.tsx" ;
13
13
14
14
export type LocalPeerContext = {
15
- video : UseCameraResult < TrackMetadata > ;
15
+ video : CameraAPI < TrackMetadata > ;
16
16
init : ( ) => void ;
17
17
blur : boolean ;
18
18
setBlur : ( status : boolean , restart : boolean ) => void ;
@@ -67,6 +67,7 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
67
67
} ) ;
68
68
69
69
const video = useCamera ( ) ;
70
+ const microphone = useMicrophone ( ) ;
70
71
71
72
const [ blur , setBlur ] = useState ( false ) ;
72
73
const processor = useRef < BlurProcessor | null > ( null ) ;
@@ -127,6 +128,9 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
127
128
. some ( ( track ) => track ?. metadata ?. type === "camera" ) ;
128
129
129
130
const newTrack = trackRef . current ;
131
+
132
+ const newMetadata = { active : metadataActive , type : "camera" , displayName } as const ;
133
+
130
134
if ( ! lastCameraTrack && streamRef . current && newTrack ) {
131
135
const mediaStream = new MediaStream ( ) ;
132
136
mediaStream . addTrack ( newTrack ) ;
@@ -140,8 +144,7 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
140
144
141
145
remoteTrackIdRef . current = await client . addTrack (
142
146
newTrack ,
143
- mediaStream ,
144
- { active : metadataActive , type : "camera" , displayName } ,
147
+ newMetadata ,
145
148
simulcastConfig ,
146
149
selectBandwidthLimit ( "camera" , simulcastEnabled )
147
150
) ;
@@ -152,7 +155,6 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
152
155
// todo
153
156
// When you replaceTrack, this does not affect the stream, so the local peer doesn't know that something has changed.
154
157
// add localTrackReplaced event
155
- const newMetadata : TrackMetadata = { active : metadataActive , type : "camera" , displayName } ;
156
158
await client . replaceTrack ( remoteTrackIdRef . current , trackRef . current , newMetadata ) ;
157
159
} else if ( remoteTrackIdRef . current && ! stream ) {
158
160
await client . removeTrack ( remoteTrackIdRef . current ) ;
@@ -263,7 +265,6 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
263
265
client . removeListener ( "devicesReady" , devicesReady ) ;
264
266
client . removeListener ( "deviceStopped" , deviceStopped ) ;
265
267
client . removeListener ( "disconnected" , disconnected ) ;
266
-
267
268
} ;
268
269
} , [ simulcast . status ] ) ;
269
270
@@ -276,12 +277,15 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
276
277
277
278
const noop : ( ) => Promise < any > = useCallback ( ( ..._args ) => Promise . resolve ( ) , [ ] ) ;
278
279
279
- const newVideo : UseCameraResult < TrackMetadata > = useMemo ( ( ) => ( {
280
+ const newVideo : CameraAPI < TrackMetadata > = useMemo ( ( ) => ( {
280
281
stream : stream || null ,
281
282
track : track || null ,
282
283
addTrack : noop ,
283
284
removeTrack : noop ,
284
285
replaceTrack : noop ,
286
+ updateTrackMetadata : noop ,
287
+ muteTrack : noop ,
288
+ unmuteTrack : noop ,
285
289
broadcast : video . broadcast ,
286
290
deviceInfo : video . deviceInfo ,
287
291
devices : video . devices ,
@@ -295,8 +299,6 @@ export const LocalPeerMediaProvider = ({ children }: Props) => {
295
299
mediaStatus : video . mediaStatus
296
300
} ) , [ stream , track ] ) ;
297
301
298
- const microphone = useMicrophone ( ) ;
299
-
300
302
const setDevice = useCallback ( async ( cameraId : string | null , microphoneId : string | null , blur : boolean ) => {
301
303
if ( microphoneId && microphoneIntentionRef . current ) {
302
304
microphone . start ( microphoneId ) ;
0 commit comments