Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(call-integration): rely on ice connection to control outgoing calls (#17503)
Calinteodor6d30415ba577
diff --git a/react/features/base/conference/actionTypes.ts b/react/features/base/conference/actionTypes.tsindex 4b73da9401..6886e0bb2f 100644--- a/react/features/base/conference/actionTypes.ts+++ b/react/features/base/conference/actionTypes.ts@@ -32,6 +32,17 @@ export const CONFERENCE_FAILED = 'CONFERENCE_FAILED';*/export const CONFERENCE_JOINED = 'CONFERENCE_JOINED';+/**+ * The type of (redux) action which signals that the conference's ICE connection+ * was established (media is flowing).+ *+ * {+ * type: CONFERENCE_CONNECTION_ESTABLISHED,+ * conference: JitsiConference+ * }+ */+export const CONFERENCE_CONNECTION_ESTABLISHED = 'CONFERENCE_CONNECTION_ESTABLISHED';+/*** The type of (redux) action which signals that a specific conference joining is in progress.* A CONFERENCE_JOINED is guaranteed to follow.diff --git a/react/features/base/conference/actions.any.ts b/react/features/base/conference/actions.any.tsindex c384622d81..d142973f9c 100644--- a/react/features/base/conference/actions.any.ts+++ b/react/features/base/conference/actions.any.ts@@ -38,6 +38,7 @@ import { getBackendSafeRoomName } from '../util/uri';import {AUTH_STATUS_CHANGED,+ CONFERENCE_CONNECTION_ESTABLISHED,CONFERENCE_FAILED,CONFERENCE_JOINED,CONFERENCE_JOIN_IN_PROGRESS,@@ -126,6 +127,13 @@ function _addConferenceListeners(conference: IJitsiConference, dispatch: IStore[conference.on(JitsiConferenceEvents.CONFERENCE_JOIN_IN_PROGRESS,(..._args: any[]) => dispatch(conferenceJoinInProgress(conference)));+ // CONNECTION_ESTABLISHED is skipped when P2P wins the ICE race; CONNECTION_RESTORED covers it.+ conference.on(+ JitsiConferenceEvents.CONNECTION_ESTABLISHED,+ (..._args: any[]) => dispatch(conferenceConnectionEstablished(conference)));+ conference.on(+ JitsiConferenceEvents.CONNECTION_RESTORED,+ (..._args: any[]) => dispatch(conferenceConnectionEstablished(conference)));conference.on(JitsiConferenceEvents.CONFERENCE_LEFT,(..._args: any[]) => {@@ -427,6 +435,19 @@ export function conferenceJoinInProgress(conference: IJitsiConference) {};}+/**+ * Signals that the conference's ICE connection was established (media flowing).+ *+ * @param {JitsiConference} conference - The conference whose ICE connection was established.+ * @returns {{ type: CONFERENCE_CONNECTION_ESTABLISHED, conference: JitsiConference }}+ */+export function conferenceConnectionEstablished(conference: IJitsiConference) {+ return {+ type: CONFERENCE_CONNECTION_ESTABLISHED,+ conference+ };+}+/*** Signals that a specific conference has been left.*diff --git a/react/features/base/conference/reducer.ts b/react/features/base/conference/reducer.tsindex 0b19aae1c7..3160fe02d1 100644--- a/react/features/base/conference/reducer.ts+++ b/react/features/base/conference/reducer.ts@@ -12,6 +12,7 @@ import { assign, equals, set } from '../redux/functions';import {AUTH_STATUS_CHANGED,+ CONFERENCE_CONNECTION_ESTABLISHED,CONFERENCE_FAILED,CONFERENCE_JOINED,CONFERENCE_LEFT,@@ -41,6 +42,7 @@ const DEFAULT_STATE = {conference: undefined,dataChannelOpen: undefined,e2eeSupported: undefined,+ iceConnected: undefined,joining: undefined,leaving: undefined,locked: undefined,@@ -178,6 +180,7 @@ export interface IConferenceState {dataChannelOpen?: boolean;e2eeSupported?: boolean;error?: Error;+ iceConnected?: boolean;joining?: IJitsiConference;leaving?: IJitsiConference;lobbyError?: boolean;@@ -231,6 +234,9 @@ ReducerRegistry.register<IConferenceState>('features/base/conference',case CONFERENCE_JOINED:return _conferenceJoined(state, action);+ case CONFERENCE_CONNECTION_ESTABLISHED:+ return set(state, 'iceConnected', true);+case CONFERENCE_SUBJECT_CHANGED:return set(state, 'subject', action.subject);@@ -414,6 +420,7 @@ function _conferenceFailed(state: IConferenceState, { conference, error }: {conference: undefined,e2eeSupported: undefined,error,+ iceConnected: undefined,joining: undefined,leaving: undefined,lobbyError,@@ -521,6 +528,7 @@ function _conferenceLeftOrWillLeave(state: IConferenceState, { conference, type// been LOCKED_LOCALLY or LOCKED_REMOTELY.delete nextState.locked;delete nextState.password;+ nextState.iceConnected = undefined;break;}}diff --git a/react/features/conference/components/functions.native.ts b/react/features/conference/components/functions.native.tsindex 2507c125f6..e1e425879c 100644--- a/react/features/conference/components/functions.native.ts+++ b/react/features/conference/components/functions.native.ts@@ -12,6 +12,7 @@ export const isConnecting = (state: IReduxState) => {const { connecting, connection } = state['features/base/connection'];const {conference,+ iceConnected,joining,membersOnly,leaving@@ -25,8 +26,12 @@ export const isConnecting = (state: IReduxState) => {// - the XMPP connection is connecting, or// - the XMPP connection is connected and the conference is joining, or// - the XMPP connection is connected and we have no conference yet, nor we- // are leaving one.+ // are leaving one, or+ // - the conference is joined but its ICE connection (media) is not up yet,+ // so the loader also covers the media-connection gap.return Boolean(- connecting || (connection && (!membersOnly && (joining || (!conference && !leaving))))+ connecting+ || (connection && (!membersOnly && (joining || (!conference && !leaving))))+ || (conference && !iceConnected && !leaving));};diff --git a/react/features/conference/components/native/carmode/CarMode.tsx b/react/features/conference/components/native/carmode/CarMode.tsxindex 7d55688354..a0f93bd303 100644--- a/react/features/conference/components/native/carmode/CarMode.tsx+++ b/react/features/conference/components/native/carmode/CarMode.tsx@@ -46,15 +46,6 @@ const CarMode = (): JSX.Element => {<JitsiScreenfooterComponent = { CarModeFooter }style = { styles.conference }>- {/*- * The activity/loading indicator goes above everything, except- * the toolbox/toolbars and the dialogs.- */- connecting- && <TintedView>- <LoadingIndicator />- </TintedView>- }<ViewpointerEvents = 'box-none'style = { styles.titleBarSafeViewColor as ViewStyle }>@@ -69,6 +60,12 @@ const CarMode = (): JSX.Element => {style = { styles.microphoneContainer as ViewStyle }><MicrophoneButton /></View>+ {+ connecting+ && <TintedView>+ <LoadingIndicator />+ </TintedView>+ }</JitsiScreen>);};diff --git a/react/features/mobile/call-integration/CallKit.ts b/react/features/mobile/call-integration/CallKit.tsindex 4c43fd79d9..871e3e643f 100644--- a/react/features/mobile/call-integration/CallKit.ts+++ b/react/features/mobile/call-integration/CallKit.ts@@ -32,7 +32,6 @@ let CallKit: any;if (RNCallKit) {const eventEmitter = new NativeEventEmitter(RNCallKit);const augmented: Record<string, any> = {- addListener: eventEmitter.addListener.bind(eventEmitter),registerSubscriptions(context: any, delegate: any) {RNCallKit.setProviderConfiguration({iconTemplateImageName: 'CallKitIcon',diff --git a/react/features/mobile/call-integration/middleware.ts b/react/features/mobile/call-integration/middleware.tsindex 019c881b00..f8bbc1fdd4 100644--- a/react/features/mobile/call-integration/middleware.ts+++ b/react/features/mobile/call-integration/middleware.ts@@ -9,8 +9,8 @@ import { IReduxState, IStore } from '../../app/types';import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../base/app/actionTypes';import { SET_AUDIO_ONLY } from '../../base/audio-only/actionTypes';import {+ CONFERENCE_CONNECTION_ESTABLISHED,CONFERENCE_FAILED,- CONFERENCE_JOINED,CONFERENCE_JOIN_IN_PROGRESS,CONFERENCE_LEFT,CONFERENCE_WILL_LEAVE@@ -64,9 +64,6 @@ CallIntegration && MiddlewareRegistry.register(store => next => action => {case CONFERENCE_FAILED:return _conferenceFailed(store, next, action);- case CONFERENCE_JOINED:- return _conferenceJoined(store, next, action);-// If a conference is being left in a graceful manner then// the CONFERENCE_WILL_LEAVE fires as soon as the conference starts// disconnecting. We need to destroy the call on the native side as soon@@ -80,6 +77,9 @@ CallIntegration && MiddlewareRegistry.register(store => next => action => {case CONFERENCE_JOIN_IN_PROGRESS:return _conferenceWillJoin(store, next, action);+ case CONFERENCE_CONNECTION_ESTABLISHED:+ return _conferenceConnectionEstablished(store, next, action);+case SET_AUDIO_ONLY:return _setAudioOnly(store, next, action);@@ -167,26 +167,30 @@ function _conferenceFailed({ getState }: IStore, next: Function, action: AnyActi}/**- * Notifies the feature callkit that the action {@link CONFERENCE_JOINED} is- * being dispatched within a specific redux {@code store}.+ * Notifies the feature callkit that the action {@link CONFERENCE_CONNECTION_ESTABLISHED}+ * is being dispatched. Reports the outgoing call connected when its ICE connection (media)+ * is up, so CallKit gets a real connecting->connected transition.** @param {Store} store - The redux store in which the specified {@code action}* is being dispatched.* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the* specified {@code action} in the specified {@code store}.- * @param {Action} action - The redux action {@code CONFERENCE_JOINED} which is- * being dispatched in the specified {@code store}.+ * @param {Action} action - The redux action {@code CONFERENCE_CONNECTION_ESTABLISHED}+ * which is being dispatched in the specified {@code store}.* @private* @returns {*} The value returned by {@code next(action)}.*/-function _conferenceJoined({ getState }: IStore, next: Function, action: AnyAction) {+function _conferenceConnectionEstablished({ getState }: IStore, next: Function, action: AnyAction) {+ // Report connected once; this action also fires on CONNECTION_RESTORED mid-call.+ const wasConnected = getState()['features/base/conference'].iceConnected;const result = next(action);- if (!isCallIntegrationEnabled(getState)) {+ if (!isCallIntegrationEnabled(getState) || wasConnected) {return result;}- const { callUUID } = action.conference;+ const { conference } = action;+ const { callUUID } = conference;if (callUUID) {CallIntegration.reportConnectedOutgoingCall(callUUID)@@ -194,7 +198,7 @@ function _conferenceJoined({ getState }: IStore, next: Function, action: AnyActi// iOS 13 doesn't like the mute state to be false before the call is started// so we update it here in case the user selected startWithAudioMuted.if (Platform.OS === 'ios') {- _updateCallIntegrationMuted(action.conference, getState());+ _updateCallIntegrationMuted(conference, getState());}}).catch(() => {@@ -245,15 +249,16 @@ function _conferenceLeft({ getState }: IStore, next: Function, action: AnyAction}/**- * Notifies the feature callkit that the action {@link CONFERENCE_WILL_JOIN} is- * being dispatched within a specific redux {@code store}.+ * Notifies the feature callkit that the action {@link CONFERENCE_JOIN_IN_PROGRESS}+ * is being dispatched. Starts the outgoing call (reports connecting); connected is+ * reported later on {@link CONFERENCE_CONNECTION_ESTABLISHED}.** @param {Store} store - The redux store in which the specified {@code action}* is being dispatched.* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the* specified {@code action} in the specified {@code store}.- * @param {Action} action - The redux action {@code CONFERENCE_WILL_JOIN} which- * is being dispatched in the specified {@code store}.+ * @param {Action} action - The redux action {@code CONFERENCE_JOIN_IN_PROGRESS}+ * which is being dispatched in the specified {@code store}.* @private* @returns {*} The value returned by {@code next(action)}.*/