File tree 1 file changed +19
-2
lines changed
packages/react/src/prefabs
1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type {
3
3
LocalAudioTrack ,
4
4
LocalTrack ,
5
5
LocalVideoTrack ,
6
+ VideoResolution ,
6
7
} from 'livekit-client' ;
7
8
import {
8
9
createLocalAudioTrack ,
@@ -52,6 +53,19 @@ export interface PreJoinProps
52
53
persistUserChoices ?: boolean ;
53
54
}
54
55
56
+ const makeComparableOptions = ( options : CreateLocalTracksOptions ) => {
57
+ return {
58
+ video :
59
+ typeof options . video === 'object'
60
+ ? { ...options . video , processor : options . video . processor ?. name }
61
+ : options . video ,
62
+ audio :
63
+ typeof options . audio === 'object'
64
+ ? { ...options . audio , processor : options . audio . processor ?. name }
65
+ : options . audio ,
66
+ } ;
67
+ } ;
68
+
55
69
/** @alpha */
56
70
export function usePreviewTracks (
57
71
options : CreateLocalTracksOptions ,
@@ -87,13 +101,16 @@ export function usePreviewTracks(
87
101
} ) ;
88
102
89
103
return ( ) => {
104
+ // In case this is triggered while awaiting for `createLocalTracks`,
105
+ // this makes sure, we will stop the tracks after the creation await.
106
+ // (yes needsCleanup is passed into this closure by ref and is the same ref as in the
107
+ // lock.then closure)
90
108
needsCleanup = true ;
91
109
localTracks . forEach ( ( track ) => {
92
110
track . stop ( ) ;
93
111
} ) ;
94
112
} ;
95
- } , [ JSON . stringify ( options ) , onError , trackLock ] ) ;
96
-
113
+ } , [ trackLock , makeComparableOptions ( options ) ] ) ;
97
114
return tracks ;
98
115
}
99
116
You can’t perform that action at this time.
0 commit comments