/** * @module Webrtc */ import { Subscription } from 'rxjs'; import { Call, CallRB, CallStatus } from "../../models/call.model"; import type { VirtualBackgroundService } from '../../services/virtualBackground/virtualBackground.service'; import { WebrtcP2PEventHandler } from "../../services/webrtc/webrtcP2PEventHandler"; import { Contact } from '../../models/contact.model'; import type { SpeechEnhancementService } from '../../services/speechEnhancement/speech-enhancement.service'; import { Service } from '../../services/service'; import { JingleSession } from '../../libs/strophe/strophe.jingle.session'; import { ConversationRB } from '../../models/conversation.model'; /** * @internal */ export declare const WEBRTC_P2P_SVC = "WebrtcP2PService"; /** * @eventProperty * WebrtcP2PService Events. */ export declare enum WebrtcP2PServiceEvents { /** * @eventProperty * This RB event is send when P2P called is busy (in order to manage a busy tone). */ RAINBOW_ON_WEBRTC_BUSY = "RAINBOW_ON_WEBRTC_BUSY", /** * @eventProperty * This RB event is send when we need to ask for snapshot from other ressources to update the list of calls */ RAINBOW_SUPERVISION_SNAPSHOT_NEEDED = "RAINBOW_SUPERVISION_SNAPSHOT_NEEDED", /** * @eventProperty * This RB event is send when a call is updated; This event can be used to manage all calls in single place; */ RAINBOW_ON_CALL_UPDATED_EVENT = "RAINBOW_ON_CALL_UPDATED_EVENT", /** * @eventProperty * This RB event is send when a MP call is updated */ RAINBOW_ON_MEDIA_PILLAR_CALL_UPDATED_EVENT = "RAINBOW_ON_MEDIA_PILLAR_CALL_UPDATED_EVENT" } /** * @public * Webrtc P2P Service interface */ export interface IWebrtcP2PService { /** * Make a standard P2P call toward a contact * @param contact - The Call object that we want to remove * @param mediaType - The media type of call (could be 'audio', 'video' (i.e audio and video), 'videoOnly' (no audio, only video), 'sharing' (audio and sharing) and 'sharingOnly' (only sharing, no audio)) * @param message - [optional] additional message send to the distant party for the reason of the call * @returns Returns the call */ makeCall(contact: Contact, mediaType: 'audio' | 'video' | 'videoOnly' | 'sharing' | 'sharingOnly', message?: string): Promise; /** * Answer an incoming webrtc call * @param call - The Call object that we want to remove * @param mediaType - (optional) The media type to answer the call (by default, it's only audio anwser). In case of audio and video incoming call * the user can use type = "video" to answer the call with audio and video; */ answerCall(call: CallRB, mediaType: string): void; /** *Terminate a webrtc call * @param call - The Call object that we want to remove * @param cause - (optional) cause to reject the call * @param notifyOtherParticipant -(optional) Indicates wether the other participant should be notified by a xmpp message or not */ terminateCall(call: CallRB, cause: string, notifyOtherParticipant: boolean): void; /** * Allow to mute / unmute a call * @param call - The call * @param state - if true, the audio in the call will be muted * @returns The updated call object */ muteCall(call: CallRB, state: boolean): CallRB; /** * Put the call on Hold * @param call - The call to be put on hold * @param hold - When true the call is hold * @returns the updated call object */ holdCall(call: CallRB, state: boolean): CallRB; /** * Remove a media from call * @param call - The call object * @param mediaType - the mediaType to remove from the call * @returns Resolved when the action is taken into accout */ removeMediaFromCall(call: CallRB, mediaType: 'video' | 'sharing'): Promise; /** *Allow to send DTMF * @param call - if true, the audio in the call will be muted * @param dialString - The conversation that is related to the call * @param skipHandle - [optional] Should skip the ontonechange event -- false by default */ sendDTMF(call: CallRB, dialString: string, skipHandle?: boolean): Promise; /** * Get a call by it's ID * @param callId - The id of the call to find * @returns The call */ getCallById(callId: string): CallRB; /** * Find and return the current active call (the last one found), or null otherwise * @returns Return the current active call (the last one found), or null otherwise */ getCurrentActiveCall(): CallRB | null; /** * If the current user has any kind of webrtc call (could also be with WebRTC GW / Media Pillar) * @returns True if user has a call */ isUserContactInCall(): boolean; /** * Subscribe to updates on the current calls sessions (all events are of RBEvent type `{ name: string, data:any }`); * All public events that are fired by this service are described in the documentation. * NB There might be some events that are not documented here, they should be ignored * @param handler - The call-back function that will be subscribed to the RxJS subject * @param eventName - The name of the event to filter * @returns Returns RxJS Subscription */ subscribe(handler: any, eventName?: string): Subscription; } /** * @internal */ export declare class WebrtcP2PService extends Service implements IWebrtcP2PService { started: boolean; connected: boolean; RTC: any; calls: Record; autoreleaseTimeout: any; makingCall: boolean; reconnectCall: boolean; alreadyAttaching: boolean; firefoxPreferedSharing: string; webrtcP2PEventHandler: WebrtcP2PEventHandler; private isMixPstnWebRtcAllowed; private audioProfileChanging; private subscriptions; private xmppConnectionSubscription; private replaceBackgroundSubscription; private deviceManagementSubscription; private listeners; virtualBackgroundService?: VirtualBackgroundService; speechEnhancementService?: SpeechEnhancementService; private logger; private mainService; private rxSubject; private eventService; private webrtcConfigAndUtils; private contactService; private xmppService; private profileService; private deviceManagementService; private settingsService; private conversationService; getDesktopSharingSource(): any; askToAddSharing(__conversationId: any, __shouldAskForAudio?: boolean): boolean; askToStartSharing(__contactId: any, __media: any, __shouldAskForAudio?: boolean): boolean; isNativeApplication(): boolean; static getInstance(): WebrtcP2PService; static build(): WebrtcP2PService; private constructor(); start(): void; stop(): void; reconnect(): void; private attachHandlers; private removeHandlers; private reconnectSessionsIfNeeded; private webrtcConfigAndUtilsEvent; /** * Send an event to the RX Subject (sends always a RBEvent type) * @param name - The name of the event * @param data - The data of the event */ sendEvent(name: string, data?: any): void; /** * Subscribe to updates on the current calls sessions (all events are of RBEvent type {name: string, data:any}); * All public events that are fired by this service are described in the documentation. * NB There might be some events that are not documented here, they should be ignored * @param handler - The call-back function that will be subscribed to the RxJS subject * @param eventName - The name of the event to filter * @returns Returns RxJS Subscription */ subscribe(handler: any, eventName?: string): Subscription; /** * Make a standard P2P call toward a contact * @param contact - The Call object that we want to remove * @param mediaType - The media type of call (could be 'audio', 'video' (i.e audio and video), 'videoOnly' (no audio, only video), 'sharing' (audio and sharing) and 'sharingOnly' (only sharing, no audio)) * @param message - [optional] additional message send to the distant party for the reason of the call * @param message - [optional] TRUE in case we want to propose add System audio on top of sharing * @returns Returns the call */ makeCall(contact: Contact, mediaType: string, message?: string, addAudioToSharingCall?: boolean): Promise; /** * Answer an incoming webrtc call * @param call - The Call object that we want to remove * @param mediaType - (optional) The media type to answer the call (by default, it's only audio anwser). In case of audio and video incoming call * the user can use type = "video" to answer the call with audio and video; */ answerCall(call: CallRB, mediaType?: string): void; /** * Terminate a webrtc call * @param call - The Call object that we want to remove * @param cause - (optional) cause to reject the call * @param notifyOtherParticipant - (optional) Indicates wether the other participant should be notified by a xmpp message or not */ terminateCall(call: CallRB, cause?: string, notifyOtherParticipant?: boolean): void; /** * Allow to mute / unmute acall * @param call - The call * @param state - if true, the audio in the call will be muted * @returns The updated call object */ muteCall(call: CallRB, state: boolean): CallRB; /** * Put the call on Hold * @param call - The call to be put on hold * @param hold - When true the call is hold * @returns the updated call object */ holdCall(call: CallRB, hold: boolean): CallRB; /** * Remove a media from call * @param call - The call object * @param mediaType - the mediaType to remove from the call */ removeMediaFromCall(call: CallRB, mediaType: 'video' | 'sharing'): Promise; /** * Allow to send DTMF * @param call - if true, the audio in the call will be muted * @param dialString - The conversation that is related to the call * @param skipHandle - [optional] Should skip the ontonechange event -- false by default */ sendDTMF(call: CallRB, dialString: string, skipHandle?: boolean): Promise; /** * Remove The Call object and terminates the webrtc session related to this call. * @param call - The Call object that we want to remove * @param reason - The reason to end the call that is send to the distant * @param text - Additional text send to the distant when the webrtc session is released */ removeCallObject(call: CallRB, reason?: string, text?: string): void; private onReplaceBackgroundChangeEvent; private putActiveWebrtcCallOnHold; private onConnectionStateChangeEvent; isUserContactInCall(): boolean; isUserContactInOtherCall(call: CallRB): boolean; /** * Find and return the current active call (the last one found), or null otherwise * @returns Return the current active call (the last one found), or null otherwise */ getCurrentActiveCall(): CallRB | null; /** * Retrieve the list of calls with a status equal to a given status (or a list of given status) (if some exist) * @public * @param {any} [searchedCallStatus] Status (or array of status) of calls to search. If not passed, it returns all calls except incoming/queued ringing calls * @returns {CallRB[]} List of calls matching the searched status (or empty array if no calls found) * @instance * @function */ getCalls(searchedCallStatus?: CallStatus[] | CallStatus): CallRB[]; /** * Return an array with all the WebRTC Jingle active sessions * @returns Return an array with all the WebRTC Jingle active sessions */ getCurrentActiveSessions(): any[]; /** * Return an array with all the Call objects that are not ended and not related to MP * @returns Return an array with all the Call objects that are not ended and not related to MP */ getCurrentCallsNotMediaPillar(): CallRB[]; /** * Return an array with all the Call objects that are not ended and not related to MP * @returns Return an array with all the Call objects that are not ended and not related to MP */ getCurrentIncomingCallsNotMediaPillar(): CallRB[]; /** * Check if the user has an active webrtc session that is not related to Media Pillar / WebRTC GW * @returns Return true if the user has an active webrtc session that is not related to Media Pillar / WebRTC GW */ existWebrtcActiveSessionNotMP(): boolean; /** * Check if the user has an active webrtc session that is related to Media Pillar / WebRTC GW * @returns Return true if the user has an active webrtc session that is related to Media Pillar / WebRTC GW */ existMediaPillarAudioCall(): boolean; /** * Check if the user has an answering webrtc session that is related to Media Pillar / WebRTC GW * @returns Return true if the user has an answering webrtc session that is related to Media Pillar / WebRTC GW */ existMediaPillarAnsweringCall(): boolean; /** * Return an array of Call that are related to Media Pillar / Webrtc GW * @returns Return an array of Call that are related to Media Pillar / Webrtc GW */ getMediaPillarAudioCalls(): CallRB[]; /** * Return an array of Call that are related to Media Pillar / Webrtc GW * @returns Return an array of Call that are related to Media Pillar / Webrtc GW */ getActiveMediaPillarAudioCall(): CallRB; isInMediaPillarAudioCallWithContactJid(jid: any): boolean; hasMediaPillarCallWithContactJid(jid: string): boolean; hasOtherWebrtcCallWithContactJid(callId: string, contactJid: string): boolean; /** * Return the Call that is on hold (put on hold by the user) * @returns Return the Call that is on hold (put on hold by the user) */ getCallOnHold(): CallRB; /** * Return the Call that is on hold (put on hold by the distant party) * @returns Return the Call that is put on hold */ getCallPutOnHold(): CallRB; /** * getWebrtcAudioCall * @returns the audio webrtc call */ getWebrtcAudioCall(): CallRB; getWebrtcAudioCalls(): CallRB[]; getSecondSharingCallForPbxCall(pbxCall: CallRB): CallRB; /** * getActiveWebrtcAudioCall * @returns the audio webrtc call that is in ACTIVE STATE */ getActiveWebrtcAudioCall(): CallRB; /** * GetWebrtcCallsOnHold * @returns the audio webrtc call that is in HOLD STATE */ getWebrtcCallsOnHold(): CallRB[]; getMPWebrtcAudioCallByState(soughtCallState: any): CallRB; getCurrentSharingCall(): CallRB; /** * Ends all sharing calls related to a given contact * @param contact - The contact related to all calls */ endAllCallsForContact(contact: Contact): void; private onAudioVideoInputDeviceChange; getCallById(callId: string): CallRB; /** * Find and return a call by the distant contact's jid or full jid * @param contactJid - The jid of the contact that we want to find * @param fullJid - [optional] The full JID of the contact related to the call * @returns The call */ getCallByJid(contactJid: string, fullJid?: string): CallRB; /** * Send to remote (others clients) a dummy reject for an incoming webrtc call * then the others remote ressources manage this call as rejected even if locally it isn't * (mainly for RQRAINB-9057) * @param callId - The tel Call id that we want to remotly manage as rejected */ dummyRejectCallForRemote(callId: string): void; /** * Release a standard call * @param call - The Call object that we want to release * @param reason - (optional) reason to release the call * @param text - (optional) additional text */ releaseCall(call: CallRB, reason?: string, text?: string): void; callShiftPBX(cstaCallId: string, mpJid: string, otherSid: string): Promise; callShift(otherSid: string, referTo: string, media?: string): Promise; /** * Make a Jingle call toward the destionation (could be a MP call) * @param call - The Call object * @param mediaPillarJid - (optional) the media Pillar Jid only in case of webrtc gateway media Pillar * @param phoneNumber - (optional) the number to join by mediaPillar * @param otherSid - parameter only used in case of transfer webrtc to webrtc call * @param callShift - in case of call shift */ makeJingleCall(call: CallRB, mediaPillarJid?: string, phoneNumber?: string, otherSid?: string, callShift?: boolean): Promise; /** * Make the jingle webtc call with sharing and audio towards the destination in the call * @param call - The Call object */ makeJingleSharingCall(call: CallRB): Promise; /** * UCAAS Method -- to be used to start the desktop sharing in case of Desktop App * @param contact - The Call object that we want to remove * @param media - The media type of call (could be 'sharing' (audio and sharing) and 'sharingOnly' (only sharing, no audio)) */ startDesktopSharing(contact: Contact, media: string): void; /** * UCAAS Method -- Desktop app has annulated start of sharing */ startSharingCancelled(): void; sendUpdateCallEvent(call: CallRB): void; /** * Answer an incoming jingle call * @param call - the call */ answerJingleCall(call: CallRB): Promise; /** * UCAAS Method -- P2P call is transferred to a SFU conference * @param call - The P2P call that should be removed */ onCallTransferred(call: CallRB): void; /** * UCAAS Method -- Desktop app to add a sharing to conversation * @param conversation - The conversation related */ askToAddDesktopSharing(conversation: ConversationRB): void; /** * Add audio to call (or change the current audio input device) * @param call - The call object * @param mediaModify - if True, the action is to "change" the current input audio device, * and not add audio to the current call * @returns Resolved when the action is taken into accout */ addAudioToCall(call: CallRB, mediaModify?: boolean): Promise; /** * Add Sharing to a existing active call * @param call - The call object * @returns Resolved when the action is taken into accout */ addSharingToCall(call: CallRB, withAudio?: boolean): Promise; /** * Add video to active call (or modify the video input) * @param call - The call object * @param mediaModify - if True, the action is to "change" the current video audio device, and not add video to the current call * @returns Resolved when the action is taken into accout */ addVideoToCall(call: CallRB, mediaModify?: boolean): Promise; private changeBackgroundForCall; /** * Remove the sharing from the call * @param call - The call object */ removeSharingFromCall(call: CallRB): Promise; /** * Remove the sharing and video from the call * @param call - The call object * @returns Resolves when the action is taken into account */ private removeVideoAndSharingFromCall; /** * Remove video from the current call * @param call - The call object * @returns Resolved when the action is taken into account */ removeVideoFromCall(call: CallRB): Promise; /*************************************************************/ /*************************************************************/ /** * Allow to mute / unmute the current call UCAAS ONLY FONCTION * @param conversation - The conversation that is related to the call * @param state - if true, the audio in the call will be muted * @returns The updated call object */ muteAudio(conversation: ConversationRB, state: boolean): CallRB; /** * Put the call on Hold * NB this will stop all video and sharing coming from this user before the hold action * @param call - The call to be put on hold * @returns the updated call object */ private putCallOnHold; /** * Retrieve the call on Hold * @param call - The call to be put on hold * @returns the updated call object */ private retrieveCallOnHold; /** * Functions related to the refer action - update from P2P call to Conference call * @returns the updated call object */ referTo(session: any, confEndpointId: string, referTo: string): void; /** * Transfer a webrtc call on hold to another active call (only works for 2 webrtc P2P calls) * @param session - The session related to the call on hold * @param otherSession - The active call session, to whom we want to transfer the call */ transferCall(session: JingleSession, otherSession: JingleSession): void; sendReferStatus(callId: string, status: string): void; sendReferTransfer(callId: string, method: string, referTo: string): void; /** * Stops and removes all Tracks from the Media Stream array * @param streams - Array of Media Streams */ disableStreams(streams: MediaStream[]): void; pushInLocalStreams(stream: MediaStream, callId: string): void; openErrorPopup(msg?: string): void; private removeSharingStreamFromCall; private removeAudioVideoStreamFromCall; private removeAllStreamsFromCall; resetToSafeState(call?: CallRB): void; dropAudio(): Promise; /*************************************************************/ /** * Method calculatePresenceMessage * @private * @memberof WebrtcP2PService * UCAAS Method -- Calculate the call message to be shown on the UI * @param {Call} call call object * @returns {string} The new message to be shown for our current presence */ calculatePresenceMessage(call: CallRB): string; /** * Method updateRemoteTypeMedia * @private * @memberof WebrtcP2PService * UCAAS Method -- Calculate the remoteMedia object value * @param {string} remoteType The new remote type string * @param {Call} call call object */ updateRemoteTypeMedia(remoteType: string, call: CallRB): void; private updateLocalAudioStreamForCall; private updateLocalMediaType; updateCurrentCall(call: CallRB, session: JingleSession, type: any, action: any): Promise; private handleToneChangeEvent; private silentToneChangeEventHandle; clearSrcObjectsFromElements(): void; attachDistantMediaStreamsUnifiedPlan(call: any): void; attachDistantMediaStreams(attach: any, call: any): void; attachLocalVideoOnlyStreamToElement(call: any, attach: any, element: any): void; playStartRecordSoundInCall(): Promise; } //# sourceMappingURL=webrtcP2P.service.d.ts.map