agora-appbuilder-core 4.0.27 → 4.0.28-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 +2 -2
- package/template/_package-lock.json +10 -7
- package/template/agora-rn-uikit/src/Reducer/UserOffline.ts +9 -0
- package/template/bridge/rtm/web/index.ts +44 -26
- package/template/customization-api/app-state.ts +1 -0
- package/template/customization-api/atoms.ts +8 -0
- package/template/customization-api/index.ts +1 -0
- package/template/customization-api/sub-components.ts +4 -1
- package/template/customization-api/temp.ts +1 -2
- package/template/customization-api/typeDefinition.ts +8 -0
- package/template/customization-api/types.ts +3 -0
- package/template/customization-api/utils.ts +10 -1
- package/template/defaultConfig.js +2 -2
- package/template/ios/HelloWorld.xcodeproj/project.pbxproj +102 -50
- package/template/ios/HelloWorld.xcodeproj/xcshareddata/xcschemes/ScreenSharing.xcscheme +95 -0
- package/template/ios/Podfile +1 -1
- package/template/ios/Podfile.lock +200 -44
- package/template/ios/ScreenSharing/SampleHandler.h +2 -6
- package/template/ios/ScreenSharing/SampleHandler.m +17 -48
- package/template/package-lock.json +10 -7
- package/template/package.json +1 -1
- package/template/src/AppWrapper.tsx +2 -2
- package/template/src/assets/selection.json +3491 -1
- package/template/src/atoms/ActionMenu.tsx +96 -113
- package/template/src/atoms/LinkButton.tsx +4 -3
- package/template/src/atoms/ToolbarItem.tsx +36 -22
- package/template/src/atoms/ToolbarPreset.tsx +18 -3
- package/template/src/components/Controls.tsx +72 -49
- package/template/src/components/CustomSidePanel.tsx +82 -0
- package/template/src/components/EventsConfigure.tsx +11 -27
- package/template/src/components/Navbar.tsx +51 -86
- package/template/src/components/NavbarMobile.tsx +27 -3
- package/template/src/components/PinnedVideo.tsx +9 -0
- package/template/src/components/RTMConfigure.tsx +69 -1
- package/template/src/components/Settings.tsx +6 -29
- package/template/src/components/chat/chatConfigure.native.tsx +123 -119
- package/template/src/components/chat/chatConfigure.tsx +59 -46
- package/template/src/components/chat-messages/useChatMessages.tsx +5 -4
- package/template/src/components/chat-ui/useChatUIControls.tsx +4 -1
- package/template/src/components/livestream/views/LiveStreamControls.tsx +2 -1
- package/template/src/components/participants/UserActionMenuOptions.tsx +10 -10
- package/template/src/components/virtual-background/VBButton.tsx +5 -7
- package/template/src/language/default-labels/videoCallScreenLabels.ts +9 -2
- package/template/src/language/i18nTypes.ts +1 -1
- package/template/src/pages/video-call/ActionSheet.native.tsx +110 -34
- package/template/src/pages/video-call/ActionSheet.tsx +109 -27
- package/template/src/pages/video-call/ActionSheetContent.tsx +67 -49
- package/template/src/pages/video-call/ActionSheetHandle.tsx +12 -2
- package/template/src/pages/video-call/SidePanelHeader.tsx +28 -2
- package/template/src/pages/video-call/VideoCallScreen.tsx +70 -16
- package/template/src/pages/video-call/VideoRenderer.tsx +1 -0
- package/template/src/rtm-events-api/Events.ts +37 -3
- package/template/src/rtm-events-api/LocalEvents.ts +1 -0
- package/template/src/rtm-events-api/types.ts +5 -0
- package/template/src/subComponents/ChatBubble.tsx +15 -1
- package/template/src/subComponents/ChatInput.tsx +18 -7
- package/template/src/subComponents/CopyJoinInfo.tsx +5 -13
- package/template/src/subComponents/LayoutIconButton.tsx +6 -14
- package/template/src/subComponents/LocalAudioMute.tsx +7 -11
- package/template/src/subComponents/LocalEndCall.tsx +6 -4
- package/template/src/subComponents/LocalSwitchCamera.tsx +5 -4
- package/template/src/subComponents/LocalVideoMute.tsx +10 -36
- package/template/src/subComponents/Recording.tsx +4 -10
- package/template/src/subComponents/ScreenShareNotice.tsx +3 -0
- package/template/src/subComponents/SidePanelEnum.tsx +6 -6
- package/template/src/subComponents/caption/CaptionContainer.tsx +2 -2
- package/template/src/subComponents/caption/CaptionIcon.tsx +21 -17
- package/template/src/subComponents/caption/TranscriptIcon.tsx +6 -3
- package/template/src/subComponents/chat/ChatActionMenu.tsx +3 -3
- package/template/src/subComponents/chat/ChatAttachment.tsx +107 -51
- package/template/src/subComponents/chat/ChatEmoji.tsx +8 -4
- package/template/src/subComponents/chat/ChatSendButton.tsx +52 -30
- package/template/src/subComponents/chat/ChatUploadStatus.tsx +22 -3
- package/template/src/subComponents/chat/ImagePopup.tsx +4 -4
- package/template/src/subComponents/livestream/controls/LocalRaiseHand.tsx +14 -25
- package/template/src/subComponents/screenshare/ScreenshareButton.tsx +8 -7
- package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +333 -163
- package/template/src/utils/common.tsx +22 -9
- package/template/src/utils/useEndCall.ts +6 -4
- package/template/src/utils/useFullScreen.native.ts +12 -0
- package/template/src/utils/useOrientation.tsx +46 -46
- package/template/src/utils/useSidePanel.tsx +2 -2
- package/template/src/utils/useString.ts +6 -4
|
@@ -9,10 +9,21 @@
|
|
|
9
9
|
information visit https://appbuilder.agora.io.
|
|
10
10
|
*********************************************
|
|
11
11
|
*/
|
|
12
|
-
import React, {
|
|
12
|
+
import React, {
|
|
13
|
+
useCallback,
|
|
14
|
+
useContext,
|
|
15
|
+
useEffect,
|
|
16
|
+
useRef,
|
|
17
|
+
useState,
|
|
18
|
+
} from 'react';
|
|
13
19
|
import {Platform} from 'react-native';
|
|
14
20
|
import KeepAwake from 'react-native-keep-awake';
|
|
15
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
ClientRoleType,
|
|
23
|
+
DispatchContext,
|
|
24
|
+
PropsContext,
|
|
25
|
+
UidType,
|
|
26
|
+
} from '../../../agora-rn-uikit';
|
|
16
27
|
import {
|
|
17
28
|
getGridLayoutName,
|
|
18
29
|
getPinnedLayoutName,
|
|
@@ -20,28 +31,41 @@ import {
|
|
|
20
31
|
useSetPinnedLayout,
|
|
21
32
|
} from '../../pages/video-call/DefaultLayouts';
|
|
22
33
|
import {useScreenContext} from '../../components/contexts/ScreenShareContext';
|
|
23
|
-
import events from '../../rtm-events-api';
|
|
34
|
+
import events, {PersistanceLevel} from '../../rtm-events-api';
|
|
24
35
|
import {EventNames, EventActions} from '../../rtm-events';
|
|
25
|
-
import {useLayout, useContent, useRtc} from 'customization-api';
|
|
36
|
+
import {useLayout, useContent, useRtc, useRoomInfo} from 'customization-api';
|
|
26
37
|
import {filterObject} from '../../utils';
|
|
27
38
|
import {ScreenshareContext} from './useScreenshare';
|
|
28
39
|
import useMuteToggleLocal, {
|
|
29
40
|
MUTE_LOCAL_TYPE,
|
|
30
41
|
} from '../../utils/useMuteToggleLocal';
|
|
31
42
|
import {useLocalUserInfo} from '../../app-state/useLocalUserInfo';
|
|
32
|
-
import {
|
|
33
|
-
|
|
43
|
+
import {
|
|
44
|
+
LocalVideoStreamState,
|
|
45
|
+
PermissionType,
|
|
46
|
+
showRPSystemBroadcastPickerView,
|
|
47
|
+
VideoSourceType,
|
|
48
|
+
} from 'react-native-agora';
|
|
34
49
|
import {LogSource, logger} from '../../logger/AppBuilderLogger';
|
|
50
|
+
import {controlMessageEnum} from '../../components/ChatContext';
|
|
51
|
+
import {timeNow} from '../../rtm/utils';
|
|
52
|
+
import LocalEventEmitter, {
|
|
53
|
+
LocalEventsEnum,
|
|
54
|
+
} from '../../rtm-events-api/LocalEvents';
|
|
35
55
|
|
|
36
56
|
export const ScreenshareContextConsumer = ScreenshareContext.Consumer;
|
|
37
57
|
|
|
38
58
|
export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
|
|
59
|
+
const {
|
|
60
|
+
data: {channel: channelId},
|
|
61
|
+
} = useRoomInfo();
|
|
39
62
|
const [isScreenshareActive, setScreenshareActive] = useState(false);
|
|
40
|
-
const
|
|
41
|
-
|
|
63
|
+
const {
|
|
64
|
+
rtcProps: {screenShareUid, screenShareToken},
|
|
65
|
+
} = useContext(PropsContext);
|
|
42
66
|
const processRef = useRef(false);
|
|
43
|
-
const enableVideoRef = useRef(false);
|
|
44
67
|
const {RtcEngineUnsafe} = useRtc();
|
|
68
|
+
const engine = useRef(RtcEngineUnsafe);
|
|
45
69
|
const {dispatch} = useContext(DispatchContext);
|
|
46
70
|
const {defaultContent, activeUids, pinnedUid, secondaryPinnedUid} =
|
|
47
71
|
useContent();
|
|
@@ -80,6 +104,40 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
|
|
|
80
104
|
currentLayoutRef.current.currentLayout = currentLayout;
|
|
81
105
|
}, [currentLayout]);
|
|
82
106
|
|
|
107
|
+
const triggerChangeLayout = useCallback(
|
|
108
|
+
(pinned: boolean, screenShareUid?: UidType, parentUid?: UidType) => {
|
|
109
|
+
let layout = currentLayoutRef.current.currentLayout;
|
|
110
|
+
//screenshare is started set the layout to Pinned View
|
|
111
|
+
if (pinned && screenShareUid) {
|
|
112
|
+
isPinned.current = screenShareUid;
|
|
113
|
+
dispatch({
|
|
114
|
+
type: 'UserPin',
|
|
115
|
+
value: [screenShareUid],
|
|
116
|
+
});
|
|
117
|
+
if (parentUid && !secondaryPinnedUidRef.current.secondaryPinnedUid) {
|
|
118
|
+
dispatch({
|
|
119
|
+
type: 'UserSecondaryPin',
|
|
120
|
+
value: [parentUid],
|
|
121
|
+
});
|
|
122
|
+
} else if (
|
|
123
|
+
parentUid &&
|
|
124
|
+
secondaryPinnedUidRef.current.secondaryPinnedUid
|
|
125
|
+
) {
|
|
126
|
+
dispatch({
|
|
127
|
+
type: 'ActiveSpeaker',
|
|
128
|
+
value: [parentUid],
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
layout !== getPinnedLayoutName() && setPinnedLayout();
|
|
132
|
+
} else {
|
|
133
|
+
isPinned.current = 0;
|
|
134
|
+
//screenshare is stopped set the layout Grid View
|
|
135
|
+
layout !== getGridLayoutName() && changeLayout();
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
[changeLayout, dispatch, setPinnedLayout],
|
|
139
|
+
);
|
|
140
|
+
|
|
83
141
|
useEffect(() => {
|
|
84
142
|
const data = filterObject(screenShareData, ([k, v]) => v?.isActive);
|
|
85
143
|
if (data) {
|
|
@@ -103,69 +161,25 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
|
|
|
103
161
|
}
|
|
104
162
|
}
|
|
105
163
|
}
|
|
106
|
-
}, [activeUids, screenShareData]);
|
|
107
|
-
|
|
108
|
-
const triggerChangeLayout = (
|
|
109
|
-
pinned: boolean,
|
|
110
|
-
screenShareUid?: UidType,
|
|
111
|
-
parentUid?: UidType,
|
|
112
|
-
) => {
|
|
113
|
-
let layout = currentLayoutRef.current.currentLayout;
|
|
114
|
-
//screenshare is started set the layout to Pinned View
|
|
115
|
-
if (pinned && screenShareUid) {
|
|
116
|
-
isPinned.current = screenShareUid;
|
|
117
|
-
dispatch({
|
|
118
|
-
type: 'UserPin',
|
|
119
|
-
value: [screenShareUid],
|
|
120
|
-
});
|
|
121
|
-
if (parentUid && !secondaryPinnedUidRef.current.secondaryPinnedUid) {
|
|
122
|
-
dispatch({
|
|
123
|
-
type: 'UserSecondaryPin',
|
|
124
|
-
value: [parentUid],
|
|
125
|
-
});
|
|
126
|
-
} else if (
|
|
127
|
-
parentUid &&
|
|
128
|
-
secondaryPinnedUidRef.current.secondaryPinnedUid
|
|
129
|
-
) {
|
|
130
|
-
dispatch({
|
|
131
|
-
type: 'ActiveSpeaker',
|
|
132
|
-
value: [parentUid],
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
layout !== getPinnedLayoutName() && setPinnedLayout();
|
|
136
|
-
} else {
|
|
137
|
-
isPinned.current = 0;
|
|
138
|
-
//screenshare is stopped set the layout Grid View
|
|
139
|
-
layout !== getGridLayoutName() && changeLayout();
|
|
140
|
-
}
|
|
141
|
-
};
|
|
164
|
+
}, [activeUids, screenShareData, triggerChangeLayout]);
|
|
142
165
|
|
|
143
166
|
useEffect(() => {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
case LocalVideoStreamError.ExtensionCaptureDisconnected:
|
|
161
|
-
case LocalVideoStreamError.ScreenCapturePermissionDenied:
|
|
162
|
-
processRef.current = true;
|
|
163
|
-
setScreenshareActive(false);
|
|
164
|
-
break;
|
|
165
|
-
default:
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
167
|
+
/**
|
|
168
|
+
* When user kicked off by remote host then stop the screenshare
|
|
169
|
+
*/
|
|
170
|
+
const unsubKickUser = LocalEventEmitter.on(
|
|
171
|
+
LocalEventsEnum.USER_KICKED_OFF_BY_REMOTE_HOST,
|
|
172
|
+
() => {
|
|
173
|
+
stopScreenshare(false, true);
|
|
174
|
+
},
|
|
175
|
+
);
|
|
176
|
+
/**
|
|
177
|
+
* When host removed the screenshare
|
|
178
|
+
*/
|
|
179
|
+
const unsubKickScreenshare = events.on(
|
|
180
|
+
controlMessageEnum.kickScreenshare,
|
|
181
|
+
() => {
|
|
182
|
+
stopScreenshare(false, true);
|
|
169
183
|
},
|
|
170
184
|
);
|
|
171
185
|
const unsubScreenShareAttribute = events.on(
|
|
@@ -238,79 +252,269 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
|
|
|
238
252
|
|
|
239
253
|
return () => {
|
|
240
254
|
unsubScreenShareAttribute();
|
|
255
|
+
unsubKickScreenshare();
|
|
256
|
+
unsubKickUser.removeListener(
|
|
257
|
+
LocalEventsEnum.USER_KICKED_OFF_BY_REMOTE_HOST,
|
|
258
|
+
() => {},
|
|
259
|
+
);
|
|
241
260
|
};
|
|
242
261
|
}, []);
|
|
243
262
|
|
|
244
|
-
const
|
|
245
|
-
if (!
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
263
|
+
const publishScreenshare = useCallback(() => {
|
|
264
|
+
if (!channelId) {
|
|
265
|
+
console.error('channelId is invalid');
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (screenShareUid <= 0) {
|
|
269
|
+
console.error('uid2 is invalid');
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
try {
|
|
274
|
+
// publish screen share stream
|
|
275
|
+
//@ts-ignore
|
|
276
|
+
engine?.current?.joinChannelEx(
|
|
277
|
+
screenShareToken,
|
|
278
|
+
{channelId, localUid: screenShareUid},
|
|
279
|
+
{
|
|
280
|
+
autoSubscribeAudio: false,
|
|
281
|
+
autoSubscribeVideo: false,
|
|
282
|
+
publishMicrophoneTrack: false,
|
|
283
|
+
publishCameraTrack: false,
|
|
284
|
+
clientRoleType: ClientRoleType.ClientRoleBroadcaster,
|
|
285
|
+
publishScreenCaptureAudio: true,
|
|
286
|
+
publishScreenCaptureVideo: true,
|
|
287
|
+
},
|
|
288
|
+
);
|
|
289
|
+
} catch (error) {
|
|
290
|
+
logger.error(
|
|
264
291
|
LogSource.Internals,
|
|
265
292
|
'SCREENSHARE',
|
|
266
|
-
'screenshare
|
|
293
|
+
'native screenshare Error on joinChannelEx',
|
|
294
|
+
error,
|
|
267
295
|
);
|
|
268
296
|
}
|
|
269
|
-
};
|
|
297
|
+
}, [engine, screenShareToken, screenShareUid, channelId]);
|
|
270
298
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
299
|
+
const unpublishScreenshare = useCallback(() => {
|
|
300
|
+
try {
|
|
301
|
+
//@ts-ignore
|
|
302
|
+
engine?.current?.leaveChannelEx({channelId, localUid: screenShareUid});
|
|
303
|
+
} catch (error) {
|
|
304
|
+
logger.error(
|
|
305
|
+
LogSource.Internals,
|
|
306
|
+
'SCREENSHARE',
|
|
307
|
+
'native screenshare Error on leaveChannelEx',
|
|
308
|
+
error,
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
}, [engine, channelId, screenShareUid]);
|
|
312
|
+
|
|
313
|
+
const startScreenshare = useCallback(
|
|
314
|
+
async (captureAudio: boolean = false) => {
|
|
315
|
+
if (!isScreenshareActive) {
|
|
316
|
+
logger.log(
|
|
317
|
+
LogSource.Internals,
|
|
318
|
+
'SCREENSHARE',
|
|
319
|
+
'Trying to start native screenshare',
|
|
320
|
+
);
|
|
321
|
+
if (video) {
|
|
322
|
+
localMute(MUTE_LOCAL_TYPE.video);
|
|
323
|
+
}
|
|
324
|
+
try {
|
|
325
|
+
await engine.current.startScreenCapture({
|
|
326
|
+
captureVideo: true,
|
|
327
|
+
captureAudio,
|
|
328
|
+
});
|
|
329
|
+
if (Platform.OS === 'ios') {
|
|
330
|
+
// Show the picker view for screen share, ⚠️ only support for iOS 12+
|
|
331
|
+
await showRPSystemBroadcastPickerView(true);
|
|
332
|
+
}
|
|
333
|
+
} catch (error) {
|
|
334
|
+
logger.error(
|
|
335
|
+
LogSource.Internals,
|
|
336
|
+
'SCREENSHARE',
|
|
337
|
+
'native screenshare error on -> startScreenCapture',
|
|
338
|
+
error,
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
} else {
|
|
342
|
+
logger.debug(
|
|
343
|
+
LogSource.Internals,
|
|
344
|
+
'SCREENSHARE',
|
|
345
|
+
'native screenshare is already active',
|
|
346
|
+
);
|
|
280
347
|
}
|
|
281
|
-
},
|
|
282
|
-
|
|
348
|
+
},
|
|
349
|
+
[isScreenshareActive, video, localMute],
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
const ScreenshareStartedCallback = useCallback(() => {
|
|
353
|
+
logger.log(
|
|
354
|
+
LogSource.Internals,
|
|
355
|
+
'SCREENSHARE',
|
|
356
|
+
'native screenshare started.',
|
|
357
|
+
);
|
|
358
|
+
publishScreenshare();
|
|
359
|
+
processRef.current = true;
|
|
360
|
+
setScreenshareActive(true);
|
|
361
|
+
// 1. Set local state
|
|
362
|
+
setScreenShareData(prevState => {
|
|
363
|
+
return {
|
|
364
|
+
...prevState,
|
|
365
|
+
[screenShareUid]: {
|
|
366
|
+
name: defaultContentRef.current.defaultContent[screenShareUid]?.name,
|
|
367
|
+
isActive: true,
|
|
368
|
+
ts: timeNow(),
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
});
|
|
372
|
+
// 2. Inform everyone in the channel screenshare is actice
|
|
373
|
+
events.send(
|
|
374
|
+
EventNames.SCREENSHARE_ATTRIBUTE,
|
|
375
|
+
JSON.stringify({
|
|
376
|
+
action: EventActions.SCREENSHARE_STARTED,
|
|
377
|
+
value: timeNow(),
|
|
378
|
+
screenUidOfUser: screenShareUid,
|
|
379
|
+
}),
|
|
380
|
+
PersistanceLevel.Sender,
|
|
381
|
+
);
|
|
382
|
+
}, [publishScreenshare, screenShareUid, setScreenShareData]);
|
|
283
383
|
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
384
|
+
const ScreenshareStoppedCallback = useCallback(() => {
|
|
385
|
+
logger.log(
|
|
386
|
+
LogSource.Internals,
|
|
387
|
+
'SCREENSHARE',
|
|
388
|
+
'native screenshare stopped.',
|
|
389
|
+
);
|
|
390
|
+
processRef.current = true;
|
|
391
|
+
setScreenshareActive(false);
|
|
392
|
+
unpublishScreenshare();
|
|
393
|
+
events.send(
|
|
394
|
+
EventNames.SCREENSHARE_ATTRIBUTE,
|
|
395
|
+
JSON.stringify({
|
|
396
|
+
action: EventActions.SCREENSHARE_STOPPED,
|
|
397
|
+
value: 0,
|
|
398
|
+
}),
|
|
399
|
+
PersistanceLevel.Sender,
|
|
400
|
+
);
|
|
401
|
+
setScreenShareData(prevState => {
|
|
402
|
+
return {
|
|
403
|
+
...prevState,
|
|
404
|
+
[screenShareUid]: {
|
|
405
|
+
...prevState[screenShareUid],
|
|
406
|
+
isActive: false,
|
|
407
|
+
ts: 0,
|
|
408
|
+
},
|
|
409
|
+
};
|
|
410
|
+
});
|
|
411
|
+
//if local user stopped the screenshare then change layout to grid
|
|
412
|
+
//if user pinned somebody then don't triggerlayout change
|
|
413
|
+
if (!pinnedUidRef.current.pinnedUid) {
|
|
414
|
+
triggerChangeLayout(false);
|
|
415
|
+
}
|
|
416
|
+
if (screenShareUid === pinnedUidRef.current.pinnedUid) {
|
|
417
|
+
triggerChangeLayout(false);
|
|
418
|
+
dispatch({
|
|
419
|
+
type: 'UserPin',
|
|
420
|
+
value: [0],
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}, [
|
|
424
|
+
screenShareUid,
|
|
425
|
+
dispatch,
|
|
426
|
+
triggerChangeLayout,
|
|
427
|
+
setScreenShareData,
|
|
428
|
+
unpublishScreenshare,
|
|
429
|
+
]);
|
|
430
|
+
|
|
431
|
+
const stopScreenshare = useCallback(
|
|
432
|
+
async (enableVideo: boolean = false, forceStop: boolean = false) => {
|
|
433
|
+
if (isScreenshareActive || forceStop) {
|
|
434
|
+
logger.log(
|
|
435
|
+
LogSource.Internals,
|
|
436
|
+
'SCREENSHARE',
|
|
437
|
+
'Trying to stop native screenshare',
|
|
438
|
+
);
|
|
439
|
+
try {
|
|
440
|
+
engine?.current?.stopScreenCapture();
|
|
441
|
+
} catch (error) {
|
|
442
|
+
logger.error(
|
|
443
|
+
LogSource.Internals,
|
|
444
|
+
'SCREENSHARE',
|
|
445
|
+
'native screenshare error on -> stopScreenCapture',
|
|
446
|
+
error,
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
} else {
|
|
450
|
+
logger.debug(
|
|
451
|
+
LogSource.Internals,
|
|
452
|
+
'SCREENSHARE',
|
|
453
|
+
'native screenshare -> no screenshare is active',
|
|
454
|
+
);
|
|
295
455
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
456
|
+
},
|
|
457
|
+
[engine, isScreenshareActive],
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
const onLocalVideoStateChanged = useCallback(
|
|
461
|
+
(source: VideoSourceType, state: LocalVideoStreamState, error) => {
|
|
462
|
+
logger.log(
|
|
299
463
|
LogSource.Internals,
|
|
300
464
|
'SCREENSHARE',
|
|
301
|
-
'
|
|
465
|
+
'native screenshare -> onLocalVideoStateChanged',
|
|
466
|
+
{source, state, error},
|
|
302
467
|
);
|
|
303
|
-
|
|
304
|
-
|
|
468
|
+
if (source === VideoSourceType.VideoSourceScreen) {
|
|
469
|
+
switch (state) {
|
|
470
|
+
case LocalVideoStreamState.LocalVideoStreamStateStopped:
|
|
471
|
+
case LocalVideoStreamState.LocalVideoStreamStateFailed:
|
|
472
|
+
ScreenshareStoppedCallback();
|
|
473
|
+
break;
|
|
474
|
+
case LocalVideoStreamState.LocalVideoStreamStateCapturing:
|
|
475
|
+
case LocalVideoStreamState.LocalVideoStreamStateEncoding:
|
|
476
|
+
ScreenshareStartedCallback();
|
|
477
|
+
break;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
[ScreenshareStoppedCallback, ScreenshareStartedCallback],
|
|
482
|
+
);
|
|
305
483
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
logger.log(
|
|
484
|
+
const onPermissionError = useCallback(
|
|
485
|
+
(permissionType: PermissionType) => {
|
|
486
|
+
logger.error(
|
|
310
487
|
LogSource.Internals,
|
|
311
488
|
'SCREENSHARE',
|
|
312
|
-
'native screenshare
|
|
489
|
+
'native screenshare -> onPermissionError',
|
|
490
|
+
permissionType,
|
|
313
491
|
);
|
|
492
|
+
// ⚠️ You should call stopScreenCapture if received the event with permissionType ScreenCapture,
|
|
493
|
+
// otherwise you can not startScreenCapture again
|
|
494
|
+
stopScreenshare();
|
|
495
|
+
},
|
|
496
|
+
[stopScreenshare],
|
|
497
|
+
);
|
|
498
|
+
|
|
499
|
+
useEffect(() => {
|
|
500
|
+
engine.current.addListener(
|
|
501
|
+
'onLocalVideoStateChanged',
|
|
502
|
+
onLocalVideoStateChanged,
|
|
503
|
+
);
|
|
504
|
+
engine.current.addListener('onPermissionError', onPermissionError);
|
|
505
|
+
|
|
506
|
+
const engineCopy = engine.current;
|
|
507
|
+
return () => {
|
|
508
|
+
engineCopy.removeListener(
|
|
509
|
+
'onLocalVideoStateChanged',
|
|
510
|
+
onLocalVideoStateChanged,
|
|
511
|
+
);
|
|
512
|
+
engineCopy.removeListener('onPermissionError', onPermissionError);
|
|
513
|
+
};
|
|
514
|
+
}, [engine, onLocalVideoStateChanged, onPermissionError]);
|
|
515
|
+
|
|
516
|
+
useEffect(() => {
|
|
517
|
+
if (processRef?.current) {
|
|
314
518
|
if (isScreenshareActive) {
|
|
315
519
|
//to increase the performance - stop incoming video stream
|
|
316
520
|
logger.log(
|
|
@@ -318,53 +522,19 @@ export const ScreenshareConfigure = (props: {children: React.ReactNode}) => {
|
|
|
318
522
|
'SCREENSHARE',
|
|
319
523
|
'muting all remote video streams[muteAllRemoteVideoStreams(true)] to increase the performance',
|
|
320
524
|
);
|
|
321
|
-
RtcEngineUnsafe
|
|
322
|
-
|
|
323
|
-
//since native screenshare uses local user video
|
|
324
|
-
//we need to turn on video if its off.
|
|
325
|
-
//otherwise remote user can't see the screen shared from the mobile
|
|
326
|
-
if (!video) {
|
|
327
|
-
localMute(MUTE_LOCAL_TYPE.video);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
//native screenshare is stopped
|
|
331
|
-
else {
|
|
332
|
-
logger.log(
|
|
333
|
-
LogSource.Internals,
|
|
334
|
-
'SCREENSHARE',
|
|
335
|
-
'native screenshare is stopped',
|
|
336
|
-
);
|
|
525
|
+
RtcEngineUnsafe?.muteAllRemoteVideoStreams(true);
|
|
526
|
+
} else {
|
|
337
527
|
//resume the incoming video stream
|
|
338
528
|
logger.log(
|
|
339
529
|
LogSource.Internals,
|
|
340
530
|
'SCREENSHARE',
|
|
341
531
|
'resume all remote video streams[muteAllRemoteVideoStreams(false)]',
|
|
342
532
|
);
|
|
343
|
-
RtcEngineUnsafe
|
|
344
|
-
|
|
345
|
-
//edge case - if screenshare is going on and user want to enable the video
|
|
346
|
-
//then we will inform the user to stop screenshare and start camera
|
|
347
|
-
//in that case if video is off then turned it on.
|
|
348
|
-
//if video is on - that's fine
|
|
349
|
-
if (enableVideoRef.current) {
|
|
350
|
-
enableVideoRef.current = false;
|
|
351
|
-
if (!video) {
|
|
352
|
-
localMute(MUTE_LOCAL_TYPE.video);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
//regular usecase - once screenshare stopped will stop user video - since screenshare uses local user video
|
|
356
|
-
else {
|
|
357
|
-
//
|
|
358
|
-
if (video) {
|
|
359
|
-
localMute(MUTE_LOCAL_TYPE.video);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
533
|
+
RtcEngineUnsafe?.muteAllRemoteVideoStreams(false);
|
|
362
534
|
}
|
|
363
535
|
processRef.current = false;
|
|
364
536
|
}
|
|
365
|
-
}, [isScreenshareActive]);
|
|
366
|
-
|
|
367
|
-
const ScreenshareStoppedCallback = () => {};
|
|
537
|
+
}, [isScreenshareActive, RtcEngineUnsafe]);
|
|
368
538
|
|
|
369
539
|
return (
|
|
370
540
|
<ScreenshareContext.Provider
|
|
@@ -358,19 +358,32 @@ const updateToolbarDefaultConfig = (data, defaultItemsConfig) => {
|
|
|
358
358
|
});
|
|
359
359
|
};
|
|
360
360
|
|
|
361
|
-
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
361
|
+
function MergeMoreButtonFields(sourceArray, updateObject) {
|
|
362
|
+
const updateKeys = Object.keys(updateObject);
|
|
363
|
+
let result = [];
|
|
364
|
+
let sourceKeys = [];
|
|
365
|
+
sourceArray.forEach(i => {
|
|
366
|
+
sourceKeys.push(i?.componentName);
|
|
367
|
+
if (updateKeys?.indexOf(i?.componentName) !== -1) {
|
|
368
|
+
result.push({
|
|
366
369
|
...i,
|
|
367
|
-
...
|
|
368
|
-
};
|
|
370
|
+
...updateObject[i?.componentName],
|
|
371
|
+
});
|
|
369
372
|
} else {
|
|
370
|
-
|
|
373
|
+
result.push(i);
|
|
371
374
|
}
|
|
372
375
|
});
|
|
373
|
-
|
|
376
|
+
//inject new value
|
|
377
|
+
updateKeys.forEach(i => {
|
|
378
|
+
if (sourceKeys?.indexOf(i) === -1) {
|
|
379
|
+
result.push({
|
|
380
|
+
...updateObject[i],
|
|
381
|
+
componentName: i,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
return result;
|
|
386
|
+
}
|
|
374
387
|
|
|
375
388
|
export {
|
|
376
389
|
getSessionId,
|
|
@@ -33,9 +33,10 @@ const useEndCall = () => {
|
|
|
33
33
|
|
|
34
34
|
return async () => {
|
|
35
35
|
try {
|
|
36
|
-
|
|
36
|
+
beforeEndCall &&
|
|
37
|
+
(await beforeEndCall(isHost, history as unknown as History));
|
|
37
38
|
} catch (error) {
|
|
38
|
-
console.log('debugging error on beforeEndCall');
|
|
39
|
+
console.log('debugging error on beforeEndCall', error);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
setTimeout(() => {
|
|
@@ -62,9 +63,10 @@ const useEndCall = () => {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
try {
|
|
65
|
-
|
|
66
|
+
afterEndCall &&
|
|
67
|
+
(await afterEndCall(isHost, history as unknown as History));
|
|
66
68
|
} catch (error) {
|
|
67
|
-
console.log('debugging error on afterEndCall');
|
|
69
|
+
console.log('debugging error on afterEndCall', error);
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const useFullScreen = () => {
|
|
2
|
+
const requestFullscreen = async () => {
|
|
3
|
+
console.error('Full screen API not supported for native');
|
|
4
|
+
return Promise.reject(false);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const exitFullScreen = () => {
|
|
8
|
+
console.error('Full screen API not supported for native');
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return {requestFullscreen, exitFullScreen};
|
|
12
|
+
};
|