agora-appbuilder-core 4.0.24 → 4.0.25-beta-2
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.
- package/package.json +1 -1
- package/template/agora-rn-uikit/.eslintrc.js +0 -5
- package/template/agora-rn-uikit/package-lock.json +6116 -23528
- package/template/agora-rn-uikit/package.json +14 -14
- package/template/agora-rn-uikit/src/AgoraUIKit.tsx +6 -6
- package/template/agora-rn-uikit/src/Contexts/LocalUserContext.tsx +6 -6
- package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +40 -79
- package/template/agora-rn-uikit/src/Contexts/RenderContext.tsx +10 -0
- package/template/agora-rn-uikit/src/Contexts/RtcContext.tsx +17 -26
- package/template/agora-rn-uikit/src/Controls/BtnTemplate.tsx +0 -1
- package/template/agora-rn-uikit/src/Controls/Icons.ts +0 -51
- package/template/agora-rn-uikit/src/Controls/Local/EndCall.tsx +4 -6
- package/template/agora-rn-uikit/src/Controls/Local/FullScreen.tsx +1 -3
- package/template/agora-rn-uikit/src/Controls/Local/LocalAudioMute.tsx +2 -5
- package/template/agora-rn-uikit/src/Controls/Local/LocalVideoMute.tsx +2 -5
- package/template/agora-rn-uikit/src/Controls/Local/Recording.tsx +2 -0
- package/template/agora-rn-uikit/src/Controls/Local/SwitchCamera.tsx +6 -7
- package/template/agora-rn-uikit/src/Controls/LocalControls.tsx +5 -5
- package/template/agora-rn-uikit/src/Controls/Remote/RemoteAudioMute.tsx +4 -5
- package/template/agora-rn-uikit/src/Controls/Remote/RemoteSwap.tsx +1 -3
- package/template/agora-rn-uikit/src/Controls/Remote/RemoteVideoMute.tsx +4 -5
- package/template/agora-rn-uikit/src/Controls/RemoteControls.tsx +2 -2
- package/template/agora-rn-uikit/src/Reducer/ActiveSpeakerDetected.ts +11 -0
- package/template/agora-rn-uikit/src/Reducer/LocalMuteAudio.ts +7 -8
- package/template/agora-rn-uikit/src/Reducer/LocalMuteVideo.ts +7 -8
- package/template/agora-rn-uikit/src/Reducer/LocalPermissionState.ts +7 -6
- package/template/agora-rn-uikit/src/Reducer/RemoteAudioStateChanged.ts +8 -7
- package/template/agora-rn-uikit/src/Reducer/RemoteVideoStateChanged.ts +9 -9
- package/template/agora-rn-uikit/src/Reducer/UpdateDualStreamMode.ts +8 -7
- package/template/agora-rn-uikit/src/Reducer/UserJoined.ts +13 -14
- package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteAudio.ts +7 -6
- package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteVideo.ts +7 -6
- package/template/agora-rn-uikit/src/Reducer/UserOffline.ts +6 -5
- package/template/agora-rn-uikit/src/Reducer/UserPin.ts +3 -20
- package/template/agora-rn-uikit/src/Reducer/index.ts +1 -2
- package/template/agora-rn-uikit/src/Rtc/Create.tsx +125 -122
- package/template/agora-rn-uikit/src/Rtc/Join.tsx +27 -46
- package/template/agora-rn-uikit/src/RtcConfigure.tsx +77 -175
- package/template/agora-rn-uikit/src/Utils/quality.tsx +0 -8
- package/template/agora-rn-uikit/src/Views/MaxVideoView.native.tsx +12 -56
- package/template/agora-rn-uikit/src/Views/MaxVideoView.tsx +17 -47
- package/template/agora-rn-uikit/src/Views/MinVideoView.tsx +11 -19
- package/template/agora-rn-uikit/src/index.ts +9 -16
- package/template/customization-api/typeDefinition.ts +1 -4
- package/template/customization-api/utils.ts +1 -0
- package/template/defaultConfig.js +2 -0
- package/template/global.d.ts +2 -0
- package/template/src/AppRoutes.tsx +1 -7
- package/template/src/auth/AuthProvider.tsx +70 -24
- package/template/src/auth/useIDPAuth.electron.tsx +59 -2
- package/template/src/auth/useIDPAuth.native.tsx +59 -2
- package/template/src/auth/useIDPAuth.tsx +60 -2
- package/template/src/auth/useTokenAuth.tsx +66 -4
- package/template/src/components/DeviceConfigure.tsx +74 -68
- package/template/src/components/GraphQLProvider.tsx +0 -1
- package/template/src/components/contexts/WaitingRoomContext.tsx +11 -4
- package/template/src/components/recording-bot/RecordingBotRoute.tsx +1 -1
- package/template/src/components/useUserPreference.tsx +56 -9
- package/template/src/components/whiteboard/WhiteboardConfigure.tsx +4 -1
- package/template/src/components/whiteboard/WhiteboardToolBox.tsx +185 -24
- package/template/src/components/whiteboard/WhiteboardWidget.tsx +47 -6
- package/template/src/logger/AppBuilderLogger.tsx +94 -36
- package/template/src/logger/transports/customer-transport.ts +7 -3
- package/template/src/pages/VideoCall.tsx +3 -5
- package/template/src/subComponents/SelectDevice.tsx +14 -52
- package/template/src/subComponents/caption/useSTTAPI.tsx +39 -3
- package/template/src/subComponents/recording/useRecording.tsx +69 -20
- package/template/src/subComponents/waiting-rooms/useWaitingRoomAPI.ts +30 -8
- package/template/src/utils/common.tsx +6 -1
- package/template/src/utils/useCreateRoom.ts +21 -2
- package/template/src/utils/useFindActiveSpeaker.ts +12 -5
- package/template/src/utils/useGetMeetingPhrase.ts +44 -1
- package/template/src/utils/useJoinRoom.ts +29 -2
- package/template/src/utils/useMutePSTN.ts +29 -0
- package/template/agora-rn-uikit/src/Contexts/ContentContext.tsx +0 -10
- package/template/agora-rn-uikit/src/Contexts/DispatchContext.tsx +0 -22
- package/template/agora-rn-uikit/src/Reducer/ActiveSpeaker.ts +0 -30
- package/template/agora-rn-uikit/src/Reducer/UserSecondaryPin.ts +0 -23
- package/template/agora-rn-uikit/src/Utils/isBotUser.ts +0 -15
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import React, {useState, useReducer, useContext, useCallback} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
RtcProvider,
|
|
4
|
-
|
|
4
|
+
RenderStateInterface,
|
|
5
|
+
DispatchType,
|
|
5
6
|
ActionType,
|
|
6
7
|
UidType,
|
|
7
|
-
CustomContentInferface,
|
|
8
8
|
} from './Contexts/RtcContext';
|
|
9
|
-
import {DispatchType} from './Contexts/DispatchContext';
|
|
10
9
|
import PropsContext, {
|
|
11
10
|
ToggleState,
|
|
11
|
+
RtcPropsInterface,
|
|
12
12
|
CallbacksInterface,
|
|
13
13
|
DualStreamMode,
|
|
14
14
|
PermissionState,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
ChannelProfile,
|
|
16
|
+
ClientRole,
|
|
17
17
|
} from './Contexts/PropsContext';
|
|
18
|
-
import {
|
|
18
|
+
import {RenderProvider} from './Contexts/RenderContext';
|
|
19
19
|
import {actionTypeGuard} from './Utils/actionTypeGuard';
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
|
+
ActiveSpeakerDetected,
|
|
22
23
|
LocalMuteAudio,
|
|
23
24
|
LocalMuteVideo,
|
|
24
25
|
LocalPermissionState,
|
|
@@ -30,24 +31,19 @@ import {
|
|
|
30
31
|
UserMuteRemoteVideo,
|
|
31
32
|
UserOffline,
|
|
32
33
|
UserPin,
|
|
33
|
-
UserSecondaryPin,
|
|
34
|
-
ActiveSpeaker,
|
|
35
34
|
} from './Reducer';
|
|
36
35
|
import Create from './Rtc/Create';
|
|
37
36
|
import Join from './Rtc/Join';
|
|
38
37
|
import useLocalUid from './Utils/useLocalUid';
|
|
39
|
-
import {DispatchProvider} from './Contexts/DispatchContext';
|
|
40
38
|
|
|
41
|
-
const RtcConfigure = (
|
|
39
|
+
const RtcConfigure = (props: {children: React.ReactNode}) => {
|
|
42
40
|
const {callbacks, rtcProps, mode} = useContext(PropsContext);
|
|
43
41
|
let [dualStreamMode, setDualStreamMode] = useState<DualStreamMode>(
|
|
44
42
|
rtcProps?.initialDualStreamMode || DualStreamMode.DYNAMIC,
|
|
45
43
|
);
|
|
46
44
|
const localUid = useLocalUid();
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
customContent: {},
|
|
50
|
-
defaultContent: {
|
|
45
|
+
const initialLocalState: RenderStateInterface = {
|
|
46
|
+
renderList: {
|
|
51
47
|
[localUid]: {
|
|
52
48
|
uid: localUid,
|
|
53
49
|
audio: ToggleState.disabled,
|
|
@@ -55,13 +51,11 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
55
51
|
streamType: 'high',
|
|
56
52
|
type: 'rtc',
|
|
57
53
|
permissionStatus: PermissionState.NOT_REQUESTED,
|
|
58
|
-
audioForceDisabled: false,
|
|
59
|
-
videoForceDisabled: false,
|
|
60
54
|
},
|
|
61
55
|
},
|
|
62
|
-
activeUids:
|
|
56
|
+
activeUids: [localUid],
|
|
57
|
+
activeSpeaker: undefined,
|
|
63
58
|
pinnedUid: undefined,
|
|
64
|
-
secondaryPinnedUid: undefined,
|
|
65
59
|
lastJoinedUid: 0,
|
|
66
60
|
};
|
|
67
61
|
|
|
@@ -71,12 +65,11 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
71
65
|
|
|
72
66
|
React.useEffect(() => {
|
|
73
67
|
setInitialState(JSON.parse(JSON.stringify(initialLocalState)));
|
|
74
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75
68
|
}, []);
|
|
76
69
|
|
|
77
70
|
/**
|
|
78
71
|
*
|
|
79
|
-
* @param state
|
|
72
|
+
* @param state RenderStateInterface
|
|
80
73
|
* @param action ActionType<'UpdateRenderList'>
|
|
81
74
|
* @returns void
|
|
82
75
|
*
|
|
@@ -84,15 +77,15 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
84
77
|
*
|
|
85
78
|
*/
|
|
86
79
|
const UpdateRenderList = (
|
|
87
|
-
state:
|
|
80
|
+
state: RenderStateInterface,
|
|
88
81
|
action: ActionType<'UpdateRenderList'>,
|
|
89
82
|
) => {
|
|
90
83
|
const newState = {
|
|
91
84
|
...state,
|
|
92
|
-
|
|
93
|
-
...state.
|
|
85
|
+
renderList: {
|
|
86
|
+
...state.renderList,
|
|
94
87
|
[action.value[0]]: {
|
|
95
|
-
...state.
|
|
88
|
+
...state.renderList[action.value[0]],
|
|
96
89
|
...action.value[1],
|
|
97
90
|
},
|
|
98
91
|
},
|
|
@@ -102,69 +95,32 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
102
95
|
|
|
103
96
|
/**
|
|
104
97
|
*
|
|
105
|
-
* @param state
|
|
98
|
+
* @param state RenderStateInterface
|
|
106
99
|
* @param action ActionType<'AddCustomContent'>
|
|
107
100
|
* @returns void
|
|
108
101
|
*
|
|
109
102
|
* AddCustomContent use to add new data into render position and render list
|
|
110
103
|
*/
|
|
111
|
-
// const AddCustomContent = (
|
|
112
|
-
// state: ContentStateInterface,
|
|
113
|
-
// action: ActionType<'AddCustomContent'>,
|
|
114
|
-
// ) => {
|
|
115
|
-
// const newState = {
|
|
116
|
-
// ...state,
|
|
117
|
-
// activeUids: [...state.activeUids, action.value[0]],
|
|
118
|
-
// defaultContent: {
|
|
119
|
-
// ...state.defaultContent,
|
|
120
|
-
// [action.value[0]]: {
|
|
121
|
-
// ...state.defaultContent[action.value[0]],
|
|
122
|
-
// ...action.value[1],
|
|
123
|
-
// },
|
|
124
|
-
// },
|
|
125
|
-
// };
|
|
126
|
-
// return newState;
|
|
127
|
-
// };
|
|
128
|
-
|
|
129
104
|
const AddCustomContent = (
|
|
130
|
-
state:
|
|
105
|
+
state: RenderStateInterface,
|
|
131
106
|
action: ActionType<'AddCustomContent'>,
|
|
132
107
|
) => {
|
|
133
108
|
const newState = {
|
|
134
109
|
...state,
|
|
135
|
-
activeUids: state.activeUids
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
customContent: {
|
|
139
|
-
...state.customContent,
|
|
110
|
+
activeUids: [...state.activeUids, action.value[0]],
|
|
111
|
+
renderList: {
|
|
112
|
+
...state.renderList,
|
|
140
113
|
[action.value[0]]: {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
props: action.value[1]?.props,
|
|
144
|
-
onStage: action.value[1]?.onStage,
|
|
114
|
+
...state.renderList[action.value[0]],
|
|
115
|
+
...action.value[1],
|
|
145
116
|
},
|
|
146
117
|
},
|
|
147
118
|
};
|
|
148
119
|
return newState;
|
|
149
120
|
};
|
|
150
|
-
const RemoveCustomContent = (
|
|
151
|
-
state: ContentStateInterface,
|
|
152
|
-
action: ActionType<'RemoveCustomContent'>,
|
|
153
|
-
) => {
|
|
154
|
-
const customContent = state.customContent;
|
|
155
|
-
if (customContent && customContent[action.value[0]]) {
|
|
156
|
-
delete customContent[action.value[0]];
|
|
157
|
-
}
|
|
158
|
-
const newState = {
|
|
159
|
-
...state,
|
|
160
|
-
activeUids: [...state.activeUids.filter((i) => i !== action.value[0])],
|
|
161
|
-
...customContent,
|
|
162
|
-
};
|
|
163
|
-
return newState;
|
|
164
|
-
};
|
|
165
121
|
|
|
166
122
|
const reducer = (
|
|
167
|
-
state:
|
|
123
|
+
state: RenderStateInterface,
|
|
168
124
|
action: ActionType<keyof CallbacksInterface>,
|
|
169
125
|
) => {
|
|
170
126
|
let stateUpdate = {};
|
|
@@ -175,11 +131,6 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
175
131
|
stateUpdate = AddCustomContent(state, action);
|
|
176
132
|
}
|
|
177
133
|
break;
|
|
178
|
-
case 'RemoveCustomContent':
|
|
179
|
-
if (actionTypeGuard(action, action.type)) {
|
|
180
|
-
stateUpdate = RemoveCustomContent(state, action);
|
|
181
|
-
}
|
|
182
|
-
break;
|
|
183
134
|
case 'UpdateRenderList':
|
|
184
135
|
if (actionTypeGuard(action, action.type)) {
|
|
185
136
|
stateUpdate = UpdateRenderList(state, action);
|
|
@@ -245,19 +196,14 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
245
196
|
stateUpdate = RemoteVideoStateChanged(state, action);
|
|
246
197
|
}
|
|
247
198
|
break;
|
|
248
|
-
case '
|
|
199
|
+
case 'ActiveSpeakerDetected':
|
|
249
200
|
if (actionTypeGuard(action, action.type)) {
|
|
250
|
-
stateUpdate =
|
|
201
|
+
stateUpdate = ActiveSpeakerDetected(state, action);
|
|
251
202
|
}
|
|
252
203
|
break;
|
|
253
|
-
case '
|
|
254
|
-
if (actionTypeGuard(action, action.type)) {
|
|
255
|
-
stateUpdate = UserSecondaryPin(state, action);
|
|
256
|
-
}
|
|
257
|
-
break;
|
|
258
|
-
case 'ActiveSpeaker':
|
|
204
|
+
case 'UserPin':
|
|
259
205
|
if (actionTypeGuard(action, action.type)) {
|
|
260
|
-
stateUpdate =
|
|
206
|
+
stateUpdate = UserPin(state, action);
|
|
261
207
|
}
|
|
262
208
|
break;
|
|
263
209
|
}
|
|
@@ -281,16 +227,16 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
281
227
|
};
|
|
282
228
|
|
|
283
229
|
const swapVideo = useCallback(
|
|
284
|
-
(state:
|
|
230
|
+
(state: RenderStateInterface, newMaxUid: UidType) => {
|
|
285
231
|
if (state?.activeUids?.indexOf(newMaxUid) === -1) {
|
|
286
232
|
//skip the update if new max uid is not joined yet.
|
|
287
233
|
return {};
|
|
288
234
|
}
|
|
289
|
-
let activeUids:
|
|
235
|
+
let activeUids: RenderStateInterface['activeUids'] = [
|
|
290
236
|
...state.activeUids,
|
|
291
237
|
];
|
|
292
|
-
let
|
|
293
|
-
...state.
|
|
238
|
+
let renderList: RenderStateInterface['renderList'] = {
|
|
239
|
+
...state.renderList,
|
|
294
240
|
};
|
|
295
241
|
|
|
296
242
|
// Element which is currently maximized
|
|
@@ -308,12 +254,8 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
308
254
|
}
|
|
309
255
|
|
|
310
256
|
if (dualStreamMode === DualStreamMode.DYNAMIC) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
: null;
|
|
314
|
-
defaultContent[newMaxUid]
|
|
315
|
-
? (defaultContent[newMaxUid].streamType = 'high')
|
|
316
|
-
: null;
|
|
257
|
+
renderList[currentMaxUid].streamType = 'low';
|
|
258
|
+
renderList[newMaxUid].streamType = 'high';
|
|
317
259
|
// No need to modify the streamType if the mode is not dynamic
|
|
318
260
|
}
|
|
319
261
|
|
|
@@ -328,7 +270,8 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
328
270
|
|
|
329
271
|
return {
|
|
330
272
|
activeUids: activeUids,
|
|
331
|
-
|
|
273
|
+
renderList: renderList,
|
|
274
|
+
activeSpeaker: state.activeSpeaker,
|
|
332
275
|
};
|
|
333
276
|
},
|
|
334
277
|
[dualStreamMode],
|
|
@@ -338,18 +281,18 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
338
281
|
* deque will
|
|
339
282
|
*/
|
|
340
283
|
const dequeVideo = useCallback(
|
|
341
|
-
(state:
|
|
284
|
+
(state: RenderStateInterface, newMaxUid: UidType) => {
|
|
342
285
|
if (state?.activeUids?.indexOf(newMaxUid) === -1) {
|
|
343
286
|
//skip the update if new max uid is not joined yet.
|
|
344
287
|
return {};
|
|
345
288
|
}
|
|
346
|
-
let activeUids:
|
|
289
|
+
let activeUids: RenderStateInterface['activeUids'] = [
|
|
347
290
|
...state.activeUids,
|
|
348
291
|
];
|
|
349
|
-
let
|
|
350
|
-
...state.
|
|
292
|
+
let renderList: RenderStateInterface['renderList'] = {
|
|
293
|
+
...state.renderList,
|
|
351
294
|
};
|
|
352
|
-
if (!(newMaxUid in
|
|
295
|
+
if (!(newMaxUid in renderList)) {
|
|
353
296
|
//skip the update if new max uid is not joined yet.
|
|
354
297
|
return {};
|
|
355
298
|
}
|
|
@@ -362,8 +305,8 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
362
305
|
}
|
|
363
306
|
|
|
364
307
|
if (dualStreamMode === DualStreamMode.DYNAMIC) {
|
|
365
|
-
|
|
366
|
-
|
|
308
|
+
renderList[currentMaxUid].streamType = 'low';
|
|
309
|
+
renderList[newMaxUid].streamType = 'high';
|
|
367
310
|
// No need to modify the streamType if the mode is not dynamic
|
|
368
311
|
}
|
|
369
312
|
|
|
@@ -374,96 +317,55 @@ const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
|
374
317
|
activeUids = [newMaxUid, currentMaxUid, ...minIds];
|
|
375
318
|
|
|
376
319
|
return {
|
|
320
|
+
activeSpeaker: state.activeSpeaker,
|
|
377
321
|
activeUids: activeUids,
|
|
378
|
-
|
|
322
|
+
renderList: renderList,
|
|
379
323
|
};
|
|
380
324
|
},
|
|
381
325
|
[dualStreamMode],
|
|
382
326
|
);
|
|
383
327
|
|
|
384
|
-
const [uidState, dispatch]: [
|
|
385
|
-
|
|
328
|
+
const [uidState, dispatch]: [RenderStateInterface, DispatchType] = useReducer(
|
|
329
|
+
reducer,
|
|
330
|
+
initialState,
|
|
331
|
+
);
|
|
386
332
|
|
|
387
|
-
const setCustomContent = (
|
|
388
|
-
uid: CustomContentInferface['uid'],
|
|
389
|
-
component: CustomContentInferface['component'],
|
|
390
|
-
props?: CustomContentInferface['props'],
|
|
391
|
-
onStage?: CustomContentInferface['onStage'],
|
|
392
|
-
) => {
|
|
393
|
-
if (!uid) {
|
|
394
|
-
console.log('debugging UID is not given');
|
|
395
|
-
return;
|
|
396
|
-
} else {
|
|
397
|
-
if (!component) {
|
|
398
|
-
dispatch({
|
|
399
|
-
type: 'RemoveCustomContent',
|
|
400
|
-
value: [uid],
|
|
401
|
-
});
|
|
402
|
-
} else {
|
|
403
|
-
dispatch({
|
|
404
|
-
type: 'AddCustomContent',
|
|
405
|
-
value: [
|
|
406
|
-
uid,
|
|
407
|
-
{component, props, onStage: onStage === undefined ? true : onStage},
|
|
408
|
-
],
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
333
|
return (
|
|
414
334
|
<Create dispatch={dispatch}>
|
|
415
335
|
{(engineRef, tracksReady) => (
|
|
416
336
|
<Join
|
|
417
|
-
precall={!rtcProps
|
|
418
|
-
preventJoin={rtcProps?.preventJoin}
|
|
337
|
+
precall={!rtcProps.callActive}
|
|
419
338
|
engineRef={engineRef}
|
|
420
339
|
uidState={uidState}
|
|
421
340
|
dispatch={dispatch}
|
|
422
|
-
tracksReady={tracksReady}
|
|
423
|
-
|
|
424
|
-
|
|
341
|
+
tracksReady={tracksReady}
|
|
342
|
+
>
|
|
343
|
+
<RtcProvider
|
|
344
|
+
value={{
|
|
345
|
+
RtcEngine: engineRef.current,
|
|
346
|
+
dispatch,
|
|
347
|
+
setDualStreamMode,
|
|
348
|
+
}}>
|
|
349
|
+
<RenderProvider
|
|
425
350
|
value={{
|
|
426
|
-
|
|
427
|
-
|
|
351
|
+
renderList: uidState.renderList,
|
|
352
|
+
activeUids:
|
|
353
|
+
//In livestreaming mode ->audience should not see their local video tile
|
|
354
|
+
mode == ChannelProfile.LiveBroadcasting &&
|
|
355
|
+
rtcProps?.role == ClientRole.Audience
|
|
356
|
+
? uidState.activeUids.filter((i) => i !== localUid)
|
|
357
|
+
: uidState.activeUids,
|
|
358
|
+
activeSpeaker: uidState.activeSpeaker,
|
|
359
|
+
pinnedUid:
|
|
360
|
+
uidState?.pinnedUid &&
|
|
361
|
+
uidState?.activeUids?.indexOf(uidState.pinnedUid) !== -1
|
|
362
|
+
? uidState.pinnedUid
|
|
363
|
+
: undefined,
|
|
364
|
+
lastJoinedUid: uidState.lastJoinedUid,
|
|
428
365
|
}}>
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
setCustomContent: setCustomContent,
|
|
433
|
-
defaultContent: uidState.defaultContent,
|
|
434
|
-
activeUids:
|
|
435
|
-
//In livestreaming mode ->audience should not see their local video tile
|
|
436
|
-
mode ===
|
|
437
|
-
ChannelProfileType.ChannelProfileLiveBroadcasting &&
|
|
438
|
-
rtcProps?.role === ClientRoleType.ClientRoleAudience
|
|
439
|
-
? [
|
|
440
|
-
...new Set(
|
|
441
|
-
uidState.activeUids.filter((i) => i !== localUid),
|
|
442
|
-
),
|
|
443
|
-
]
|
|
444
|
-
: [
|
|
445
|
-
...new Set(
|
|
446
|
-
uidState.activeUids.filter((i) => i !== undefined),
|
|
447
|
-
),
|
|
448
|
-
],
|
|
449
|
-
pinnedUid:
|
|
450
|
-
uidState?.pinnedUid &&
|
|
451
|
-
uidState?.activeUids?.indexOf(uidState.pinnedUid) !== -1
|
|
452
|
-
? uidState.pinnedUid
|
|
453
|
-
: undefined,
|
|
454
|
-
secondaryPinnedUid:
|
|
455
|
-
uidState?.secondaryPinnedUid &&
|
|
456
|
-
uidState?.activeUids?.indexOf(
|
|
457
|
-
uidState.secondaryPinnedUid,
|
|
458
|
-
) !== -1
|
|
459
|
-
? uidState.secondaryPinnedUid
|
|
460
|
-
: undefined,
|
|
461
|
-
lastJoinedUid: uidState.lastJoinedUid,
|
|
462
|
-
}}>
|
|
463
|
-
{outerProps.children}
|
|
464
|
-
</ContentProvider>
|
|
465
|
-
</RtcProvider>
|
|
466
|
-
</DispatchProvider>
|
|
366
|
+
{props.children}
|
|
367
|
+
</RenderProvider>
|
|
368
|
+
</RtcProvider>
|
|
467
369
|
</Join>
|
|
468
370
|
)}
|
|
469
371
|
</Create>
|
|
@@ -1,57 +1,25 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
|
-
import {
|
|
3
|
-
RenderModeType,
|
|
4
|
-
RtcSurfaceView,
|
|
5
|
-
RtcTextureView,
|
|
6
|
-
} from 'react-native-agora';
|
|
2
|
+
import {RtcLocalView, RtcRemoteView, VideoRenderMode} from 'react-native-agora';
|
|
7
3
|
import styles from '../Style';
|
|
8
|
-
import PropsContext, {
|
|
9
|
-
import {View, ViewStyle
|
|
4
|
+
import PropsContext, {RenderInterface} from '../Contexts/PropsContext';
|
|
5
|
+
import {View, ViewStyle} from 'react-native';
|
|
10
6
|
import useLocalUid from '../Utils/useLocalUid';
|
|
11
7
|
|
|
12
|
-
const LocalView =
|
|
13
|
-
|
|
8
|
+
const LocalView = RtcLocalView.SurfaceView;
|
|
9
|
+
const RemoteView = RtcRemoteView.SurfaceView;
|
|
14
10
|
|
|
15
11
|
interface MaxViewInterface {
|
|
16
|
-
user:
|
|
12
|
+
user: RenderInterface;
|
|
17
13
|
fallback?: React.ComponentType;
|
|
18
14
|
containerStyle?: ViewStyle;
|
|
19
|
-
landscapeMode?: boolean;
|
|
20
|
-
isFullView?: boolean;
|
|
21
15
|
}
|
|
22
16
|
|
|
23
|
-
/*
|
|
24
|
-
RenderModeType :
|
|
25
|
-
Fill: Stretches or zooms to fill the screen, might distort.
|
|
26
|
-
Fit: Fits the entire video without distortion, might have black bars.
|
|
27
|
-
Hidden: Fills the screen, might cut off parts of the video.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
17
|
const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
31
18
|
const {styleProps, rtcProps} = useContext(PropsContext);
|
|
32
19
|
const {maxViewStyles} = styleProps || {};
|
|
33
|
-
const {
|
|
34
|
-
containerStyle = {},
|
|
35
|
-
landscapeMode = false,
|
|
36
|
-
isFullView = false,
|
|
37
|
-
} = props;
|
|
38
|
-
let landscapeModeStyle: ViewProps['style'] = {};
|
|
39
|
-
if (landscapeMode) {
|
|
40
|
-
//SurfaceView does not support transform
|
|
41
|
-
//TextureView only applicable to android
|
|
42
|
-
if (Platform.OS === 'android') {
|
|
43
|
-
RemoteView = RtcTextureView;
|
|
44
|
-
}
|
|
45
|
-
landscapeModeStyle = {
|
|
46
|
-
flex: 1,
|
|
47
|
-
alignSelf: 'center',
|
|
48
|
-
alignItems: 'center',
|
|
49
|
-
transform: [{rotate: '90deg'}],
|
|
50
|
-
};
|
|
51
|
-
}
|
|
20
|
+
const {containerStyle = {}} = props;
|
|
52
21
|
const Fallback = props.fallback;
|
|
53
22
|
const localUid = useLocalUid();
|
|
54
|
-
//@ts-ignore
|
|
55
23
|
const uid = props.user.uid === rtcProps?.screenShareUid ? 1 : props.user.uid;
|
|
56
24
|
return uid === localUid ? (
|
|
57
25
|
props.user.video ? (
|
|
@@ -61,17 +29,12 @@ const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
|
61
29
|
...(maxViewStyles as object),
|
|
62
30
|
...containerStyle,
|
|
63
31
|
}}
|
|
64
|
-
|
|
65
|
-
renderMode: isFullView
|
|
66
|
-
? RenderModeType.RenderModeAdaptive
|
|
67
|
-
: RenderModeType.RenderModeFit,
|
|
68
|
-
uid: 0,
|
|
69
|
-
}}
|
|
32
|
+
renderMode={VideoRenderMode.Fit}
|
|
70
33
|
/>
|
|
71
34
|
) : Fallback ? (
|
|
72
35
|
<Fallback />
|
|
73
36
|
) : (
|
|
74
|
-
<View style={[
|
|
37
|
+
<View style={[{flex: 1, backgroundColor: '#000'}, containerStyle]} />
|
|
75
38
|
)
|
|
76
39
|
) : props.user.video ? (
|
|
77
40
|
<RemoteView
|
|
@@ -79,22 +42,15 @@ const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
|
79
42
|
...styles.fullView,
|
|
80
43
|
...(maxViewStyles as object),
|
|
81
44
|
...containerStyle,
|
|
82
|
-
...landscapeModeStyle,
|
|
83
|
-
}}
|
|
84
|
-
canvas={{
|
|
85
|
-
renderMode: RenderModeType.RenderModeFit,
|
|
86
|
-
uid: uid as number,
|
|
87
45
|
}}
|
|
46
|
+
uid={uid as number}
|
|
47
|
+
renderMode={VideoRenderMode.Fit}
|
|
88
48
|
/>
|
|
89
49
|
) : Fallback ? (
|
|
90
50
|
<Fallback />
|
|
91
51
|
) : (
|
|
92
|
-
<View style={[
|
|
52
|
+
<View style={[{flex: 1, backgroundColor: '#000'}, containerStyle]} />
|
|
93
53
|
);
|
|
94
54
|
};
|
|
95
55
|
|
|
96
56
|
export default MaxVideoView;
|
|
97
|
-
|
|
98
|
-
const style = StyleSheet.create({
|
|
99
|
-
containerStyle: {flex: 1, backgroundColor: '#000'},
|
|
100
|
-
});
|
|
@@ -1,74 +1,46 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import {View, ViewStyle, StyleSheet} from 'react-native';
|
|
2
|
+
import {RtcLocalView, RtcRemoteView, VideoRenderMode} from 'react-native-agora';
|
|
3
|
+
import styles from '../Style';
|
|
4
|
+
import PropsContext, {RenderInterface} from '../Contexts/PropsContext';
|
|
5
|
+
import {View, ViewStyle} from 'react-native';
|
|
7
6
|
import useLocalUid from '../Utils/useLocalUid';
|
|
8
7
|
|
|
9
|
-
const LocalView =
|
|
10
|
-
const RemoteView =
|
|
8
|
+
const LocalView = RtcLocalView.SurfaceView;
|
|
9
|
+
const RemoteView = RtcRemoteView.SurfaceView;
|
|
11
10
|
|
|
12
11
|
interface MaxViewInterface {
|
|
13
|
-
user:
|
|
12
|
+
user: RenderInterface;
|
|
14
13
|
fallback?: React.ComponentType;
|
|
15
14
|
containerStyle?: ViewStyle;
|
|
16
|
-
landscapeMode?: boolean;
|
|
17
|
-
isFullView?: boolean;
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
21
|
-
const {rtcProps} = useContext(PropsContext);
|
|
22
|
-
|
|
18
|
+
const {styleProps, rtcProps} = useContext(PropsContext);
|
|
19
|
+
const {maxViewStyles} = styleProps || {};
|
|
23
20
|
const Fallback = props.fallback;
|
|
24
|
-
const {
|
|
25
|
-
containerStyle = {},
|
|
26
|
-
landscapeMode = false,
|
|
27
|
-
isFullView = false,
|
|
28
|
-
} = props;
|
|
21
|
+
const {containerStyle = {}} = props;
|
|
29
22
|
const localUid = useLocalUid();
|
|
30
|
-
//@ts-ignore
|
|
31
23
|
const uid = props.user.uid === rtcProps?.screenShareUid ? 1 : props.user.uid;
|
|
32
|
-
let landscapeModeStyle = {};
|
|
33
|
-
if (landscapeMode) {
|
|
34
|
-
landscapeModeStyle = {
|
|
35
|
-
transform: 'rotate(90deg)',
|
|
36
|
-
alignSelf: 'center',
|
|
37
|
-
alignItems: 'center',
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
24
|
return uid === localUid ? (
|
|
41
25
|
props.user.video ? (
|
|
42
|
-
<LocalView
|
|
43
|
-
style={containerStyle}
|
|
44
|
-
canvas={{
|
|
45
|
-
renderMode: isFullView
|
|
46
|
-
? RenderModeType.RenderModeAdaptive
|
|
47
|
-
: RenderModeType.RenderModeFit,
|
|
48
|
-
uid: 0,
|
|
49
|
-
}}
|
|
50
|
-
/>
|
|
26
|
+
<LocalView style={containerStyle} renderMode={VideoRenderMode.Fit} />
|
|
51
27
|
) : Fallback ? (
|
|
52
28
|
<Fallback />
|
|
53
29
|
) : (
|
|
54
|
-
<View style={[
|
|
30
|
+
<View style={[{flex: 1, backgroundColor: '#000'}, containerStyle]} />
|
|
55
31
|
)
|
|
56
32
|
) : (
|
|
57
33
|
<>
|
|
58
34
|
<div
|
|
59
|
-
// eslint-disable-next-line react-native/no-inline-styles
|
|
60
35
|
style={{
|
|
61
36
|
flex: 1,
|
|
62
37
|
overflow: 'hidden',
|
|
63
38
|
display: props.user.video ? 'flex' : 'none',
|
|
64
|
-
...landscapeModeStyle,
|
|
65
39
|
}}>
|
|
66
40
|
<RemoteView
|
|
67
41
|
style={containerStyle}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
uid: uid as number,
|
|
71
|
-
}}
|
|
42
|
+
uid={uid as number}
|
|
43
|
+
renderMode={VideoRenderMode.Fit}
|
|
72
44
|
/>
|
|
73
45
|
</div>
|
|
74
46
|
{props.user.video ? (
|
|
@@ -78,7 +50,9 @@ const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
|
78
50
|
{Fallback ? (
|
|
79
51
|
<Fallback />
|
|
80
52
|
) : (
|
|
81
|
-
<View
|
|
53
|
+
<View
|
|
54
|
+
style={[{flex: 1, backgroundColor: '#000'}, containerStyle]}
|
|
55
|
+
/>
|
|
82
56
|
)}
|
|
83
57
|
</>
|
|
84
58
|
)}
|
|
@@ -87,7 +61,3 @@ const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
|
87
61
|
};
|
|
88
62
|
|
|
89
63
|
export default MaxVideoView;
|
|
90
|
-
|
|
91
|
-
const style = StyleSheet.create({
|
|
92
|
-
containerStyle: {flex: 1, backgroundColor: '#000'},
|
|
93
|
-
});
|