agora-appbuilder-core 4.0.0-api.7 → 4.0.0-api.9
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 +3 -3
- package/template/_package-lock.json +5911 -4861
- package/template/agora-rn-uikit/.eslintrc.js +5 -0
- package/template/agora-rn-uikit/package.json +14 -14
- package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +41 -22
- package/template/agora-rn-uikit/src/Contexts/RtcContext.tsx +2 -2
- package/template/agora-rn-uikit/src/Rtc/Create.tsx +90 -57
- package/template/agora-rn-uikit/src/Rtc/Join.tsx +20 -16
- package/template/agora-rn-uikit/src/RtcConfigure.tsx +10 -10
- package/template/agora-rn-uikit/src/Utils/isBotUser.ts +15 -0
- package/template/agora-rn-uikit/src/Utils/quality.tsx +8 -0
- package/template/agora-rn-uikit/src/Views/MaxVideoView.native.tsx +32 -16
- package/template/agora-rn-uikit/src/Views/MaxVideoView.tsx +25 -14
- package/template/agora-rn-uikit/src/Views/MinVideoView.tsx +15 -9
- package/template/agora-rn-uikit/src/index.ts +1 -1
- package/template/bridge/rtc/webNg/RtcEngine.ts +73 -58
- package/template/bridge/rtc/webNg/{SurfaceView.tsx → RtcSurfaceView.tsx} +20 -26
- package/template/bridge/rtc/webNg/Types.ts +20 -5
- package/template/bridge/rtc/webNg/index.ts +9 -13
- package/template/customization-api/temp.ts +2 -2
- package/template/customization-api/typeDefinition.ts +1 -2
- package/template/customization-api/utils.ts +1 -2
- package/template/index.js +1 -0
- package/template/ios/HelloWorld/HelloWorldDebug.entitlements +10 -0
- package/template/ios/HelloWorld.xcodeproj/project.pbxproj +4 -0
- package/template/ios/Podfile +1 -1
- package/template/ios/Podfile.lock +72 -140
- package/template/package.json +5 -4
- package/template/src/App.tsx +58 -1
- package/template/src/AppRoutes.tsx +16 -3
- package/template/src/AppWrapper.tsx +21 -19
- package/template/src/components/Chat.tsx +17 -8
- package/template/src/components/ChatContext.ts +0 -2
- package/template/src/components/Controls.tsx +5 -5
- package/template/src/components/Controls1.native.tsx +7 -3
- package/template/src/components/DeviceConfigure.native.tsx +2 -2
- package/template/src/components/DeviceConfigure.tsx +2 -2
- package/template/src/components/EventsConfigure.tsx +13 -22
- package/template/src/components/GraphQLProvider.tsx +47 -30
- package/template/src/components/GridVideo.tsx +6 -2
- package/template/src/components/NetworkQualityContext.tsx +11 -5
- package/template/src/components/ParticipantsView.tsx +3 -3
- package/template/src/components/PinnedVideo.tsx +2 -2
- package/template/src/components/Precall.native.tsx +9 -6
- package/template/src/components/Precall.tsx +9 -6
- package/template/src/components/StorageContext.tsx +5 -2
- package/template/src/components/ToastComponent.tsx +7 -1
- package/template/src/components/contexts/LiveStreamDataContext.tsx +3 -3
- package/template/src/components/livestream/LiveStreamContext.tsx +42 -33
- package/template/src/components/livestream/Types.ts +2 -2
- package/template/src/components/participants/Participant.tsx +1 -1
- package/template/src/components/participants/UserActionMenuOptions.tsx +7 -2
- package/template/src/components/recording-bot/RecordingBotRoute.tsx +42 -0
- package/template/src/components/virtual-background/useVB.native.tsx +16 -19
- package/template/src/components/virtual-background/useVB.tsx +1 -1
- package/template/src/components/whiteboard/WhiteboardConfigure.native.tsx +11 -0
- package/template/src/components/whiteboard/WhiteboardConfigure.tsx +5 -0
- package/template/src/components/whiteboard/WhiteboardView.native.tsx +91 -12
- package/template/src/components/whiteboard/WhiteboardWidget.tsx +15 -4
- package/template/src/language/default-labels/precallScreenLabels.ts +5 -3
- package/template/src/language/default-labels/videoCallScreenLabels.ts +93 -41
- package/template/src/pages/VideoCall.tsx +39 -37
- package/template/src/pages/video-call/ActionSheetContent.tsx +4 -3
- package/template/src/pages/video-call/NameWithMicIcon.tsx +2 -1
- package/template/src/pages/video-call/VideoCallMobileView.tsx +26 -2
- package/template/src/pages/video-call/VideoCallScreen.tsx +32 -12
- package/template/src/pages/video-call/VideoCallScreenWrapper.tsx +41 -0
- package/template/src/pages/video-call/VideoComponent.tsx +5 -2
- package/template/src/pages/video-call/VideoRenderer.tsx +55 -34
- package/template/src/rtm-events/constants.ts +0 -2
- package/template/src/subComponents/ChatBubble.tsx +2 -0
- package/template/src/subComponents/LocalAudioMute.tsx +8 -47
- package/template/src/subComponents/LocalEndCall.tsx +5 -52
- package/template/src/subComponents/LocalSwitchCamera.tsx +3 -3
- package/template/src/subComponents/LocalVideoMute.tsx +8 -50
- package/template/src/subComponents/SelectDevice.tsx +5 -2
- package/template/src/subComponents/SelectDeviceSettings.backup.tsx +9 -6
- package/template/src/subComponents/caption/Caption.tsx +12 -10
- package/template/src/subComponents/caption/Transcript.tsx +13 -10
- package/template/src/subComponents/caption/useTranscriptDownload.native.ts +11 -16
- package/template/src/subComponents/caption/utils.ts +1 -0
- package/template/src/subComponents/livestream/ApprovedLiveStreamControlsView.tsx +2 -2
- package/template/src/subComponents/livestream/CurrentLiveStreamRequestsView.tsx +3 -2
- package/template/src/subComponents/livestream/controls/LocalRaiseHand.tsx +1 -1
- package/template/src/subComponents/recording/useIsRecordingBot.tsx +38 -0
- package/template/src/subComponents/recording/useRecording.tsx +176 -135
- package/template/src/subComponents/screenshare/ScreenshareButton.tsx +3 -3
- package/template/src/subComponents/screenshare/ScreenshareConfigure.tsx +1 -22
- package/template/src/utils/index.tsx +16 -5
- package/template/src/utils/useEndCall.ts +65 -0
- package/template/src/utils/useIsLocalUserSpeaking.ts +6 -1
- package/template/{bridge/rtc/webNg/LocalView.tsx → src/utils/useLocalAudio.ts} +24 -6
- package/template/src/utils/useMuteToggleLocal.ts +10 -5
- package/template/src/utils/useSearchParams.tsx +18 -0
- package/template/src/wasms/agora-virtual-background.wasm +0 -0
- package/template/src/utils/endCallEveryOne.ts +0 -7
- package/template/src/utils/useDisableButton.tsx +0 -37
|
@@ -4,18 +4,16 @@ import {
|
|
|
4
4
|
ContentStateInterface,
|
|
5
5
|
ActionType,
|
|
6
6
|
UidType,
|
|
7
|
-
CustomContentObjects,
|
|
8
7
|
CustomContentInferface,
|
|
9
8
|
} from './Contexts/RtcContext';
|
|
10
9
|
import {DispatchType} from './Contexts/DispatchContext';
|
|
11
10
|
import PropsContext, {
|
|
12
11
|
ToggleState,
|
|
13
|
-
RtcPropsInterface,
|
|
14
12
|
CallbacksInterface,
|
|
15
13
|
DualStreamMode,
|
|
16
14
|
PermissionState,
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
ChannelProfileType,
|
|
16
|
+
ClientRoleType,
|
|
19
17
|
} from './Contexts/PropsContext';
|
|
20
18
|
import {ContentProvider} from './Contexts/ContentContext';
|
|
21
19
|
import {actionTypeGuard} from './Utils/actionTypeGuard';
|
|
@@ -40,7 +38,7 @@ import Join from './Rtc/Join';
|
|
|
40
38
|
import useLocalUid from './Utils/useLocalUid';
|
|
41
39
|
import {DispatchProvider} from './Contexts/DispatchContext';
|
|
42
40
|
|
|
43
|
-
const RtcConfigure = (
|
|
41
|
+
const RtcConfigure = (outerProps: {children: React.ReactNode}) => {
|
|
44
42
|
const {callbacks, rtcProps, mode} = useContext(PropsContext);
|
|
45
43
|
let [dualStreamMode, setDualStreamMode] = useState<DualStreamMode>(
|
|
46
44
|
rtcProps?.initialDualStreamMode || DualStreamMode.DYNAMIC,
|
|
@@ -61,7 +59,7 @@ const RtcConfigure = (props: {children: React.ReactNode}) => {
|
|
|
61
59
|
videoForceDisabled: false,
|
|
62
60
|
},
|
|
63
61
|
},
|
|
64
|
-
activeUids: [localUid],
|
|
62
|
+
activeUids: rtcProps?.recordingBot ? [] : [localUid],
|
|
65
63
|
pinnedUid: undefined,
|
|
66
64
|
secondaryPinnedUid: undefined,
|
|
67
65
|
lastJoinedUid: 0,
|
|
@@ -73,6 +71,7 @@ const RtcConfigure = (props: {children: React.ReactNode}) => {
|
|
|
73
71
|
|
|
74
72
|
React.useEffect(() => {
|
|
75
73
|
setInitialState(JSON.parse(JSON.stringify(initialLocalState)));
|
|
74
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
75
|
}, []);
|
|
77
76
|
|
|
78
77
|
/**
|
|
@@ -415,7 +414,7 @@ const RtcConfigure = (props: {children: React.ReactNode}) => {
|
|
|
415
414
|
<Create dispatch={dispatch}>
|
|
416
415
|
{(engineRef, tracksReady) => (
|
|
417
416
|
<Join
|
|
418
|
-
precall={!rtcProps
|
|
417
|
+
precall={!rtcProps?.callActive}
|
|
419
418
|
preventJoin={rtcProps?.preventJoin}
|
|
420
419
|
engineRef={engineRef}
|
|
421
420
|
uidState={uidState}
|
|
@@ -434,8 +433,9 @@ const RtcConfigure = (props: {children: React.ReactNode}) => {
|
|
|
434
433
|
defaultContent: uidState.defaultContent,
|
|
435
434
|
activeUids:
|
|
436
435
|
//In livestreaming mode ->audience should not see their local video tile
|
|
437
|
-
mode
|
|
438
|
-
|
|
436
|
+
mode ===
|
|
437
|
+
ChannelProfileType.ChannelProfileLiveBroadcasting &&
|
|
438
|
+
rtcProps?.role === ClientRoleType.ClientRoleAudience
|
|
439
439
|
? [
|
|
440
440
|
...new Set(
|
|
441
441
|
uidState.activeUids.filter((i) => i !== localUid),
|
|
@@ -460,7 +460,7 @@ const RtcConfigure = (props: {children: React.ReactNode}) => {
|
|
|
460
460
|
: undefined,
|
|
461
461
|
lastJoinedUid: uidState.lastJoinedUid,
|
|
462
462
|
}}>
|
|
463
|
-
{
|
|
463
|
+
{outerProps.children}
|
|
464
464
|
</ContentProvider>
|
|
465
465
|
</RtcProvider>
|
|
466
466
|
</DispatchProvider>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function isBotUser(args: [uid: number, elapsed: number]): boolean {
|
|
2
|
+
// STT bot
|
|
3
|
+
if (args[0] === 111111) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
// Web Recording bot (userUid)
|
|
7
|
+
if (args[0] === 100000) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
// Web Recording bot (screenUid)
|
|
11
|
+
if (args[0] === 100001) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
RenderModeType,
|
|
4
|
+
RtcSurfaceView,
|
|
5
|
+
RtcTextureView,
|
|
6
|
+
} from 'react-native-agora';
|
|
3
7
|
import styles from '../Style';
|
|
4
8
|
import PropsContext, {ContentInterface} from '../Contexts/PropsContext';
|
|
5
|
-
import {
|
|
6
|
-
View,
|
|
7
|
-
ViewStyle,
|
|
8
|
-
useWindowDimensions,
|
|
9
|
-
Platform,
|
|
10
|
-
ViewProps,
|
|
11
|
-
} from 'react-native';
|
|
9
|
+
import {View, ViewStyle, Platform, ViewProps, StyleSheet} from 'react-native';
|
|
12
10
|
import useLocalUid from '../Utils/useLocalUid';
|
|
13
11
|
|
|
14
|
-
const LocalView =
|
|
15
|
-
let RemoteView =
|
|
12
|
+
const LocalView = RtcSurfaceView;
|
|
13
|
+
let RemoteView = RtcSurfaceView;
|
|
16
14
|
|
|
17
15
|
interface MaxViewInterface {
|
|
18
16
|
user: ContentInterface;
|
|
@@ -22,6 +20,13 @@ interface MaxViewInterface {
|
|
|
22
20
|
isFullView?: boolean;
|
|
23
21
|
}
|
|
24
22
|
|
|
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
|
+
|
|
25
30
|
const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
26
31
|
const {styleProps, rtcProps} = useContext(PropsContext);
|
|
27
32
|
const {maxViewStyles} = styleProps || {};
|
|
@@ -35,7 +40,7 @@ const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
|
35
40
|
//SurfaceView does not support transform
|
|
36
41
|
//TextureView only applicable to android
|
|
37
42
|
if (Platform.OS === 'android') {
|
|
38
|
-
RemoteView =
|
|
43
|
+
RemoteView = RtcTextureView;
|
|
39
44
|
}
|
|
40
45
|
landscapeModeStyle = {
|
|
41
46
|
flex: 1,
|
|
@@ -56,12 +61,17 @@ const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
|
56
61
|
...(maxViewStyles as object),
|
|
57
62
|
...containerStyle,
|
|
58
63
|
}}
|
|
59
|
-
|
|
64
|
+
canvas={{
|
|
65
|
+
renderMode: isFullView
|
|
66
|
+
? RenderModeType.RenderModeAdaptive
|
|
67
|
+
: RenderModeType.RenderModeFit,
|
|
68
|
+
uid: 0,
|
|
69
|
+
}}
|
|
60
70
|
/>
|
|
61
71
|
) : Fallback ? (
|
|
62
72
|
<Fallback />
|
|
63
73
|
) : (
|
|
64
|
-
<View style={[
|
|
74
|
+
<View style={[style.containerStyle, containerStyle]} />
|
|
65
75
|
)
|
|
66
76
|
) : props.user.video ? (
|
|
67
77
|
<RemoteView
|
|
@@ -71,14 +81,20 @@ const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
|
71
81
|
...containerStyle,
|
|
72
82
|
...landscapeModeStyle,
|
|
73
83
|
}}
|
|
74
|
-
|
|
75
|
-
|
|
84
|
+
canvas={{
|
|
85
|
+
renderMode: RenderModeType.RenderModeFit,
|
|
86
|
+
uid: uid as number,
|
|
87
|
+
}}
|
|
76
88
|
/>
|
|
77
89
|
) : Fallback ? (
|
|
78
90
|
<Fallback />
|
|
79
91
|
) : (
|
|
80
|
-
<View style={[
|
|
92
|
+
<View style={[style.containerStyle, containerStyle]} />
|
|
81
93
|
);
|
|
82
94
|
};
|
|
83
95
|
|
|
84
96
|
export default MaxVideoView;
|
|
97
|
+
|
|
98
|
+
const style = StyleSheet.create({
|
|
99
|
+
containerStyle: {flex: 1, backgroundColor: '#000'},
|
|
100
|
+
});
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
|
|
3
|
+
import {RenderModeType, RtcSurfaceView} from 'react-native-agora';
|
|
4
|
+
|
|
4
5
|
import PropsContext, {ContentInterface} from '../Contexts/PropsContext';
|
|
5
|
-
import {View, ViewStyle} from 'react-native';
|
|
6
|
+
import {View, ViewStyle, StyleSheet} from 'react-native';
|
|
6
7
|
import useLocalUid from '../Utils/useLocalUid';
|
|
7
8
|
|
|
8
|
-
const LocalView =
|
|
9
|
-
const RemoteView =
|
|
9
|
+
const LocalView = RtcSurfaceView;
|
|
10
|
+
const RemoteView = RtcSurfaceView;
|
|
10
11
|
|
|
11
12
|
interface MaxViewInterface {
|
|
12
13
|
user: ContentInterface;
|
|
@@ -17,8 +18,8 @@ interface MaxViewInterface {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
20
|
-
const {
|
|
21
|
-
|
|
21
|
+
const {rtcProps} = useContext(PropsContext);
|
|
22
|
+
|
|
22
23
|
const Fallback = props.fallback;
|
|
23
24
|
const {
|
|
24
25
|
containerStyle = {},
|
|
@@ -40,16 +41,22 @@ const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
|
40
41
|
props.user.video ? (
|
|
41
42
|
<LocalView
|
|
42
43
|
style={containerStyle}
|
|
43
|
-
|
|
44
|
+
canvas={{
|
|
45
|
+
renderMode: isFullView
|
|
46
|
+
? RenderModeType.RenderModeAdaptive
|
|
47
|
+
: RenderModeType.RenderModeFit,
|
|
48
|
+
uid: 0,
|
|
49
|
+
}}
|
|
44
50
|
/>
|
|
45
51
|
) : Fallback ? (
|
|
46
52
|
<Fallback />
|
|
47
53
|
) : (
|
|
48
|
-
<View style={[
|
|
54
|
+
<View style={[style.containerStyle, containerStyle]} />
|
|
49
55
|
)
|
|
50
56
|
) : (
|
|
51
57
|
<>
|
|
52
58
|
<div
|
|
59
|
+
// eslint-disable-next-line react-native/no-inline-styles
|
|
53
60
|
style={{
|
|
54
61
|
flex: 1,
|
|
55
62
|
overflow: 'hidden',
|
|
@@ -58,8 +65,10 @@ const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
|
58
65
|
}}>
|
|
59
66
|
<RemoteView
|
|
60
67
|
style={containerStyle}
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
canvas={{
|
|
69
|
+
renderMode: RenderModeType.RenderModeFit,
|
|
70
|
+
uid: uid as number,
|
|
71
|
+
}}
|
|
63
72
|
/>
|
|
64
73
|
</div>
|
|
65
74
|
{props.user.video ? (
|
|
@@ -69,9 +78,7 @@ const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
|
69
78
|
{Fallback ? (
|
|
70
79
|
<Fallback />
|
|
71
80
|
) : (
|
|
72
|
-
<View
|
|
73
|
-
style={[{flex: 1, backgroundColor: '#000'}, containerStyle]}
|
|
74
|
-
/>
|
|
81
|
+
<View style={[style.containerStyle, containerStyle]} />
|
|
75
82
|
)}
|
|
76
83
|
</>
|
|
77
84
|
)}
|
|
@@ -80,3 +87,7 @@ const MaxVideoView: React.FC<MaxViewInterface> = (props) => {
|
|
|
80
87
|
};
|
|
81
88
|
|
|
82
89
|
export default MaxVideoView;
|
|
90
|
+
|
|
91
|
+
const style = StyleSheet.create({
|
|
92
|
+
containerStyle: {flex: 1, backgroundColor: '#000'},
|
|
93
|
+
});
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
/* eslint-disable react-native/no-inline-styles */
|
|
1
2
|
import React, {useState, useContext} from 'react';
|
|
2
3
|
import {View, TouchableOpacity, Image} from 'react-native';
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
import {RenderModeType, RtcSurfaceView} from 'react-native-agora';
|
|
4
6
|
import styles from '../Style';
|
|
5
7
|
import icons from '../Controls/Icons';
|
|
6
8
|
import RemoteControls from '../Controls/RemoteControls';
|
|
7
9
|
import PropsContext, {ContentInterface} from '../Contexts/PropsContext';
|
|
8
10
|
import useLocalUid from '../Utils/useLocalUid';
|
|
9
11
|
|
|
10
|
-
const LocalView =
|
|
11
|
-
const RemoteView =
|
|
12
|
+
const LocalView = RtcSurfaceView;
|
|
13
|
+
const RemoteView = RtcSurfaceView;
|
|
12
14
|
|
|
13
15
|
interface MinViewInterface {
|
|
14
16
|
user: ContentInterface;
|
|
@@ -33,7 +35,7 @@ const MinVideoView: React.FC<MinViewInterface> = (props) => {
|
|
|
33
35
|
props.user.video ? (
|
|
34
36
|
<LocalView
|
|
35
37
|
style={{...styles.minView, ...(minViewStyles as object)}}
|
|
36
|
-
|
|
38
|
+
canvas={{renderMode: RenderModeType.RenderModeHidden, uid: 0}}
|
|
37
39
|
zOrderMediaOverlay={true}
|
|
38
40
|
/>
|
|
39
41
|
) : (
|
|
@@ -49,8 +51,10 @@ const MinVideoView: React.FC<MinViewInterface> = (props) => {
|
|
|
49
51
|
) : (
|
|
50
52
|
<RemoteView
|
|
51
53
|
style={{...styles.minView, ...(minViewStyles as object)}}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
canvas={{
|
|
55
|
+
renderMode: RenderModeType.RenderModeHidden,
|
|
56
|
+
uid: uid as number,
|
|
57
|
+
}}
|
|
54
58
|
zOrderMediaOverlay={true}
|
|
55
59
|
/>
|
|
56
60
|
)}
|
|
@@ -58,14 +62,16 @@ const MinVideoView: React.FC<MinViewInterface> = (props) => {
|
|
|
58
62
|
) : uid === localUid ? (
|
|
59
63
|
<LocalView
|
|
60
64
|
style={{...styles.minView, ...(minViewStyles as object)}}
|
|
61
|
-
|
|
65
|
+
canvas={{renderMode: RenderModeType.RenderModeHidden, uid: 0}}
|
|
62
66
|
zOrderMediaOverlay={true}
|
|
63
67
|
/>
|
|
64
68
|
) : (
|
|
65
69
|
<RemoteView
|
|
66
70
|
style={{...styles.minView, ...(minViewStyles as object)}}
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
canvas={{
|
|
72
|
+
renderMode: RenderModeType.RenderModeHidden,
|
|
73
|
+
uid: uid as number,
|
|
74
|
+
}}
|
|
69
75
|
zOrderMediaOverlay={true}
|
|
70
76
|
/>
|
|
71
77
|
)}
|
|
@@ -42,7 +42,7 @@ export type {
|
|
|
42
42
|
PropsInterface,
|
|
43
43
|
} from './Contexts/PropsContext';
|
|
44
44
|
|
|
45
|
-
export {
|
|
45
|
+
export {ClientRoleType, ChannelProfileType} from './Contexts/PropsContext';
|
|
46
46
|
|
|
47
47
|
export {
|
|
48
48
|
default as RtcContext,
|
|
@@ -31,9 +31,11 @@ import type {
|
|
|
31
31
|
RtcEngineEvents,
|
|
32
32
|
Subscription,
|
|
33
33
|
} from 'react-native-agora/lib/typescript/src/common/RtcEvents';
|
|
34
|
+
|
|
35
|
+
import {IRtcEngine} from 'react-native-agora';
|
|
34
36
|
import {VideoProfile} from '../quality';
|
|
35
|
-
import {
|
|
36
|
-
import {role, mode} from './Types';
|
|
37
|
+
import {ChannelProfileType, ClientRoleType} from '../../../agora-rn-uikit';
|
|
38
|
+
import {role, mode, RtcEngineContext} from './Types';
|
|
37
39
|
import {LOG_ENABLED, GEO_FENCING} from '../../../config.json';
|
|
38
40
|
import {Platform} from 'react-native';
|
|
39
41
|
import isMobileOrTablet from '../../../src/utils/isMobileOrTablet';
|
|
@@ -170,6 +172,7 @@ interface RemoteStream {
|
|
|
170
172
|
audio?: IRemoteAudioTrack;
|
|
171
173
|
video?: IRemoteVideoTrack;
|
|
172
174
|
}
|
|
175
|
+
|
|
173
176
|
if ($config.GEO_FENCING) {
|
|
174
177
|
AgoraRTC.setArea({
|
|
175
178
|
areaCode: AREAS.GLOBAL,
|
|
@@ -191,15 +194,15 @@ export default class RtcEngine {
|
|
|
191
194
|
public client: any | IAgoraRTCClient;
|
|
192
195
|
public screenClient: any | IAgoraRTCClient;
|
|
193
196
|
public eventsMap = new Map<string, callbackType>([
|
|
194
|
-
['
|
|
195
|
-
['
|
|
196
|
-
['
|
|
197
|
-
['
|
|
198
|
-
['
|
|
199
|
-
['
|
|
200
|
-
['
|
|
201
|
-
['
|
|
202
|
-
['
|
|
197
|
+
['onUserJoined', () => null],
|
|
198
|
+
['onUserOffline', () => null],
|
|
199
|
+
['onJoinChannelSuccess', () => null],
|
|
200
|
+
['onScreenshareStopped', () => null],
|
|
201
|
+
['onRemoteAudioStateChanged', () => null],
|
|
202
|
+
['onRemoteVideoStateChanged', () => null],
|
|
203
|
+
['onNetworkQuality', () => null],
|
|
204
|
+
['onActiveSpeaker', () => null],
|
|
205
|
+
['onStreamMessage', () => null],
|
|
203
206
|
]);
|
|
204
207
|
public localStream: LocalStream = {};
|
|
205
208
|
public screenStream: ScreenStream = {};
|
|
@@ -220,17 +223,9 @@ export default class RtcEngine {
|
|
|
220
223
|
private usersVolumeLevel = [];
|
|
221
224
|
// Create channel profile and set it here
|
|
222
225
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
constructor(appId: string) {
|
|
226
|
+
initialize(context: RtcEngineContext) {
|
|
227
|
+
const {appId} = context;
|
|
226
228
|
this.appId = appId;
|
|
227
|
-
// this.AgoraRTC = AgoraRTC;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
static async create(appId: string): Promise<RtcEngine> {
|
|
231
|
-
let engine = new RtcEngine(appId);
|
|
232
|
-
window.engine = engine;
|
|
233
|
-
return engine;
|
|
234
229
|
}
|
|
235
230
|
|
|
236
231
|
getRemoteVideoStats(id: string) {
|
|
@@ -412,7 +407,7 @@ export default class RtcEngine {
|
|
|
412
407
|
|
|
413
408
|
if (this.isPublished === false) {
|
|
414
409
|
this.isPublished = true;
|
|
415
|
-
(this.eventsMap.get('
|
|
410
|
+
(this.eventsMap.get('onJoinChannelSuccess') as callbackType)();
|
|
416
411
|
}
|
|
417
412
|
}
|
|
418
413
|
} catch (e) {
|
|
@@ -425,19 +420,21 @@ export default class RtcEngine {
|
|
|
425
420
|
async joinChannel(
|
|
426
421
|
token: string,
|
|
427
422
|
channelName: string,
|
|
428
|
-
optionalInfo: string,
|
|
429
423
|
optionalUid: number,
|
|
424
|
+
_optionalInfo: {},
|
|
430
425
|
): Promise<void> {
|
|
431
426
|
// TODO create agora client here
|
|
432
427
|
this.client.on('user-joined', user => {
|
|
433
|
-
(this.eventsMap.get('
|
|
434
|
-
(this.eventsMap.get('
|
|
428
|
+
(this.eventsMap.get('onUserJoined') as callbackType)({}, user.uid);
|
|
429
|
+
(this.eventsMap.get('onRemoteVideoStateChanged') as callbackType)(
|
|
430
|
+
{},
|
|
435
431
|
user.uid,
|
|
436
432
|
0,
|
|
437
433
|
0,
|
|
438
434
|
0,
|
|
439
435
|
);
|
|
440
|
-
(this.eventsMap.get('
|
|
436
|
+
(this.eventsMap.get('onRemoteAudioStateChanged') as callbackType)(
|
|
437
|
+
{},
|
|
441
438
|
user.uid,
|
|
442
439
|
0,
|
|
443
440
|
0,
|
|
@@ -450,13 +447,14 @@ export default class RtcEngine {
|
|
|
450
447
|
if (this.remoteStreams.has(uid)) {
|
|
451
448
|
this.remoteStreams.delete(uid);
|
|
452
449
|
}
|
|
453
|
-
(this.eventsMap.get('
|
|
450
|
+
(this.eventsMap.get('onUserOffline') as callbackType)({}, uid);
|
|
454
451
|
// (this.eventsMap.get('UserJoined') as callbackType)(uid);
|
|
455
452
|
});
|
|
456
453
|
this.client.on('user-published', async (user, mediaType) => {
|
|
457
454
|
// Initiate the subscription
|
|
458
455
|
if (this.inScreenshare && user.uid === this.screenClient.uid) {
|
|
459
|
-
(this.eventsMap.get('
|
|
456
|
+
(this.eventsMap.get('onRemoteVideoStateChanged') as callbackType)(
|
|
457
|
+
{},
|
|
460
458
|
user.uid,
|
|
461
459
|
2,
|
|
462
460
|
0,
|
|
@@ -480,7 +478,8 @@ export default class RtcEngine {
|
|
|
480
478
|
.get(user.uid)
|
|
481
479
|
?.audio?.setPlaybackDevice(this.speakerDeviceId);
|
|
482
480
|
}
|
|
483
|
-
(this.eventsMap.get('
|
|
481
|
+
(this.eventsMap.get('onRemoteAudioStateChanged') as callbackType)(
|
|
482
|
+
{},
|
|
484
483
|
user.uid,
|
|
485
484
|
2,
|
|
486
485
|
0,
|
|
@@ -494,7 +493,8 @@ export default class RtcEngine {
|
|
|
494
493
|
...this.remoteStreams.get(user.uid),
|
|
495
494
|
video: videoTrack,
|
|
496
495
|
});
|
|
497
|
-
(this.eventsMap.get('
|
|
496
|
+
(this.eventsMap.get('onRemoteVideoStateChanged') as callbackType)(
|
|
497
|
+
{},
|
|
498
498
|
user.uid,
|
|
499
499
|
2,
|
|
500
500
|
0,
|
|
@@ -506,7 +506,8 @@ export default class RtcEngine {
|
|
|
506
506
|
if (mediaType === 'audio') {
|
|
507
507
|
const {audio, ...rest} = this.remoteStreams.get(user.uid);
|
|
508
508
|
this.remoteStreams.set(user.uid, rest);
|
|
509
|
-
(this.eventsMap.get('
|
|
509
|
+
(this.eventsMap.get('onRemoteAudioStateChanged') as callbackType)(
|
|
510
|
+
{},
|
|
510
511
|
user.uid,
|
|
511
512
|
0,
|
|
512
513
|
0,
|
|
@@ -515,7 +516,8 @@ export default class RtcEngine {
|
|
|
515
516
|
} else {
|
|
516
517
|
const {video, ...rest} = this.remoteStreams.get(user.uid);
|
|
517
518
|
this.remoteStreams.set(user.uid, rest);
|
|
518
|
-
(this.eventsMap.get('
|
|
519
|
+
(this.eventsMap.get('onRemoteVideoStateChanged') as callbackType)(
|
|
520
|
+
{},
|
|
519
521
|
user.uid,
|
|
520
522
|
0,
|
|
521
523
|
0,
|
|
@@ -567,13 +569,14 @@ export default class RtcEngine {
|
|
|
567
569
|
'network-quality',
|
|
568
570
|
async ({downlinkNetworkQuality, uplinkNetworkQuality}) => {
|
|
569
571
|
const networkQualityIndicatorCallback = this.eventsMap.get(
|
|
570
|
-
'
|
|
572
|
+
'onNetworkQuality',
|
|
571
573
|
) as callbackType;
|
|
572
574
|
|
|
573
575
|
networkQualityIndicatorCallback(
|
|
576
|
+
{},
|
|
574
577
|
0,
|
|
575
|
-
downlinkNetworkQuality,
|
|
576
578
|
uplinkNetworkQuality,
|
|
579
|
+
downlinkNetworkQuality,
|
|
577
580
|
);
|
|
578
581
|
|
|
579
582
|
const remoteUserNetworkQualities =
|
|
@@ -581,9 +584,10 @@ export default class RtcEngine {
|
|
|
581
584
|
|
|
582
585
|
Object.keys(remoteUserNetworkQualities).forEach(uid => {
|
|
583
586
|
networkQualityIndicatorCallback(
|
|
587
|
+
{},
|
|
584
588
|
uid,
|
|
585
|
-
remoteUserNetworkQualities[uid].downlinkNetworkQuality,
|
|
586
589
|
remoteUserNetworkQualities[uid].uplinkNetworkQuality,
|
|
590
|
+
remoteUserNetworkQualities[uid].downlinkNetworkQuality,
|
|
587
591
|
);
|
|
588
592
|
});
|
|
589
593
|
},
|
|
@@ -594,7 +598,7 @@ export default class RtcEngine {
|
|
|
594
598
|
console.log(
|
|
595
599
|
`stt-web: onStreamMessageCallback uid:${uid} , payload:${payload}`,
|
|
596
600
|
);
|
|
597
|
-
(this.eventsMap.get('
|
|
601
|
+
(this.eventsMap.get('onStreamMessage') as callbackType)(uid, payload);
|
|
598
602
|
});
|
|
599
603
|
|
|
600
604
|
await this.client.join(
|
|
@@ -628,15 +632,15 @@ export default class RtcEngine {
|
|
|
628
632
|
listener: RtcEngineEvents[EventType],
|
|
629
633
|
): Subscription {
|
|
630
634
|
if (
|
|
631
|
-
event === '
|
|
632
|
-
event === '
|
|
633
|
-
event === '
|
|
634
|
-
event === '
|
|
635
|
-
event === '
|
|
636
|
-
event === '
|
|
637
|
-
event === '
|
|
638
|
-
event === '
|
|
639
|
-
event === '
|
|
635
|
+
event === 'onUserJoined' ||
|
|
636
|
+
event === 'onUserOffline' ||
|
|
637
|
+
event === 'onJoinChannelSuccess' ||
|
|
638
|
+
event === 'onScreenshareStopped' ||
|
|
639
|
+
event === 'onRemoteAudioStateChanged' ||
|
|
640
|
+
event === 'onRemoteVideoStateChanged' ||
|
|
641
|
+
event === 'onNetworkQuality' ||
|
|
642
|
+
event === 'onActiveSpeaker' ||
|
|
643
|
+
event === 'onStreamMessage'
|
|
640
644
|
) {
|
|
641
645
|
this.eventsMap.set(event, listener as callbackType);
|
|
642
646
|
}
|
|
@@ -741,17 +745,21 @@ export default class RtcEngine {
|
|
|
741
745
|
return devices;
|
|
742
746
|
}
|
|
743
747
|
|
|
744
|
-
async setChannelProfile(profile:
|
|
748
|
+
async setChannelProfile(profile: ChannelProfileType): Promise<void> {
|
|
745
749
|
try {
|
|
746
750
|
this.client = AgoraRTC.createClient({
|
|
747
751
|
codec: 'vp8',
|
|
748
752
|
mode:
|
|
749
|
-
profile ===
|
|
753
|
+
profile === ChannelProfileType.ChannelProfileLiveBroadcasting
|
|
754
|
+
? mode.live
|
|
755
|
+
: mode.rtc,
|
|
750
756
|
});
|
|
751
757
|
this.screenClient = AgoraRTC.createClient({
|
|
752
758
|
codec: 'vp8',
|
|
753
759
|
mode:
|
|
754
|
-
profile ===
|
|
760
|
+
profile === ChannelProfileType.ChannelProfileLiveBroadcasting
|
|
761
|
+
? mode.live
|
|
762
|
+
: mode.rtc,
|
|
755
763
|
});
|
|
756
764
|
} catch (e) {
|
|
757
765
|
throw e;
|
|
@@ -759,11 +767,11 @@ export default class RtcEngine {
|
|
|
759
767
|
}
|
|
760
768
|
|
|
761
769
|
async setClientRole(
|
|
762
|
-
clientRole:
|
|
770
|
+
clientRole: ClientRoleType,
|
|
763
771
|
options?: ClientRoleOptions,
|
|
764
772
|
): Promise<void> {
|
|
765
773
|
try {
|
|
766
|
-
if (clientRole ==
|
|
774
|
+
if (clientRole == ClientRoleType.ClientRoleAudience) {
|
|
767
775
|
if (this.isJoined) {
|
|
768
776
|
// Unpublish the streams when role is changed to Audience
|
|
769
777
|
await this.client.unpublish();
|
|
@@ -773,7 +781,7 @@ export default class RtcEngine {
|
|
|
773
781
|
}
|
|
774
782
|
await this.client.setClientRole(role.audience, options);
|
|
775
783
|
await this.screenClient.setClientRole(role.audience, options);
|
|
776
|
-
} else if (clientRole ==
|
|
784
|
+
} else if (clientRole == ClientRoleType.ClientRoleBroadcaster) {
|
|
777
785
|
await this.client.setClientRole(role.host);
|
|
778
786
|
await this.screenClient.setClientRole(role.host);
|
|
779
787
|
}
|
|
@@ -947,13 +955,18 @@ export default class RtcEngine {
|
|
|
947
955
|
console.error('Please use enableEncryption instead');
|
|
948
956
|
}
|
|
949
957
|
|
|
950
|
-
async
|
|
958
|
+
// async removeAllListeners<EventType extends keyof RtcEngineEvents>(event: EventType) {
|
|
959
|
+
// this.client.removeAllListeners(eventName);
|
|
960
|
+
// }
|
|
961
|
+
|
|
962
|
+
async release(): Promise<void> {
|
|
951
963
|
if (this.inScreenshare) {
|
|
952
|
-
(this.eventsMap.get('
|
|
964
|
+
(this.eventsMap.get('onUserOffline') as callbackType)(
|
|
965
|
+
{},
|
|
953
966
|
this.screenClient.uid,
|
|
954
967
|
);
|
|
955
968
|
this.screenClient.leave();
|
|
956
|
-
(this.eventsMap.get('
|
|
969
|
+
(this.eventsMap.get('onScreenshareStopped') as callbackType)();
|
|
957
970
|
}
|
|
958
971
|
this.eventsMap.forEach((callback, event, map) => {
|
|
959
972
|
this.client.off(event, callback);
|
|
@@ -1063,7 +1076,8 @@ export default class RtcEngine {
|
|
|
1063
1076
|
);
|
|
1064
1077
|
|
|
1065
1078
|
this.screenStream.video.on('track-ended', () => {
|
|
1066
|
-
(this.eventsMap.get('
|
|
1079
|
+
(this.eventsMap.get('onUserOffline') as callbackType)(
|
|
1080
|
+
{},
|
|
1067
1081
|
this.screenClient.uid,
|
|
1068
1082
|
);
|
|
1069
1083
|
|
|
@@ -1073,15 +1087,16 @@ export default class RtcEngine {
|
|
|
1073
1087
|
this.screenStream.video?.close();
|
|
1074
1088
|
this.screenStream = {};
|
|
1075
1089
|
|
|
1076
|
-
(this.eventsMap.get('
|
|
1090
|
+
(this.eventsMap.get('onScreenshareStopped') as callbackType)();
|
|
1077
1091
|
this.inScreenshare = false;
|
|
1078
1092
|
});
|
|
1079
1093
|
} else {
|
|
1080
|
-
(this.eventsMap.get('
|
|
1094
|
+
(this.eventsMap.get('onUserOffline') as callbackType)(
|
|
1095
|
+
{},
|
|
1081
1096
|
this.screenClient.uid,
|
|
1082
1097
|
);
|
|
1083
1098
|
this.screenClient.leave();
|
|
1084
|
-
(this.eventsMap.get('
|
|
1099
|
+
(this.eventsMap.get('onScreenshareStopped') as callbackType)();
|
|
1085
1100
|
try {
|
|
1086
1101
|
this.screenStream.audio?.close();
|
|
1087
1102
|
this.screenStream.video?.close();
|