agora-appbuilder-core 4.0.0-spl.13 → 4.0.0-spl.15
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/src/Contexts/PropsContext.tsx +2 -0
- package/template/agora-rn-uikit/src/Rtc/Create.tsx +23 -2
- package/template/bridge/rtc/webNg/RtcEngine.ts +26 -6
- package/template/bridge/rtm/web/index.ts +2 -1
- package/template/src/components/SdkApiContext.tsx +2 -0
- package/template/src/pages/VideoCall.tsx +17 -10
package/package.json
CHANGED
|
@@ -113,6 +113,8 @@ export interface RtcPropsInterface {
|
|
|
113
113
|
| EncryptionMode.AES256XTS
|
|
114
114
|
| EncryptionMode.AES128ECB;
|
|
115
115
|
};
|
|
116
|
+
preferredCameraId?: string;
|
|
117
|
+
preferredMicrophoneId?: string;
|
|
116
118
|
// commented for v1 release
|
|
117
119
|
// lifecycle?: {
|
|
118
120
|
// useBeforeJoin?: () => () => Promise<void>;
|
|
@@ -34,6 +34,8 @@ const Create = ({
|
|
|
34
34
|
geoFencing = true,
|
|
35
35
|
audioRoom = false,
|
|
36
36
|
activeSpeaker = false,
|
|
37
|
+
preferredCameraId = '',
|
|
38
|
+
preferredMicrophoneId = '',
|
|
37
39
|
} = rtcProps || {};
|
|
38
40
|
let engine = useRef<RtcEngine>({} as RtcEngine);
|
|
39
41
|
// commented for v1 release
|
|
@@ -84,7 +86,16 @@ const Create = ({
|
|
|
84
86
|
value: [ToggleState.disabled],
|
|
85
87
|
});
|
|
86
88
|
} else {
|
|
87
|
-
|
|
89
|
+
if (Platform.OS === 'web') {
|
|
90
|
+
await engine.current.enableVideo(
|
|
91
|
+
//@ts-ignore
|
|
92
|
+
preferredCameraId,
|
|
93
|
+
//@ts-ignore
|
|
94
|
+
preferredMicrophoneId,
|
|
95
|
+
);
|
|
96
|
+
} else {
|
|
97
|
+
await engine.current.enableVideo();
|
|
98
|
+
}
|
|
88
99
|
dispatch({
|
|
89
100
|
type: 'LocalPermissionState',
|
|
90
101
|
value: [PermissionState.GRANTED_FOR_CAM_AND_MIC],
|
|
@@ -143,7 +154,17 @@ const Create = ({
|
|
|
143
154
|
value: [ToggleState.enabled],
|
|
144
155
|
});
|
|
145
156
|
} else {
|
|
146
|
-
|
|
157
|
+
if (Platform.OS === 'web') {
|
|
158
|
+
//@ts-ignore
|
|
159
|
+
await engine.current.enableVideo(
|
|
160
|
+
//@ts-ignore
|
|
161
|
+
preferredCameraId,
|
|
162
|
+
//@ts-ignore
|
|
163
|
+
preferredMicrophoneId,
|
|
164
|
+
);
|
|
165
|
+
} else {
|
|
166
|
+
await engine.current.enableVideo();
|
|
167
|
+
}
|
|
147
168
|
dispatch({
|
|
148
169
|
type: 'LocalPermissionState',
|
|
149
170
|
value: [PermissionState.GRANTED_FOR_CAM_AND_MIC],
|
|
@@ -25,6 +25,7 @@ import AgoraRTC, {
|
|
|
25
25
|
ClientRoleOptions,
|
|
26
26
|
CameraVideoTrackInitConfig,
|
|
27
27
|
MicrophoneAudioTrackInitConfig,
|
|
28
|
+
IMicrophoneAudioTrack,
|
|
28
29
|
} from 'agora-rtc-sdk-ng';
|
|
29
30
|
import type {
|
|
30
31
|
RtcEngineEvents,
|
|
@@ -240,7 +241,10 @@ export default class RtcEngine {
|
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
243
|
|
|
243
|
-
async enableVideo(
|
|
244
|
+
async enableVideo(
|
|
245
|
+
preferredCameraId?: string,
|
|
246
|
+
preferredMicrophoneId?: string,
|
|
247
|
+
): Promise<void> {
|
|
244
248
|
/**
|
|
245
249
|
* Issue: Backgrounding the browser or app causes the audio streaming to be cut off.
|
|
246
250
|
* Impact: All browsers and apps that use WKWebView on iOS 15.x, such as Safari and Chrome.
|
|
@@ -252,14 +256,16 @@ export default class RtcEngine {
|
|
|
252
256
|
|
|
253
257
|
const audioConfig: MicrophoneAudioTrackInitConfig = {
|
|
254
258
|
bypassWebAudio: Platform.OS == 'web' && isMobileOrTablet(),
|
|
255
|
-
|
|
259
|
+
microphoneId: preferredMicrophoneId,
|
|
256
260
|
};
|
|
257
261
|
const videoConfig: CameraVideoTrackInitConfig = {
|
|
258
262
|
encoderConfig: this.videoProfile,
|
|
259
|
-
|
|
263
|
+
cameraId: preferredCameraId,
|
|
260
264
|
};
|
|
261
265
|
try {
|
|
262
266
|
let [localAudio, localVideo] =
|
|
267
|
+
// If preferred devices are not present, the createTrack call will fallover to
|
|
268
|
+
// the catch block below.
|
|
263
269
|
await AgoraRTC.createMicrophoneAndCameraTracks(
|
|
264
270
|
audioConfig,
|
|
265
271
|
videoConfig,
|
|
@@ -277,9 +283,15 @@ export default class RtcEngine {
|
|
|
277
283
|
} catch (e) {
|
|
278
284
|
let audioError = false;
|
|
279
285
|
let videoError = false;
|
|
280
|
-
try {
|
|
281
|
-
let localAudio = await AgoraRTC.createMicrophoneAudioTrack(audioConfig);
|
|
282
286
|
|
|
287
|
+
try {
|
|
288
|
+
let localAudio: IMicrophoneAudioTrack;
|
|
289
|
+
try {
|
|
290
|
+
localAudio = await AgoraRTC.createMicrophoneAudioTrack(audioConfig);
|
|
291
|
+
} catch (e) {
|
|
292
|
+
videoConfig.microphoneId = '';
|
|
293
|
+
localAudio = await AgoraRTC.createMicrophoneAudioTrack(audioConfig);
|
|
294
|
+
}
|
|
283
295
|
this.localStream.audio = localAudio;
|
|
284
296
|
this.audioDeviceId = localAudio
|
|
285
297
|
?.getMediaStreamTrack()
|
|
@@ -288,8 +300,15 @@ export default class RtcEngine {
|
|
|
288
300
|
} catch (error) {
|
|
289
301
|
audioError = error;
|
|
290
302
|
}
|
|
303
|
+
|
|
291
304
|
try {
|
|
292
|
-
let localVideo
|
|
305
|
+
let localVideo: ICameraVideoTrack;
|
|
306
|
+
try {
|
|
307
|
+
localVideo = await AgoraRTC.createCameraVideoTrack(videoConfig);
|
|
308
|
+
} catch (e) {
|
|
309
|
+
videoConfig.cameraId = '';
|
|
310
|
+
localVideo = await AgoraRTC.createCameraVideoTrack(videoConfig);
|
|
311
|
+
}
|
|
293
312
|
this.localStream.video = localVideo;
|
|
294
313
|
this.videoDeviceId = localVideo
|
|
295
314
|
?.getMediaStreamTrack()
|
|
@@ -298,6 +317,7 @@ export default class RtcEngine {
|
|
|
298
317
|
} catch (error) {
|
|
299
318
|
videoError = error;
|
|
300
319
|
}
|
|
320
|
+
|
|
301
321
|
e.status = {audioError, videoError};
|
|
302
322
|
throw e;
|
|
303
323
|
// if (audioError && videoError) throw e;
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from 'agora-react-native-rtm/lib/typescript/src';
|
|
19
19
|
import {RtmClientEvents} from 'agora-react-native-rtm/lib/typescript/src/RtmEngine';
|
|
20
20
|
import AgoraRTM, {VERSION} from 'agora-rtm-sdk';
|
|
21
|
+
import RtmClient from 'agora-react-native-rtm';
|
|
21
22
|
// export {RtmAttribute}
|
|
22
23
|
//
|
|
23
24
|
interface RtmAttributePlaceholder {}
|
|
@@ -175,7 +176,7 @@ export default class RtmEngine {
|
|
|
175
176
|
}
|
|
176
177
|
|
|
177
178
|
async logout(): Promise<any> {
|
|
178
|
-
return this.client.logout();
|
|
179
|
+
return await this.client.logout();
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
async joinChannel(channelId: string): Promise<any> {
|
|
@@ -68,7 +68,7 @@ import {SdkApiContext, SDK_MEETING_TAG} from '../components/SdkApiContext';
|
|
|
68
68
|
import isSDK from '../utils/isSDK';
|
|
69
69
|
import {useSetMeetingInfo} from '../components/meeting-info/useSetMeetingInfo';
|
|
70
70
|
import SdkMuteToggleListener from '../components/SdkMuteToggleListener';
|
|
71
|
-
|
|
71
|
+
import StorageContext from '../components/StorageContext';
|
|
72
72
|
enum RnEncryptionEnum {
|
|
73
73
|
/**
|
|
74
74
|
* @deprecated
|
|
@@ -117,6 +117,15 @@ const VideoCall: React.FC = () => {
|
|
|
117
117
|
editName: false,
|
|
118
118
|
});
|
|
119
119
|
const {phrase} = useParams<{phrase: string}>();
|
|
120
|
+
|
|
121
|
+
const {store} = useContext(StorageContext);
|
|
122
|
+
const {
|
|
123
|
+
join: SdkJoinState,
|
|
124
|
+
microphoneDevice: sdkMicrophoneDevice,
|
|
125
|
+
cameraDevice: sdkCameraDevice,
|
|
126
|
+
clearState,
|
|
127
|
+
} = useContext(SdkApiContext);
|
|
128
|
+
|
|
120
129
|
// commented for v1 release
|
|
121
130
|
//const lifecycle = useCustomization((data) => data.lifecycle);
|
|
122
131
|
const [rtcProps, setRtcProps] = React.useState({
|
|
@@ -136,9 +145,12 @@ const VideoCall: React.FC = () => {
|
|
|
136
145
|
geoFencing: $config.GEO_FENCING,
|
|
137
146
|
audioRoom: $config.AUDIO_ROOM,
|
|
138
147
|
activeSpeaker: $config.ACTIVE_SPEAKER,
|
|
148
|
+
preferredCameraId:
|
|
149
|
+
sdkCameraDevice.deviceId || store?.activeDeviceId?.videoinput || null,
|
|
150
|
+
preferredMicrophoneId:
|
|
151
|
+
sdkMicrophoneDevice.deviceId || store?.activeDeviceId?.audioinput || null,
|
|
139
152
|
});
|
|
140
153
|
|
|
141
|
-
const {join: SdkJoinState, clearState} = useContext(SdkApiContext);
|
|
142
154
|
const history = useHistory();
|
|
143
155
|
const currentMeetingPhrase = useRef(history.location.pathname);
|
|
144
156
|
|
|
@@ -207,14 +219,12 @@ const VideoCall: React.FC = () => {
|
|
|
207
219
|
|
|
208
220
|
React.useEffect(() => {
|
|
209
221
|
if (isJoinDataFetched === true && !queryComplete) {
|
|
210
|
-
setRtcProps({
|
|
211
|
-
|
|
222
|
+
setRtcProps((prevRtcProps) => ({
|
|
223
|
+
...prevRtcProps,
|
|
212
224
|
channel: data.channel,
|
|
213
225
|
uid: data.uid,
|
|
214
226
|
token: data.token,
|
|
215
227
|
rtm: data.rtmToken,
|
|
216
|
-
dual: true,
|
|
217
|
-
profile: $config.PROFILE,
|
|
218
228
|
encryption: $config.ENCRYPTION_ENABLED
|
|
219
229
|
? {
|
|
220
230
|
key: data.encryptionSecret,
|
|
@@ -225,10 +235,7 @@ const VideoCall: React.FC = () => {
|
|
|
225
235
|
screenShareUid: data.screenShareUid,
|
|
226
236
|
screenShareToken: data.screenShareToken,
|
|
227
237
|
role: data.isHost ? ClientRole.Broadcaster : ClientRole.Audience,
|
|
228
|
-
|
|
229
|
-
audioRoom: $config.AUDIO_ROOM,
|
|
230
|
-
activeSpeaker: $config.ACTIVE_SPEAKER,
|
|
231
|
-
});
|
|
238
|
+
}));
|
|
232
239
|
|
|
233
240
|
// 1. Store the display name from API
|
|
234
241
|
// if (data.username) {
|