agora-appbuilder-core 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/package.json +3 -2
  2. package/template/_package-lock.json +22850 -0
  3. package/template/agora-rn-uikit/.git/HEAD +1 -1
  4. package/template/agora-rn-uikit/.git/index +0 -0
  5. package/template/agora-rn-uikit/.git/logs/HEAD +2 -3
  6. package/template/agora-rn-uikit/.git/logs/refs/heads/ab-dev-auto +1 -1
  7. package/template/agora-rn-uikit/.git/logs/refs/heads/master +1 -1
  8. package/template/agora-rn-uikit/.git/logs/refs/remotes/origin/HEAD +1 -1
  9. package/template/agora-rn-uikit/.git/objects/pack/pack-f379286d0537eb68377220b4929979324b8d5d1c.idx +0 -0
  10. package/template/agora-rn-uikit/.git/objects/pack/{pack-19a65e0782e617d79275088a06e668496d6e2d73.pack → pack-f379286d0537eb68377220b4929979324b8d5d1c.pack} +0 -0
  11. package/template/agora-rn-uikit/.git/packed-refs +3 -2
  12. package/template/agora-rn-uikit/.git/refs/heads/ab-dev-auto +1 -1
  13. package/template/agora-rn-uikit/package.json +1 -0
  14. package/template/agora-rn-uikit/src/AgoraUIKit.tsx +8 -8
  15. package/template/agora-rn-uikit/src/{LocalUserContext.tsx → Contexts/LocalUserContext.tsx} +1 -1
  16. package/template/agora-rn-uikit/src/{MaxUidContext.tsx → Contexts/MaxUidContext.tsx} +0 -0
  17. package/template/agora-rn-uikit/src/{MinUidContext.tsx → Contexts/MinUidContext.tsx} +0 -0
  18. package/template/agora-rn-uikit/src/{PropsContext.tsx → Contexts/PropsContext.tsx} +34 -16
  19. package/template/agora-rn-uikit/src/{RtcContext.tsx → Contexts/RtcContext.tsx} +12 -21
  20. package/template/agora-rn-uikit/src/Controls/BtnTemplate.tsx +25 -15
  21. package/template/agora-rn-uikit/src/Controls/Icons.ts +53 -3
  22. package/template/agora-rn-uikit/src/Controls/ImageIcon.tsx +53 -0
  23. package/template/agora-rn-uikit/src/Controls/Local/EndCall.tsx +4 -3
  24. package/template/agora-rn-uikit/src/Controls/Local/FullScreen.tsx +3 -3
  25. package/template/agora-rn-uikit/src/Controls/Local/LocalAudioMute.tsx +58 -14
  26. package/template/agora-rn-uikit/src/Controls/Local/LocalVideoMute.tsx +60 -14
  27. package/template/agora-rn-uikit/src/Controls/Local/Recording.tsx +2 -2
  28. package/template/agora-rn-uikit/src/Controls/Local/Screenshare.tsx +2 -2
  29. package/template/agora-rn-uikit/src/Controls/Local/SwitchCamera.tsx +9 -9
  30. package/template/agora-rn-uikit/src/Controls/LocalControls.tsx +20 -17
  31. package/template/agora-rn-uikit/src/Controls/Remote/RemoteAudioMute.tsx +8 -8
  32. package/template/agora-rn-uikit/src/Controls/Remote/RemoteSwap.tsx +3 -3
  33. package/template/agora-rn-uikit/src/Controls/Remote/RemoteVideoMute.tsx +13 -8
  34. package/template/agora-rn-uikit/src/Controls/RemoteControls.tsx +1 -2
  35. package/template/agora-rn-uikit/src/Reducer/LocalMuteAudio.ts +20 -0
  36. package/template/agora-rn-uikit/src/Reducer/LocalMuteVideo.ts +20 -0
  37. package/template/agora-rn-uikit/src/Reducer/RemoteAudioStateChanged.ts +26 -0
  38. package/template/agora-rn-uikit/src/Reducer/RemoteVideoStateChanged.ts +26 -0
  39. package/template/agora-rn-uikit/src/Reducer/UpdateDualStreamMode.ts +46 -0
  40. package/template/agora-rn-uikit/src/Reducer/UserJoined.ts +47 -0
  41. package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteAudio.ts +20 -0
  42. package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteVideo.ts +20 -0
  43. package/template/agora-rn-uikit/src/Reducer/UserOffline.ts +21 -0
  44. package/template/agora-rn-uikit/src/Reducer/index.ts +9 -0
  45. package/template/agora-rn-uikit/src/Rtc/Create.tsx +138 -0
  46. package/template/agora-rn-uikit/src/Rtc/Join.tsx +100 -0
  47. package/template/agora-rn-uikit/src/RtcConfigure.tsx +197 -0
  48. package/template/agora-rn-uikit/src/Style.ts +3 -3
  49. package/template/agora-rn-uikit/src/Utils/actionTypeGuard.tsx +9 -0
  50. package/template/agora-rn-uikit/src/{events.ts → Utils/events.ts} +0 -0
  51. package/template/agora-rn-uikit/src/{permission.ts → Utils/permission.ts} +0 -0
  52. package/template/agora-rn-uikit/src/{quality.tsx → Utils/quality.tsx} +0 -0
  53. package/template/agora-rn-uikit/src/{MaxVideoView.native.tsx → Views/MaxVideoView.native.tsx} +3 -4
  54. package/template/agora-rn-uikit/src/{MaxVideoView.tsx → Views/MaxVideoView.tsx} +3 -4
  55. package/template/agora-rn-uikit/src/Views/MinVideoView.tsx +86 -0
  56. package/template/agora-rn-uikit/src/index.ts +67 -0
  57. package/template/bridge/rtc/webNg/RtcEngine.ts +23 -6
  58. package/template/package-lock.json +22850 -0
  59. package/template/package.json +6 -5
  60. package/template/src/assets/icons.ts +35 -6
  61. package/template/src/atoms/SecondaryButton.tsx +6 -5
  62. package/template/src/atoms/TextInput.tsx +6 -1
  63. package/template/src/components/Chat.tsx +50 -21
  64. package/template/src/components/ChatContext.ts +22 -1
  65. package/template/src/components/Controls.native.tsx +2 -2
  66. package/template/src/components/Controls.tsx +2 -2
  67. package/template/src/components/DeviceConfigure.tsx +1 -1
  68. package/template/src/components/GridVideo.tsx +69 -31
  69. package/template/src/components/Navbar.tsx +136 -113
  70. package/template/src/components/NetworkQualityContext.tsx +134 -0
  71. package/template/src/components/ParticipantsView.tsx +105 -49
  72. package/template/src/components/PinnedVideo.tsx +112 -71
  73. package/template/src/components/Precall.native.tsx +20 -9
  74. package/template/src/components/Precall.tsx +35 -32
  75. package/template/src/components/RTMConfigure.tsx +331 -181
  76. package/template/src/components/RTMEvents.tsx +84 -0
  77. package/template/src/components/Settings.tsx +19 -16
  78. package/template/src/components/Share.tsx +131 -62
  79. package/template/src/hooks/useImageDelay.tsx +28 -0
  80. package/template/src/pages/Create.tsx +9 -3
  81. package/template/src/pages/VideoCall.tsx +124 -98
  82. package/template/src/subComponents/ChatContainer.tsx +40 -28
  83. package/template/src/subComponents/CopyJoinInfo.tsx +9 -12
  84. package/template/src/subComponents/LocalAudioMute.tsx +9 -9
  85. package/template/src/subComponents/LocalVideoMute.tsx +9 -9
  86. package/template/src/subComponents/NetworkQualityPill.tsx +161 -0
  87. package/template/src/subComponents/Recording.tsx +12 -16
  88. package/template/src/subComponents/RemoteAudioMute.tsx +23 -27
  89. package/template/src/subComponents/RemoteEndCall.tsx +7 -15
  90. package/template/src/subComponents/RemoteVideoMute.tsx +15 -28
  91. package/template/src/subComponents/ScreenShareNotice.tsx +61 -0
  92. package/template/src/subComponents/ScreenshareButton.tsx +74 -75
  93. package/template/src/subComponents/SwitchCamera.tsx +5 -2
  94. package/template/src/subComponents/TextWithTooltip.native.tsx +128 -0
  95. package/template/src/subComponents/TextWithTooltip.tsx +44 -0
  96. package/template/src/subComponents/toastConfig.tsx +2 -2
  97. package/template/src/utils/isSafariBrowser.tsx +22 -0
  98. package/template/agora-rn-uikit/.git/objects/pack/pack-19a65e0782e617d79275088a06e668496d6e2d73.idx +0 -0
  99. package/template/agora-rn-uikit/Components.js +0 -35
  100. package/template/agora-rn-uikit/Contexts.js +0 -7
  101. package/template/agora-rn-uikit/index.js +0 -12
  102. package/template/agora-rn-uikit/src/MinVideoView.tsx +0 -87
  103. package/template/agora-rn-uikit/src/RTCConfigure.tsx +0 -520
@@ -1,520 +0,0 @@
1
- import React, {
2
- useState,
3
- useEffect,
4
- useReducer,
5
- useContext,
6
- useRef,
7
- useCallback,
8
- useDebugValue,
9
- } from 'react';
10
- import RtcEngine, {
11
- VideoEncoderConfiguration,
12
- AreaCode,
13
- } from 'react-native-agora';
14
- import {Platform} from 'react-native';
15
- import requestCameraAndAudioPermission from './permission';
16
- import {
17
- RtcProvider,
18
- UidInterface,
19
- UidStateInterface,
20
- DispatchType,
21
- ActionInterface,
22
- ActionType,
23
- } from './RtcContext';
24
- import PropsContext, {
25
- RtcPropsInterface,
26
- CallbacksInterface,
27
- DualStreamMode,
28
- } from './PropsContext';
29
- import {MinUidProvider} from './MinUidContext';
30
- import {MaxUidProvider} from './MaxUidContext';
31
- import quality from './quality';
32
-
33
- const initialState: UidStateInterface = {
34
- min: [],
35
- max: [
36
- {
37
- uid: 'local',
38
- audio: true,
39
- video: true,
40
- streamType: 'high',
41
- },
42
- ],
43
- };
44
-
45
- const RtcConfigure: React.FC<Partial<RtcPropsInterface>> = (props) => {
46
- const [ready, setReady] = useState<boolean>(false);
47
- useDebugValue(ready, (ready) => `ready to join ${String(ready)}`);
48
- let joinRes: ((arg0: boolean) => void) | null = null;
49
- let canJoin = useRef(new Promise<boolean | void>((res) => (joinRes = res)));
50
- const {callbacks, rtcProps} = useContext(PropsContext);
51
- let engine = useRef<RtcEngine | null>(null);
52
- let [dualStreamMode, setDualStreamMode] = useState<DualStreamMode>(
53
- rtcProps.initialDualStreamMode || DualStreamMode.DYNAMIC,
54
- );
55
- let {callActive} = props;
56
- callActive === undefined ? (callActive = true) : {};
57
-
58
- const reducer = (
59
- state: UidStateInterface,
60
- action: ActionInterface<keyof CallbacksInterface, CallbacksInterface>,
61
- ) => {
62
- let stateUpdate = {},
63
- uids = [...state.max, ...state.min].map((u: UidInterface) => u.uid);
64
-
65
- switch (action.type) {
66
- case 'UpdateDualStreamMode':
67
- const newMode = (action as ActionType<'UpdateDualStreamMode'>).value[0];
68
- if (newMode === DualStreamMode.HIGH) {
69
- const maxStateUpdate: UidInterface[] = state.max.map((user) => ({
70
- ...user,
71
- streamType: 'high',
72
- }));
73
- const minStateUpdate: UidInterface[] = state.min.map((user) => ({
74
- ...user,
75
- streamType: 'high',
76
- }));
77
- stateUpdate = {min: minStateUpdate, max: maxStateUpdate};
78
- }
79
- if (newMode === DualStreamMode.LOW) {
80
- const maxStateUpdate: UidInterface[] = state.max.map((user) => ({
81
- ...user,
82
- streamType: 'low',
83
- }));
84
- const minStateUpdate: UidInterface[] = state.min.map((user) => ({
85
- ...user,
86
- streamType: 'low',
87
- }));
88
- stateUpdate = {min: minStateUpdate, max: maxStateUpdate};
89
- }
90
- if (newMode === DualStreamMode.DYNAMIC) {
91
- const maxStateUpdate: UidInterface[] = state.max.map((user) => ({
92
- ...user,
93
- streamType: 'high',
94
- }));
95
- const minStateUpdate: UidInterface[] = state.min.map((user) => ({
96
- ...user,
97
- streamType: 'low',
98
- }));
99
- stateUpdate = {min: minStateUpdate, max: maxStateUpdate};
100
- }
101
- break;
102
- case 'UserJoined':
103
- if (
104
- uids.indexOf((action as ActionType<'UserJoined'>).value[0]) === -1
105
- ) {
106
- //If new user has joined
107
-
108
- let minUpdate = [
109
- ...state.min,
110
- {
111
- uid: (action as ActionType<'UserJoined'>).value[0],
112
- audio: false,
113
- video: false,
114
- streamType:
115
- dualStreamMode === DualStreamMode.HIGH ? 'high' : 'low', // Low if DualStreamMode is LOW or DYNAMIC by default
116
- },
117
- ]; //By default add to minimized
118
-
119
- if (minUpdate.length === 1 && state.max[0].uid === 'local') {
120
- //Only one remote and local is maximized
121
- //Change stream type to high if dualStreaMode is DYNAMIC
122
- if (dualStreamMode === DualStreamMode.DYNAMIC) {
123
- minUpdate[0].streamType = 'high';
124
- }
125
- //Swap max and min
126
- stateUpdate = {
127
- max: minUpdate,
128
- min: state.max,
129
- };
130
- } else {
131
- //More than one remote
132
- stateUpdate = {
133
- min: minUpdate,
134
- };
135
- }
136
-
137
- console.log('new user joined!\n', state, stateUpdate, {
138
- dualStreamMode,
139
- });
140
- }
141
- break;
142
- case 'UserOffline':
143
- if (
144
- state.max[0].uid === (action as ActionType<'UserOffline'>).value[0]
145
- ) {
146
- //If max has the remote video
147
- let minUpdate = [...state.min];
148
- stateUpdate = {
149
- max: [minUpdate.pop()],
150
- min: minUpdate,
151
- };
152
- } else {
153
- stateUpdate = {
154
- min: state.min.filter(
155
- (user) =>
156
- user.uid !== (action as ActionType<'UserOffline'>).value[0],
157
- ),
158
- };
159
- }
160
- break;
161
- case 'SwapVideo':
162
- stateUpdate = swapVideo(state, action.value[0] as UidInterface);
163
- break;
164
- case 'UserMuteRemoteAudio':
165
- const audioMute = (user: UidInterface) => {
166
- if (user.uid === (action.value[0] as UidInterface).uid) {
167
- user.audio = !action.value[1];
168
- }
169
- return user;
170
- };
171
- stateUpdate = {
172
- min: state.min.map(audioMute),
173
- max: state.max.map(audioMute),
174
- };
175
- break;
176
- case 'UserMuteRemoteVideo':
177
- const videoMute = (user: UidInterface) => {
178
- if (user.uid === (action.value[0] as UidInterface).uid) {
179
- user.video = !action.value[1];
180
- }
181
- return user;
182
- };
183
- stateUpdate = {
184
- min: state.min.map(videoMute),
185
- max: state.max.map(videoMute),
186
- };
187
- break;
188
- case 'LocalMuteAudio':
189
- (engine.current as RtcEngine).muteLocalAudioStream(
190
- (action as ActionType<'LocalMuteAudio'>).value[0],
191
- );
192
- const LocalAudioMute = (user: UidInterface) => {
193
- if (user.uid === 'local') {
194
- user.audio = !(action as ActionType<'LocalMuteAudio'>).value[0];
195
- }
196
- return user;
197
- };
198
- stateUpdate = {
199
- min: state.min.map(LocalAudioMute),
200
- max: state.max.map(LocalAudioMute),
201
- };
202
- break;
203
- case 'LocalMuteVideo':
204
- (engine.current as RtcEngine).muteLocalVideoStream(
205
- (action as ActionType<'LocalMuteAudio'>).value[0],
206
- );
207
- const LocalVideoMute = (user: UidInterface) => {
208
- if (user.uid === 'local') {
209
- user.video = !(action as ActionType<'LocalMuteVideo'>).value[0];
210
- }
211
- return user;
212
- };
213
- stateUpdate = {
214
- min: state.min.map(LocalVideoMute),
215
- max: state.max.map(LocalVideoMute),
216
- };
217
- break;
218
- case 'SwitchCamera':
219
- (engine.current as RtcEngine).switchCamera();
220
- break;
221
- case 'RemoteAudioStateChanged':
222
- let audioState;
223
- if (action.value[1] === 0) {
224
- audioState = false;
225
- } else if (action.value[1] === 2) {
226
- audioState = true;
227
- }
228
- const audioChange = (user: UidInterface) => {
229
- // updated condition to prevent undefined value to set in the state
230
- // so it will retain the previous state value
231
- if (user.uid == action.value[0] && audioState !== undefined) {
232
- user.audio = audioState;
233
- user.video = user.video;
234
- }
235
- return user;
236
- };
237
- stateUpdate = {
238
- min: state.min.map(audioChange),
239
- max: state.max.map(audioChange),
240
- };
241
- break;
242
- case 'RemoteVideoStateChanged':
243
- let videoState;
244
- let logx = action.value;
245
- if (action.value[1] === 0) {
246
- videoState = false;
247
- } else if (action.value[1] === 2) {
248
- videoState = true;
249
- }
250
- const videoChange = (user: UidInterface) => {
251
- //updated condition to check undefined for preventing blinking issue in native - mobile
252
- //so it will prevent the previous state vaule
253
- if (user.uid == action.value[0] && videoState !== undefined) {
254
- user.video = videoState;
255
- user.audio = user.audio;
256
- }
257
- return user;
258
- };
259
- stateUpdate = {
260
- min: state.min.map(videoChange),
261
- max: state.max.map(videoChange),
262
- };
263
- break;
264
- }
265
-
266
- // Handle event listeners
267
-
268
- if (callbacks && callbacks[action.type]) {
269
- // @ts-ignore
270
- callbacks[action.type].apply(null, action.value);
271
- console.log('callback executed');
272
- } else {
273
- // console.log('callback not found', action.type);
274
- }
275
-
276
- // console.log(state, action, stateUpdate);
277
-
278
- return {
279
- ...state,
280
- ...stateUpdate,
281
- };
282
- };
283
-
284
- const swapVideo = useCallback(
285
- (state: UidStateInterface, ele: UidInterface) => {
286
- let newState: UidStateInterface = {
287
- min: [],
288
- max: [],
289
- };
290
- // Remove the minimized element which is being swapped out
291
- newState.min = state.min.filter((e) => e !== ele);
292
-
293
- let maxEle = state.max[0]; // Element which is currently maximized
294
- let minEle = ele;
295
-
296
- if (dualStreamMode === DualStreamMode.DYNAMIC) {
297
- maxEle.streamType = 'low'; // set stream quality to low
298
- minEle.streamType = 'high'; // set stream quality to high
299
-
300
- // No need to modify the streamType if the mode is not dynamic
301
- }
302
-
303
- if (maxEle.uid === 'local') {
304
- newState.min.unshift(maxEle);
305
- } else {
306
- newState.min.push(maxEle);
307
- }
308
- newState.max = [minEle];
309
-
310
- return newState;
311
- },
312
- [dualStreamMode],
313
- );
314
- const [uidState, dispatch] = useReducer(reducer, initialState);
315
-
316
- // When mode is updated, reducer is triggered to update the individual states
317
- useEffect(() => {
318
- (dispatch as DispatchType<'UpdateDualStreamMode'>)({
319
- type: 'UpdateDualStreamMode',
320
- value: [dualStreamMode],
321
- });
322
- }, [dualStreamMode]);
323
-
324
- // useEffect(() => {
325
- // const setStreamType = (user: UidInterface) => {
326
- // if (user.uid !== 'local') {
327
- // engine.current?.setRemoteVideoStreamType(
328
- // user.uid as number,
329
- // user.streamType === 'high' ? 0 : 1,
330
- // );
331
- // }
332
- // };
333
- // uidState.max.map(setStreamType);
334
- // uidState.min.map(setStreamType);
335
- // }, [uidState.min, uidState.max]);
336
-
337
- useEffect(() => {
338
- async function init() {
339
- if (Platform.OS === 'android') {
340
- //Request required permissions from Android
341
- await requestCameraAndAudioPermission();
342
- }
343
- try {
344
- if (Platform.OS === 'android' || Platform.OS === 'ios') {
345
- engine.current = await RtcEngine.createWithAreaCode(
346
- rtcProps.appId,
347
- AreaCode.GLOB ^ AreaCode.CN,
348
- );
349
- } else {
350
- engine.current = await RtcEngine.create(rtcProps.appId);
351
- }
352
- console.log(engine.current);
353
- if (rtcProps.profile) {
354
- if (Platform.OS === 'web') {
355
- // @ts-ignore
356
- await engine.current.setVideoProfile(rtcProps.profile);
357
- } else {
358
- const config: VideoEncoderConfiguration = quality[rtcProps.profile];
359
- await engine.current.setVideoEncoderConfiguration({
360
- ...config,
361
- bitrate: 0,
362
- });
363
- }
364
- }
365
- try {
366
- await engine.current.enableVideo();
367
- } catch (e) {
368
- (dispatch as DispatchType<'LocalMuteAudio'>)({
369
- type: 'LocalMuteAudio',
370
- value: [true],
371
- });
372
- (dispatch as DispatchType<'LocalMuteVideo'>)({
373
- type: 'LocalMuteVideo',
374
- value: [true],
375
- });
376
- console.error('No devices', e);
377
- }
378
-
379
- engine.current.addListener('JoinChannelSuccess', async (...args) => {
380
- //Get current peer IDs
381
- (dispatch as DispatchType<'JoinChannelSuccess'>)({
382
- type: 'JoinChannelSuccess',
383
- value: args,
384
- });
385
-
386
- console.log('UIkit enabling dual stream', rtcProps.dual);
387
- if (rtcProps.dual) {
388
- console.log('UIkit enabled dual stream');
389
- await engine.current.enableDualStreamMode(rtcProps.dual);
390
- // await engine.current.setRemoteSubscribeFallbackOption(1);
391
- }
392
- });
393
-
394
- engine.current.addListener('UserJoined', (...args) => {
395
- //Get current peer IDs
396
- (dispatch as DispatchType<'UserJoined'>)({
397
- type: 'UserJoined',
398
- value: args,
399
- });
400
- });
401
-
402
- engine.current.addListener('UserOffline', (...args) => {
403
- //If user leaves
404
- (dispatch as DispatchType<'UserOffline'>)({
405
- type: 'UserOffline',
406
- value: args,
407
- });
408
- });
409
-
410
- engine.current.addListener('RemoteAudioStateChanged', (...args) => {
411
- console.log('RemoteAudioStateChanged', args);
412
-
413
- (dispatch as DispatchType<'RemoteAudioStateChanged'>)({
414
- type: 'RemoteAudioStateChanged',
415
- value: args,
416
- });
417
- });
418
-
419
- engine.current.addListener('Error', (e) => {
420
- console.log('Error: ', e);
421
- });
422
-
423
- engine.current.addListener('RemoteVideoStateChanged', (...args) => {
424
- console.log('RemoteVideoStateChanged', args);
425
-
426
- dispatch({
427
- type: 'RemoteVideoStateChanged',
428
- value: args,
429
- });
430
- });
431
-
432
- (joinRes as (arg0: boolean) => void)(true);
433
- setReady(true);
434
- } catch (e) {
435
- console.error(e);
436
- }
437
- }
438
-
439
- if (joinRes) {
440
- init();
441
- return () => {
442
- (engine.current as RtcEngine).destroy();
443
- };
444
- }
445
- // eslint-disable-next-line react-hooks/exhaustive-deps
446
- }, [rtcProps.appId]);
447
-
448
- // Dynamically switches channel when channel prop changes
449
- useEffect(() => {
450
- async function join() {
451
- await canJoin.current;
452
- if (
453
- engine.current &&
454
- rtcProps.encryption &&
455
- rtcProps.encryption.key &&
456
- rtcProps.encryption.mode
457
- ) {
458
- console.log('using channel encryption', rtcProps.encryption);
459
- // await engine.current.setEncryptionSecret(rtcProps.encryption.key);
460
- // await engine.current.setEncryptionMode(rtcProps.encryption.mode);
461
- await engine.current.enableEncryption(true, {
462
- encryptionKey: rtcProps.encryption.key,
463
- encryptionMode: rtcProps.encryption.mode,
464
- });
465
- }
466
- if (engine.current) {
467
- if(uidState.max[0].video){
468
- await engine.current.muteLocalVideoStream(true);
469
- }
470
-
471
- await engine.current.joinChannel(
472
- rtcProps.token || null,
473
- rtcProps.channel,
474
- null,
475
- rtcProps.uid || 0,
476
- );
477
- if(uidState.max[0].video){
478
- await engine.current.muteLocalVideoStream(false);
479
- }
480
-
481
- } else {
482
- console.error('trying to join before RTC Engine was initialized');
483
- }
484
- }
485
- if (callActive) {
486
- join();
487
- console.log('Attempted join: ', rtcProps.channel);
488
- } else {
489
- console.log('In precall - waiting to join');
490
- }
491
- return () => {
492
- if (callActive) {
493
- console.log('Leaving channel');
494
- canJoin.current = (engine.current as RtcEngine)
495
- .leaveChannel()
496
- .catch((err: any) => console.log(err));
497
- }
498
- };
499
- }, [rtcProps.channel, rtcProps.uid, rtcProps.token, callActive]);
500
-
501
- return (
502
- <RtcProvider
503
- value={{
504
- RtcEngine: engine.current as RtcEngine,
505
- dispatch,
506
- setDualStreamMode,
507
- }}>
508
- <MaxUidProvider value={uidState.max}>
509
- <MinUidProvider value={uidState.min}>
510
- {
511
- // Render children once RTCEngine has been initialized
512
- ready ? props.children : <></>
513
- }
514
- </MinUidProvider>
515
- </MaxUidProvider>
516
- </RtcProvider>
517
- );
518
- };
519
-
520
- export default RtcConfigure;