diff options
Diffstat (limited to 'includes/external/matrix/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js.map')
-rw-r--r-- | includes/external/matrix/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js.map | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js.map b/includes/external/matrix/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js.map new file mode 100644 index 0000000..aee367e --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js.map @@ -0,0 +1 @@ +{"version":3,"file":"groupCall.js","names":["_typedEventEmitter","require","_callFeed","_call","_roomState","_logger","_ReEmitter","_callEventTypes","_event","_callEventHandler","_groupCallEventHandler","_utils","_groupCallStats","_statsReport","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","GroupCallIntent","exports","GroupCallType","GroupCallTerminationReason","GroupCallEvent","GroupCallStatsReportEvent","GroupCallErrorCode","GroupCallError","Error","constructor","code","msg","err","GroupCallUnknownDeviceError","userId","UnknownDevice","OtherUserSpeakingError","GroupCallState","DEVICE_TIMEOUT","getCallUserId","call","_call$getOpponentMemb","getOpponentMember","invitee","GroupCall","TypedEventEmitter","client","room","type","isPtt","intent","groupCallId","dataChannelsEnabled","dataChannelOptions","isCallWithoutVideoAndAudio","_room$currentState$ge","_room$currentState$ge2","Map","report","emit","ConnectionStats","ByteSentStats","LocalCallFeedUninitialized","newCall","_newCall$getOpponentM","_this$calls$get","roomId","state","CallState","Ringing","logger","warn","log","reject","opponentUserId","undefined","deviceMap","calls","get","prevCall","getOpponentDeviceId","callId","hangup","CallErrorCode","Replaced","initCall","feeds","getLocalFeeds","map","feed","clone","callExpected","setTracksEnabled","stream","getAudioTracks","getVideoTracks","answerWithCallFeeds","set","CallsChanged","needsRetry","participantMap","participants","callMap","retriesMap","retryCallCounts","deviceId","participant","_retriesMap$get","_retriesMap","retries","getOpponentSessionId","sessionId","wantsOutgoingCall","placeOutgoingCalls","opponentMemberId","opponentDeviceId","currentUserMediaFeed","getUserMediaFeed","remoteUsermediaFeed","remoteFeedChanged","addUserMediaFeed","replaceUserMediaFeed","removeUserMediaFeed","currentScreenshareFeed","getScreenshareFeed","remoteScreensharingFeed","remoteScreenshareFeedChanged","addScreenshareFeed","replaceScreenshareFeed","removeScreenshareFeed","_oldState","_call$getOpponentMemb2","Ended","audioMuted","localCallFeed","isAudioMuted","localUsermediaStream","isMicrophoneMuted","setMicrophoneMuted","videoMuted","isVideoMuted","isLocalVideoMuted","setLocalVideoMuted","Connected","delete","size","_call$getOpponentMemb3","_call$getOpponentMemb4","hangupReason","getMember","disposeCall","topAvg","nextActiveSpeaker","callFeed","userMediaFeeds","isLocal","total","speakingVolumeSamples","reduce","acc","volume","Math","max","SPEAKING_THRESHOLD","avg","activeSpeaker","ActiveSpeakerChanged","updateParticipants","forEachCall","expected","Entered","newState","oldState","updateMemberState","catch","e","error","reEmitter","ReEmitter","genCallID","creationTs","currentState","getStateEvents","EventType","GroupCallPrefix","getTs","on","RoomStateEvent","Update","onRoomState","ParticipantsChanged","onParticipantsChanged","GroupCallStateChanged","onStateChanged","LocalScreenshareStateChanged","onLocalFeedsChanged","allowCallWithoutVideoAndAudio","userID","getUserId","stats","GroupCallStats","reports","StatsReport","CONNECTION_STATS","onConnectionStats","BYTE_SENT_STATS","onByteSentStats","create","Date","now","groupCallEventHandler","groupCalls","GroupCallEventHandlerEvent","Outgoing","groupCallState","sendStateEvent","_state","value","prevValue","_participants","participantStateEqual","x","y","screensharing","deviceMapsEqual","mapsEqual","_creationTs","enteredViaAnotherSession","_enteredViaAnotherSession","f","values","localScreenshareFeed","hasLocalParticipant","_this$participants$ge","_this$participants$ge2","has","getDeviceId","_this$participants$ge3","member","initLocalCallFeed","InitializingLocalCallFeed","initCallFeedPromise","initLocalCallFeedInternal","getMediaHandler","getUserMediaStream","Video","MediaStream","stopUserMediaStream","CallFeed","purpose","SDPStreamMetadataPurpose","Usermedia","initWithAudioMuted","initWithVideoMuted","LocalCallFeedInitialized","updateLocalUsermediaStream","oldStream","setNewStream","micShouldBeMuted","vidShouldBeMuted","id","enter","CallEventHandlerEvent","Incoming","onIncomingCall","callEventHandler","retryCallLoopInterval","setInterval","onRetryCallLoop","retryCallInterval","onActiveSpeakerLoop","activeSpeakerLoopInterval","activeSpeakerInterval","dispose","stopScreensharingStream","localDesktopCapturerSourceId","stopAllStreams","transmitTimer","clearTimeout","clearInterval","participantsExpirationTimer","UserHangup","clear","removeListener","stop","leave","terminate","emitStateEvent","off","existingStateEvent","getContent","CallEnded","muted","hasAudioDevice","sendUpdatesBefore","setTimeout","pttMaxTransmitTime","_call$localUsermediaF","localUsermediaFeed","setAudioVideoMuted","sendUpdates","updates","sendMetadataUpdate","Promise","all","info","LocalMuteStateChanged","hasVideoDevice","_","setScreensharingEnabled","enabled","opts","isScreensharing","getScreensharingStream","track","getTracks","onTrackEnded","removeEventListener","addEventListener","desktopCapturerSourceId","Screenshare","pushLocalFeed","throwOnFail","NoUserMedia","localScreensharingFeed","removeLocalFeed","localUserId","localDeviceId","callsChanged","_this$calls$get2","debug","NewSession","createNewMatrixCall","opponentSessionId","placeCallWithCallFeeds","then","createDataChannel","CallError","PlaceCallFailed","SignallingFailed","getMemberStateEvents","GroupCallMemberPrefix","onCallFeedsChanged","onCallStateChanged","onCallHangup","onCallReplaced","callHandlers","CallEvent","FeedsChanged","State","Hangup","reEmit","initStats","usermediaFeed","screenshareFeed","find","measureVolumeActivity","UserMediaFeedsChanged","existingFeed","replacementFeed","feedIndex","findIndex","splice","screenshareFeeds","ScreenshareFeedsChanged","localMember","entered","nextExpiration","Infinity","getStateKey","content","Array","isArray","devices","validDevices","d","device_id","session_id","expires_ts","membership","some","getSessionId","updateDevices","fn","keepAlive","_event$getContent","event","otherCalls","c","newDevices","newCalls","newContent","addDeviceToMemberState","resendMemberStateTimer","cleanMemberState","myDevices","getDevices","device","last_seen_ts","getGroupCallStats"],"sources":["../../src/webrtc/groupCall.ts"],"sourcesContent":["import { TypedEventEmitter } from \"../models/typed-event-emitter\";\nimport { CallFeed, SPEAKING_THRESHOLD } from \"./callFeed\";\nimport { MatrixClient, IMyDevice } from \"../client\";\nimport {\n CallErrorCode,\n CallEvent,\n CallEventHandlerMap,\n CallState,\n genCallID,\n MatrixCall,\n setTracksEnabled,\n createNewMatrixCall,\n CallError,\n} from \"./call\";\nimport { RoomMember } from \"../models/room-member\";\nimport { Room } from \"../models/room\";\nimport { RoomStateEvent } from \"../models/room-state\";\nimport { logger } from \"../logger\";\nimport { ReEmitter } from \"../ReEmitter\";\nimport { SDPStreamMetadataPurpose } from \"./callEventTypes\";\nimport { MatrixEvent } from \"../models/event\";\nimport { EventType } from \"../@types/event\";\nimport { CallEventHandlerEvent } from \"./callEventHandler\";\nimport { GroupCallEventHandlerEvent } from \"./groupCallEventHandler\";\nimport { IScreensharingOpts } from \"./mediaHandler\";\nimport { mapsEqual } from \"../utils\";\nimport { GroupCallStats } from \"./stats/groupCallStats\";\nimport { ByteSentStatsReport, ConnectionStatsReport, StatsReport } from \"./stats/statsReport\";\n\nexport enum GroupCallIntent {\n Ring = \"m.ring\",\n Prompt = \"m.prompt\",\n Room = \"m.room\",\n}\n\nexport enum GroupCallType {\n Video = \"m.video\",\n Voice = \"m.voice\",\n}\n\nexport enum GroupCallTerminationReason {\n CallEnded = \"call_ended\",\n}\n\nexport type CallsByUserAndDevice = Map<string, Map<string, MatrixCall>>;\n\n/**\n * Because event names are just strings, they do need\n * to be unique over all event types of event emitter.\n * Some objects could emit more then one set of events.\n */\nexport enum GroupCallEvent {\n GroupCallStateChanged = \"group_call_state_changed\",\n ActiveSpeakerChanged = \"active_speaker_changed\",\n CallsChanged = \"calls_changed\",\n UserMediaFeedsChanged = \"user_media_feeds_changed\",\n ScreenshareFeedsChanged = \"screenshare_feeds_changed\",\n LocalScreenshareStateChanged = \"local_screenshare_state_changed\",\n LocalMuteStateChanged = \"local_mute_state_changed\",\n ParticipantsChanged = \"participants_changed\",\n Error = \"group_call_error\",\n}\n\nexport type GroupCallEventHandlerMap = {\n [GroupCallEvent.GroupCallStateChanged]: (newState: GroupCallState, oldState: GroupCallState) => void;\n [GroupCallEvent.ActiveSpeakerChanged]: (activeSpeaker: CallFeed | undefined) => void;\n [GroupCallEvent.CallsChanged]: (calls: CallsByUserAndDevice) => void;\n [GroupCallEvent.UserMediaFeedsChanged]: (feeds: CallFeed[]) => void;\n [GroupCallEvent.ScreenshareFeedsChanged]: (feeds: CallFeed[]) => void;\n [GroupCallEvent.LocalScreenshareStateChanged]: (\n isScreensharing: boolean,\n feed?: CallFeed,\n sourceId?: string,\n ) => void;\n [GroupCallEvent.LocalMuteStateChanged]: (audioMuted: boolean, videoMuted: boolean) => void;\n [GroupCallEvent.ParticipantsChanged]: (participants: Map<RoomMember, Map<string, ParticipantState>>) => void;\n /**\n * Fires whenever an error occurs when call.js encounters an issue with setting up the call.\n * <p>\n * The error given will have a code equal to either `MatrixCall.ERR_LOCAL_OFFER_FAILED` or\n * `MatrixCall.ERR_NO_USER_MEDIA`. `ERR_LOCAL_OFFER_FAILED` is emitted when the local client\n * fails to create an offer. `ERR_NO_USER_MEDIA` is emitted when the user has denied access\n * to their audio/video hardware.\n * @param err - The error raised by MatrixCall.\n * @example\n * ```\n * matrixCall.on(\"error\", function(err){\n * console.error(err.code, err);\n * });\n * ```\n */\n [GroupCallEvent.Error]: (error: GroupCallError) => void;\n};\n\nexport enum GroupCallStatsReportEvent {\n ConnectionStats = \"GroupCall.connection_stats\",\n ByteSentStats = \"GroupCall.byte_sent_stats\",\n}\n\nexport type GroupCallStatsReportEventHandlerMap = {\n [GroupCallStatsReportEvent.ConnectionStats]: (report: GroupCallStatsReport<ConnectionStatsReport>) => void;\n [GroupCallStatsReportEvent.ByteSentStats]: (report: GroupCallStatsReport<ByteSentStatsReport>) => void;\n};\n\nexport enum GroupCallErrorCode {\n NoUserMedia = \"no_user_media\",\n UnknownDevice = \"unknown_device\",\n PlaceCallFailed = \"place_call_failed\",\n}\n\nexport interface GroupCallStatsReport<T extends ConnectionStatsReport | ByteSentStatsReport> {\n report: T;\n}\n\nexport class GroupCallError extends Error {\n public code: string;\n\n public constructor(code: GroupCallErrorCode, msg: string, err?: Error) {\n // Still don't think there's any way to have proper nested errors\n if (err) {\n super(msg + \": \" + err);\n } else {\n super(msg);\n }\n\n this.code = code;\n }\n}\n\nexport class GroupCallUnknownDeviceError extends GroupCallError {\n public constructor(public userId: string) {\n super(GroupCallErrorCode.UnknownDevice, \"No device found for \" + userId);\n }\n}\n\nexport class OtherUserSpeakingError extends Error {\n public constructor() {\n super(\"Cannot unmute: another user is speaking\");\n }\n}\n\nexport interface IGroupCallDataChannelOptions {\n ordered: boolean;\n maxPacketLifeTime: number;\n maxRetransmits: number;\n protocol: string;\n}\n\nexport interface IGroupCallRoomState {\n \"m.intent\": GroupCallIntent;\n \"m.type\": GroupCallType;\n \"io.element.ptt\"?: boolean;\n // TODO: Specify data-channels\n \"dataChannelsEnabled\"?: boolean;\n \"dataChannelOptions\"?: IGroupCallDataChannelOptions;\n}\n\nexport interface IGroupCallRoomMemberFeed {\n purpose: SDPStreamMetadataPurpose;\n}\n\nexport interface IGroupCallRoomMemberDevice {\n device_id: string;\n session_id: string;\n expires_ts: number;\n feeds: IGroupCallRoomMemberFeed[];\n}\n\nexport interface IGroupCallRoomMemberCallState {\n \"m.call_id\": string;\n \"m.foci\"?: string[];\n \"m.devices\": IGroupCallRoomMemberDevice[];\n}\n\nexport interface IGroupCallRoomMemberState {\n \"m.calls\": IGroupCallRoomMemberCallState[];\n}\n\nexport enum GroupCallState {\n LocalCallFeedUninitialized = \"local_call_feed_uninitialized\",\n InitializingLocalCallFeed = \"initializing_local_call_feed\",\n LocalCallFeedInitialized = \"local_call_feed_initialized\",\n Entered = \"entered\",\n Ended = \"ended\",\n}\n\nexport interface ParticipantState {\n sessionId: string;\n screensharing: boolean;\n}\n\ninterface ICallHandlers {\n onCallFeedsChanged: (feeds: CallFeed[]) => void;\n onCallStateChanged: (state: CallState, oldState: CallState | undefined) => void;\n onCallHangup: (call: MatrixCall) => void;\n onCallReplaced: (newCall: MatrixCall) => void;\n}\n\nconst DEVICE_TIMEOUT = 1000 * 60 * 60; // 1 hour\n\nfunction getCallUserId(call: MatrixCall): string | null {\n return call.getOpponentMember()?.userId || call.invitee || null;\n}\n\nexport class GroupCall extends TypedEventEmitter<\n GroupCallEvent | CallEvent | GroupCallStatsReportEvent,\n GroupCallEventHandlerMap & CallEventHandlerMap & GroupCallStatsReportEventHandlerMap\n> {\n // Config\n public activeSpeakerInterval = 1000;\n public retryCallInterval = 5000;\n public participantTimeout = 1000 * 15;\n public pttMaxTransmitTime = 1000 * 20;\n\n public activeSpeaker?: CallFeed;\n public localCallFeed?: CallFeed;\n public localScreenshareFeed?: CallFeed;\n public localDesktopCapturerSourceId?: string;\n public readonly userMediaFeeds: CallFeed[] = [];\n public readonly screenshareFeeds: CallFeed[] = [];\n public groupCallId: string;\n public readonly allowCallWithoutVideoAndAudio: boolean;\n\n private readonly calls = new Map<string, Map<string, MatrixCall>>(); // user_id -> device_id -> MatrixCall\n private callHandlers = new Map<string, Map<string, ICallHandlers>>(); // user_id -> device_id -> ICallHandlers\n private activeSpeakerLoopInterval?: ReturnType<typeof setTimeout>;\n private retryCallLoopInterval?: ReturnType<typeof setTimeout>;\n private retryCallCounts: Map<string, Map<string, number>> = new Map(); // user_id -> device_id -> count\n private reEmitter: ReEmitter;\n private transmitTimer: ReturnType<typeof setTimeout> | null = null;\n private participantsExpirationTimer: ReturnType<typeof setTimeout> | null = null;\n private resendMemberStateTimer: ReturnType<typeof setInterval> | null = null;\n private initWithAudioMuted = false;\n private initWithVideoMuted = false;\n private initCallFeedPromise?: Promise<void>;\n\n private readonly stats: GroupCallStats;\n\n public constructor(\n private client: MatrixClient,\n public room: Room,\n public type: GroupCallType,\n public isPtt: boolean,\n public intent: GroupCallIntent,\n groupCallId?: string,\n private dataChannelsEnabled?: boolean,\n private dataChannelOptions?: IGroupCallDataChannelOptions,\n isCallWithoutVideoAndAudio?: boolean,\n ) {\n super();\n this.reEmitter = new ReEmitter(this);\n this.groupCallId = groupCallId ?? genCallID();\n this.creationTs =\n room.currentState.getStateEvents(EventType.GroupCallPrefix, this.groupCallId)?.getTs() ?? null;\n this.updateParticipants();\n\n room.on(RoomStateEvent.Update, this.onRoomState);\n this.on(GroupCallEvent.ParticipantsChanged, this.onParticipantsChanged);\n this.on(GroupCallEvent.GroupCallStateChanged, this.onStateChanged);\n this.on(GroupCallEvent.LocalScreenshareStateChanged, this.onLocalFeedsChanged);\n this.allowCallWithoutVideoAndAudio = !!isCallWithoutVideoAndAudio;\n\n const userID = this.client.getUserId() || \"unknown\";\n this.stats = new GroupCallStats(this.groupCallId, userID);\n this.stats.reports.on(StatsReport.CONNECTION_STATS, this.onConnectionStats);\n this.stats.reports.on(StatsReport.BYTE_SENT_STATS, this.onByteSentStats);\n }\n\n private onConnectionStats = (report: ConnectionStatsReport): void => {\n // @TODO: Implement data argumentation\n this.emit(GroupCallStatsReportEvent.ConnectionStats, { report });\n };\n\n private onByteSentStats = (report: ByteSentStatsReport): void => {\n // @TODO: Implement data argumentation\n this.emit(GroupCallStatsReportEvent.ByteSentStats, { report });\n };\n\n public async create(): Promise<GroupCall> {\n this.creationTs = Date.now();\n this.client.groupCallEventHandler!.groupCalls.set(this.room.roomId, this);\n this.client.emit(GroupCallEventHandlerEvent.Outgoing, this);\n\n const groupCallState: IGroupCallRoomState = {\n \"m.intent\": this.intent,\n \"m.type\": this.type,\n \"io.element.ptt\": this.isPtt,\n // TODO: Specify data-channels better\n \"dataChannelsEnabled\": this.dataChannelsEnabled,\n \"dataChannelOptions\": this.dataChannelsEnabled ? this.dataChannelOptions : undefined,\n };\n\n await this.client.sendStateEvent(this.room.roomId, EventType.GroupCallPrefix, groupCallState, this.groupCallId);\n\n return this;\n }\n\n private _state = GroupCallState.LocalCallFeedUninitialized;\n\n /**\n * The group call's state.\n */\n public get state(): GroupCallState {\n return this._state;\n }\n\n private set state(value: GroupCallState) {\n const prevValue = this._state;\n if (value !== prevValue) {\n this._state = value;\n this.emit(GroupCallEvent.GroupCallStateChanged, value, prevValue);\n }\n }\n\n private _participants = new Map<RoomMember, Map<string, ParticipantState>>();\n\n /**\n * The current participants in the call, as a map from members to device IDs\n * to participant info.\n */\n public get participants(): Map<RoomMember, Map<string, ParticipantState>> {\n return this._participants;\n }\n\n private set participants(value: Map<RoomMember, Map<string, ParticipantState>>) {\n const prevValue = this._participants;\n const participantStateEqual = (x: ParticipantState, y: ParticipantState): boolean =>\n x.sessionId === y.sessionId && x.screensharing === y.screensharing;\n const deviceMapsEqual = (x: Map<string, ParticipantState>, y: Map<string, ParticipantState>): boolean =>\n mapsEqual(x, y, participantStateEqual);\n\n // Only update if the map actually changed\n if (!mapsEqual(value, prevValue, deviceMapsEqual)) {\n this._participants = value;\n this.emit(GroupCallEvent.ParticipantsChanged, value);\n }\n }\n\n private _creationTs: number | null = null;\n\n /**\n * The timestamp at which the call was created, or null if it has not yet\n * been created.\n */\n public get creationTs(): number | null {\n return this._creationTs;\n }\n\n private set creationTs(value: number | null) {\n this._creationTs = value;\n }\n\n private _enteredViaAnotherSession = false;\n\n /**\n * Whether the local device has entered this call via another session, such\n * as a widget.\n */\n public get enteredViaAnotherSession(): boolean {\n return this._enteredViaAnotherSession;\n }\n\n public set enteredViaAnotherSession(value: boolean) {\n this._enteredViaAnotherSession = value;\n this.updateParticipants();\n }\n\n /**\n * Executes the given callback on all calls in this group call.\n * @param f - The callback.\n */\n public forEachCall(f: (call: MatrixCall) => void): void {\n for (const deviceMap of this.calls.values()) {\n for (const call of deviceMap.values()) f(call);\n }\n }\n\n public getLocalFeeds(): CallFeed[] {\n const feeds: CallFeed[] = [];\n\n if (this.localCallFeed) feeds.push(this.localCallFeed);\n if (this.localScreenshareFeed) feeds.push(this.localScreenshareFeed);\n\n return feeds;\n }\n\n public hasLocalParticipant(): boolean {\n return (\n this.participants.get(this.room.getMember(this.client.getUserId()!)!)?.has(this.client.getDeviceId()!) ??\n false\n );\n }\n\n /**\n * Determines whether the given call is one that we were expecting to exist\n * given our knowledge of who is participating in the group call.\n */\n private callExpected(call: MatrixCall): boolean {\n const userId = getCallUserId(call);\n const member = userId === null ? null : this.room.getMember(userId);\n const deviceId = call.getOpponentDeviceId();\n return member !== null && deviceId !== undefined && this.participants.get(member)?.get(deviceId) !== undefined;\n }\n\n public async initLocalCallFeed(): Promise<void> {\n if (this.state !== GroupCallState.LocalCallFeedUninitialized) {\n throw new Error(`Cannot initialize local call feed in the \"${this.state}\" state.`);\n }\n this.state = GroupCallState.InitializingLocalCallFeed;\n\n // wraps the real method to serialise calls, because we don't want to try starting\n // multiple call feeds at once\n if (this.initCallFeedPromise) return this.initCallFeedPromise;\n\n try {\n this.initCallFeedPromise = this.initLocalCallFeedInternal();\n await this.initCallFeedPromise;\n } finally {\n this.initCallFeedPromise = undefined;\n }\n }\n\n private async initLocalCallFeedInternal(): Promise<void> {\n logger.log(`GroupCall ${this.groupCallId} initLocalCallFeedInternal() running`);\n\n let stream: MediaStream;\n\n try {\n stream = await this.client.getMediaHandler().getUserMediaStream(true, this.type === GroupCallType.Video);\n } catch (error) {\n // If is allowed to join a call without a media stream, then we\n // don't throw an error here. But we need an empty Local Feed to establish\n // a connection later.\n if (this.allowCallWithoutVideoAndAudio) {\n stream = new MediaStream();\n } else {\n this.state = GroupCallState.LocalCallFeedUninitialized;\n throw error;\n }\n }\n\n // The call could've been disposed while we were waiting, and could\n // also have been started back up again (hello, React 18) so if we're\n // still in this 'initializing' state, carry on, otherwise bail.\n if (this._state !== GroupCallState.InitializingLocalCallFeed) {\n this.client.getMediaHandler().stopUserMediaStream(stream);\n throw new Error(\"Group call disposed while gathering media stream\");\n }\n\n const callFeed = new CallFeed({\n client: this.client,\n roomId: this.room.roomId,\n userId: this.client.getUserId()!,\n deviceId: this.client.getDeviceId()!,\n stream,\n purpose: SDPStreamMetadataPurpose.Usermedia,\n audioMuted: this.initWithAudioMuted || stream.getAudioTracks().length === 0 || this.isPtt,\n videoMuted: this.initWithVideoMuted || stream.getVideoTracks().length === 0,\n });\n\n setTracksEnabled(stream.getAudioTracks(), !callFeed.isAudioMuted());\n setTracksEnabled(stream.getVideoTracks(), !callFeed.isVideoMuted());\n\n this.localCallFeed = callFeed;\n this.addUserMediaFeed(callFeed);\n\n this.state = GroupCallState.LocalCallFeedInitialized;\n }\n\n public async updateLocalUsermediaStream(stream: MediaStream): Promise<void> {\n if (this.localCallFeed) {\n const oldStream = this.localCallFeed.stream;\n this.localCallFeed.setNewStream(stream);\n const micShouldBeMuted = this.localCallFeed.isAudioMuted();\n const vidShouldBeMuted = this.localCallFeed.isVideoMuted();\n logger.log(\n `GroupCall ${this.groupCallId} updateLocalUsermediaStream() (oldStreamId=${oldStream.id}, newStreamId=${stream.id}, micShouldBeMuted=${micShouldBeMuted}, vidShouldBeMuted=${vidShouldBeMuted})`,\n );\n setTracksEnabled(stream.getAudioTracks(), !micShouldBeMuted);\n setTracksEnabled(stream.getVideoTracks(), !vidShouldBeMuted);\n this.client.getMediaHandler().stopUserMediaStream(oldStream);\n }\n }\n\n public async enter(): Promise<void> {\n if (this.state === GroupCallState.LocalCallFeedUninitialized) {\n await this.initLocalCallFeed();\n } else if (this.state !== GroupCallState.LocalCallFeedInitialized) {\n throw new Error(`Cannot enter call in the \"${this.state}\" state`);\n }\n\n logger.log(`GroupCall ${this.groupCallId} enter() running`);\n this.state = GroupCallState.Entered;\n\n this.client.on(CallEventHandlerEvent.Incoming, this.onIncomingCall);\n\n for (const call of this.client.callEventHandler!.calls.values()) {\n this.onIncomingCall(call);\n }\n\n this.retryCallLoopInterval = setInterval(this.onRetryCallLoop, this.retryCallInterval);\n\n this.activeSpeaker = undefined;\n this.onActiveSpeakerLoop();\n this.activeSpeakerLoopInterval = setInterval(this.onActiveSpeakerLoop, this.activeSpeakerInterval);\n }\n\n private dispose(): void {\n if (this.localCallFeed) {\n this.removeUserMediaFeed(this.localCallFeed);\n this.localCallFeed = undefined;\n }\n\n if (this.localScreenshareFeed) {\n this.client.getMediaHandler().stopScreensharingStream(this.localScreenshareFeed.stream);\n this.removeScreenshareFeed(this.localScreenshareFeed);\n this.localScreenshareFeed = undefined;\n this.localDesktopCapturerSourceId = undefined;\n }\n\n this.client.getMediaHandler().stopAllStreams();\n\n if (this.transmitTimer !== null) {\n clearTimeout(this.transmitTimer);\n this.transmitTimer = null;\n }\n\n if (this.retryCallLoopInterval !== undefined) {\n clearInterval(this.retryCallLoopInterval);\n this.retryCallLoopInterval = undefined;\n }\n\n if (this.participantsExpirationTimer !== null) {\n clearTimeout(this.participantsExpirationTimer);\n this.participantsExpirationTimer = null;\n }\n\n if (this.state !== GroupCallState.Entered) {\n return;\n }\n\n this.forEachCall((call) => call.hangup(CallErrorCode.UserHangup, false));\n\n this.activeSpeaker = undefined;\n clearInterval(this.activeSpeakerLoopInterval);\n\n this.retryCallCounts.clear();\n clearInterval(this.retryCallLoopInterval);\n\n this.client.removeListener(CallEventHandlerEvent.Incoming, this.onIncomingCall);\n this.stats.stop();\n }\n\n public leave(): void {\n this.dispose();\n this.state = GroupCallState.LocalCallFeedUninitialized;\n }\n\n public async terminate(emitStateEvent = true): Promise<void> {\n this.dispose();\n\n this.room.off(RoomStateEvent.Update, this.onRoomState);\n this.client.groupCallEventHandler!.groupCalls.delete(this.room.roomId);\n this.client.emit(GroupCallEventHandlerEvent.Ended, this);\n this.state = GroupCallState.Ended;\n\n if (emitStateEvent) {\n const existingStateEvent = this.room.currentState.getStateEvents(\n EventType.GroupCallPrefix,\n this.groupCallId,\n )!;\n\n await this.client.sendStateEvent(\n this.room.roomId,\n EventType.GroupCallPrefix,\n {\n ...existingStateEvent.getContent(),\n \"m.terminated\": GroupCallTerminationReason.CallEnded,\n },\n this.groupCallId,\n );\n }\n }\n\n /*\n * Local Usermedia\n */\n\n public isLocalVideoMuted(): boolean {\n if (this.localCallFeed) {\n return this.localCallFeed.isVideoMuted();\n }\n\n return true;\n }\n\n public isMicrophoneMuted(): boolean {\n if (this.localCallFeed) {\n return this.localCallFeed.isAudioMuted();\n }\n\n return true;\n }\n\n /**\n * Sets the mute state of the local participants's microphone.\n * @param muted - Whether to mute the microphone\n * @returns Whether muting/unmuting was successful\n */\n public async setMicrophoneMuted(muted: boolean): Promise<boolean> {\n // hasAudioDevice can block indefinitely if the window has lost focus,\n // and it doesn't make much sense to keep a device from being muted, so\n // we always allow muted = true changes to go through\n if (!muted && !(await this.client.getMediaHandler().hasAudioDevice())) {\n return false;\n }\n\n const sendUpdatesBefore = !muted && this.isPtt;\n\n // set a timer for the maximum transmit time on PTT calls\n if (this.isPtt) {\n // Set or clear the max transmit timer\n if (!muted && this.isMicrophoneMuted()) {\n this.transmitTimer = setTimeout(() => {\n this.setMicrophoneMuted(true);\n }, this.pttMaxTransmitTime);\n } else if (muted && !this.isMicrophoneMuted()) {\n if (this.transmitTimer !== null) clearTimeout(this.transmitTimer);\n this.transmitTimer = null;\n }\n }\n\n this.forEachCall((call) => call.localUsermediaFeed?.setAudioVideoMuted(muted, null));\n\n const sendUpdates = async (): Promise<void> => {\n const updates: Promise<void>[] = [];\n this.forEachCall((call) => updates.push(call.sendMetadataUpdate()));\n\n await Promise.all(updates).catch((e) =>\n logger.info(\n `GroupCall ${this.groupCallId} setMicrophoneMuted() failed to send some metadata updates`,\n e,\n ),\n );\n };\n\n if (sendUpdatesBefore) await sendUpdates();\n\n if (this.localCallFeed) {\n logger.log(\n `GroupCall ${this.groupCallId} setMicrophoneMuted() (streamId=${this.localCallFeed.stream.id}, muted=${muted})`,\n );\n\n // We needed this here to avoid an error in case user join a call without a device.\n // I can not use .then .catch functions because linter :-(\n try {\n if (!muted) {\n const stream = await this.client\n .getMediaHandler()\n .getUserMediaStream(true, !this.localCallFeed.isVideoMuted());\n if (stream === null) {\n // if case permission denied to get a stream stop this here\n /* istanbul ignore next */\n logger.log(\n `GroupCall ${this.groupCallId} setMicrophoneMuted() no device to receive local stream, muted=${muted}`,\n );\n return false;\n }\n }\n } catch (e) {\n /* istanbul ignore next */\n logger.log(\n `GroupCall ${this.groupCallId} setMicrophoneMuted() no device or permission to receive local stream, muted=${muted}`,\n );\n return false;\n }\n\n this.localCallFeed.setAudioVideoMuted(muted, null);\n // I don't believe its actually necessary to enable these tracks: they\n // are the one on the GroupCall's own CallFeed and are cloned before being\n // given to any of the actual calls, so these tracks don't actually go\n // anywhere. Let's do it anyway to avoid confusion.\n setTracksEnabled(this.localCallFeed.stream.getAudioTracks(), !muted);\n } else {\n logger.log(`GroupCall ${this.groupCallId} setMicrophoneMuted() no stream muted (muted=${muted})`);\n this.initWithAudioMuted = muted;\n }\n\n this.forEachCall((call) =>\n setTracksEnabled(call.localUsermediaFeed!.stream.getAudioTracks(), !muted && this.callExpected(call)),\n );\n this.emit(GroupCallEvent.LocalMuteStateChanged, muted, this.isLocalVideoMuted());\n\n if (!sendUpdatesBefore) await sendUpdates();\n\n return true;\n }\n\n /**\n * Sets the mute state of the local participants's video.\n * @param muted - Whether to mute the video\n * @returns Whether muting/unmuting was successful\n */\n public async setLocalVideoMuted(muted: boolean): Promise<boolean> {\n // hasAudioDevice can block indefinitely if the window has lost focus,\n // and it doesn't make much sense to keep a device from being muted, so\n // we always allow muted = true changes to go through\n if (!muted && !(await this.client.getMediaHandler().hasVideoDevice())) {\n return false;\n }\n\n if (this.localCallFeed) {\n /* istanbul ignore next */\n logger.log(\n `GroupCall ${this.groupCallId} setLocalVideoMuted() (stream=${this.localCallFeed.stream.id}, muted=${muted})`,\n );\n\n try {\n const stream = await this.client.getMediaHandler().getUserMediaStream(true, !muted);\n await this.updateLocalUsermediaStream(stream);\n this.localCallFeed.setAudioVideoMuted(null, muted);\n setTracksEnabled(this.localCallFeed.stream.getVideoTracks(), !muted);\n } catch (_) {\n // No permission to video device\n /* istanbul ignore next */\n logger.log(\n `GroupCall ${this.groupCallId} setLocalVideoMuted() no device or permission to receive local stream, muted=${muted}`,\n );\n return false;\n }\n } else {\n logger.log(`GroupCall ${this.groupCallId} setLocalVideoMuted() no stream muted (muted=${muted})`);\n this.initWithVideoMuted = muted;\n }\n\n const updates: Promise<unknown>[] = [];\n this.forEachCall((call) => updates.push(call.setLocalVideoMuted(muted)));\n await Promise.all(updates);\n\n // We setTracksEnabled again, independently from the call doing it\n // internally, since we might not be expecting the call\n this.forEachCall((call) =>\n setTracksEnabled(call.localUsermediaFeed!.stream.getVideoTracks(), !muted && this.callExpected(call)),\n );\n\n this.emit(GroupCallEvent.LocalMuteStateChanged, this.isMicrophoneMuted(), muted);\n\n return true;\n }\n\n public async setScreensharingEnabled(enabled: boolean, opts: IScreensharingOpts = {}): Promise<boolean> {\n if (enabled === this.isScreensharing()) {\n return enabled;\n }\n\n if (enabled) {\n try {\n logger.log(\n `GroupCall ${this.groupCallId} setScreensharingEnabled() is asking for screensharing permissions`,\n );\n const stream = await this.client.getMediaHandler().getScreensharingStream(opts);\n\n for (const track of stream.getTracks()) {\n const onTrackEnded = (): void => {\n this.setScreensharingEnabled(false);\n track.removeEventListener(\"ended\", onTrackEnded);\n };\n\n track.addEventListener(\"ended\", onTrackEnded);\n }\n\n logger.log(\n `GroupCall ${this.groupCallId} setScreensharingEnabled() granted screensharing permissions. Setting screensharing enabled on all calls`,\n );\n\n this.localDesktopCapturerSourceId = opts.desktopCapturerSourceId;\n this.localScreenshareFeed = new CallFeed({\n client: this.client,\n roomId: this.room.roomId,\n userId: this.client.getUserId()!,\n deviceId: this.client.getDeviceId()!,\n stream,\n purpose: SDPStreamMetadataPurpose.Screenshare,\n audioMuted: false,\n videoMuted: false,\n });\n this.addScreenshareFeed(this.localScreenshareFeed);\n\n this.emit(\n GroupCallEvent.LocalScreenshareStateChanged,\n true,\n this.localScreenshareFeed,\n this.localDesktopCapturerSourceId,\n );\n\n // TODO: handle errors\n this.forEachCall((call) => call.pushLocalFeed(this.localScreenshareFeed!.clone()));\n\n return true;\n } catch (error) {\n if (opts.throwOnFail) throw error;\n logger.error(\n `GroupCall ${this.groupCallId} setScreensharingEnabled() enabling screensharing error`,\n error,\n );\n this.emit(\n GroupCallEvent.Error,\n new GroupCallError(\n GroupCallErrorCode.NoUserMedia,\n \"Failed to get screen-sharing stream: \",\n error as Error,\n ),\n );\n return false;\n }\n } else {\n this.forEachCall((call) => {\n if (call.localScreensharingFeed) call.removeLocalFeed(call.localScreensharingFeed);\n });\n this.client.getMediaHandler().stopScreensharingStream(this.localScreenshareFeed!.stream);\n this.removeScreenshareFeed(this.localScreenshareFeed!);\n this.localScreenshareFeed = undefined;\n this.localDesktopCapturerSourceId = undefined;\n this.emit(GroupCallEvent.LocalScreenshareStateChanged, false, undefined, undefined);\n return false;\n }\n }\n\n public isScreensharing(): boolean {\n return !!this.localScreenshareFeed;\n }\n\n /*\n * Call Setup\n *\n * There are two different paths for calls to be created:\n * 1. Incoming calls triggered by the Call.incoming event.\n * 2. Outgoing calls to the initial members of a room or new members\n * as they are observed by the RoomState.members event.\n */\n\n private onIncomingCall = (newCall: MatrixCall): void => {\n // The incoming calls may be for another room, which we will ignore.\n if (newCall.roomId !== this.room.roomId) {\n return;\n }\n\n if (newCall.state !== CallState.Ringing) {\n logger.warn(\n `GroupCall ${this.groupCallId} onIncomingCall() incoming call no longer in ringing state - ignoring`,\n );\n return;\n }\n\n if (!newCall.groupCallId || newCall.groupCallId !== this.groupCallId) {\n logger.log(\n `GroupCall ${this.groupCallId} onIncomingCall() ignored because it doesn't match the current group call`,\n );\n newCall.reject();\n return;\n }\n\n const opponentUserId = newCall.getOpponentMember()?.userId;\n if (opponentUserId === undefined) {\n logger.warn(`GroupCall ${this.groupCallId} onIncomingCall() incoming call with no member - ignoring`);\n return;\n }\n\n const deviceMap = this.calls.get(opponentUserId) ?? new Map<string, MatrixCall>();\n const prevCall = deviceMap.get(newCall.getOpponentDeviceId()!);\n\n if (prevCall?.callId === newCall.callId) return;\n\n logger.log(\n `GroupCall ${this.groupCallId} onIncomingCall() incoming call (userId=${opponentUserId}, callId=${newCall.callId})`,\n );\n\n if (prevCall) prevCall.hangup(CallErrorCode.Replaced, false);\n\n this.initCall(newCall);\n\n const feeds = this.getLocalFeeds().map((feed) => feed.clone());\n if (!this.callExpected(newCall)) {\n // Disable our tracks for users not explicitly participating in the\n // call but trying to receive the feeds\n for (const feed of feeds) {\n setTracksEnabled(feed.stream.getAudioTracks(), false);\n setTracksEnabled(feed.stream.getVideoTracks(), false);\n }\n }\n newCall.answerWithCallFeeds(feeds);\n\n deviceMap.set(newCall.getOpponentDeviceId()!, newCall);\n this.calls.set(opponentUserId, deviceMap);\n this.emit(GroupCallEvent.CallsChanged, this.calls);\n };\n\n /**\n * Determines whether a given participant expects us to call them (versus\n * them calling us).\n * @param userId - The participant's user ID.\n * @param deviceId - The participant's device ID.\n * @returns Whether we need to place an outgoing call to the participant.\n */\n private wantsOutgoingCall(userId: string, deviceId: string): boolean {\n const localUserId = this.client.getUserId()!;\n const localDeviceId = this.client.getDeviceId()!;\n return (\n // If a user's ID is less than our own, they'll call us\n userId >= localUserId &&\n // If this is another one of our devices, compare device IDs to tell whether it'll call us\n (userId !== localUserId || deviceId > localDeviceId)\n );\n }\n\n /**\n * Places calls to all participants that we're responsible for calling.\n */\n private placeOutgoingCalls(): void {\n let callsChanged = false;\n\n for (const [{ userId }, participantMap] of this.participants) {\n const callMap = this.calls.get(userId) ?? new Map<string, MatrixCall>();\n\n for (const [deviceId, participant] of participantMap) {\n const prevCall = callMap.get(deviceId);\n\n if (\n prevCall?.getOpponentSessionId() !== participant.sessionId &&\n this.wantsOutgoingCall(userId, deviceId)\n ) {\n callsChanged = true;\n\n if (prevCall !== undefined) {\n logger.debug(\n `GroupCall ${this.groupCallId} placeOutgoingCalls() replacing call (userId=${userId}, deviceId=${deviceId}, callId=${prevCall.callId})`,\n );\n prevCall.hangup(CallErrorCode.NewSession, false);\n }\n\n const newCall = createNewMatrixCall(this.client, this.room.roomId, {\n invitee: userId,\n opponentDeviceId: deviceId,\n opponentSessionId: participant.sessionId,\n groupCallId: this.groupCallId,\n });\n\n if (newCall === null) {\n logger.error(\n `GroupCall ${this.groupCallId} placeOutgoingCalls() failed to create call (userId=${userId}, device=${deviceId})`,\n );\n callMap.delete(deviceId);\n } else {\n this.initCall(newCall);\n callMap.set(deviceId, newCall);\n\n logger.debug(\n `GroupCall ${this.groupCallId} placeOutgoingCalls() placing call (userId=${userId}, deviceId=${deviceId}, sessionId=${participant.sessionId})`,\n );\n\n newCall\n .placeCallWithCallFeeds(\n this.getLocalFeeds().map((feed) => feed.clone()),\n participant.screensharing,\n )\n .then(() => {\n if (this.dataChannelsEnabled) {\n newCall.createDataChannel(\"datachannel\", this.dataChannelOptions);\n }\n })\n .catch((e) => {\n logger.warn(\n `GroupCall ${this.groupCallId} placeOutgoingCalls() failed to place call (userId=${userId})`,\n e,\n );\n\n if (e instanceof CallError && e.code === GroupCallErrorCode.UnknownDevice) {\n this.emit(GroupCallEvent.Error, e);\n } else {\n this.emit(\n GroupCallEvent.Error,\n new GroupCallError(\n GroupCallErrorCode.PlaceCallFailed,\n `Failed to place call to ${userId}`,\n ),\n );\n }\n\n newCall.hangup(CallErrorCode.SignallingFailed, false);\n if (callMap.get(deviceId) === newCall) callMap.delete(deviceId);\n });\n }\n }\n }\n\n if (callMap.size > 0) {\n this.calls.set(userId, callMap);\n } else {\n this.calls.delete(userId);\n }\n }\n\n if (callsChanged) this.emit(GroupCallEvent.CallsChanged, this.calls);\n }\n\n /*\n * Room Member State\n */\n\n private getMemberStateEvents(): MatrixEvent[];\n private getMemberStateEvents(userId: string): MatrixEvent | null;\n private getMemberStateEvents(userId?: string): MatrixEvent[] | MatrixEvent | null {\n return userId === undefined\n ? this.room.currentState.getStateEvents(EventType.GroupCallMemberPrefix)\n : this.room.currentState.getStateEvents(EventType.GroupCallMemberPrefix, userId);\n }\n\n private onRetryCallLoop = (): void => {\n let needsRetry = false;\n\n for (const [{ userId }, participantMap] of this.participants) {\n const callMap = this.calls.get(userId);\n let retriesMap = this.retryCallCounts.get(userId);\n\n for (const [deviceId, participant] of participantMap) {\n const call = callMap?.get(deviceId);\n const retries = retriesMap?.get(deviceId) ?? 0;\n\n if (\n call?.getOpponentSessionId() !== participant.sessionId &&\n this.wantsOutgoingCall(userId, deviceId) &&\n retries < 3\n ) {\n if (retriesMap === undefined) {\n retriesMap = new Map();\n this.retryCallCounts.set(userId, retriesMap);\n }\n retriesMap.set(deviceId, retries + 1);\n needsRetry = true;\n }\n }\n }\n\n if (needsRetry) this.placeOutgoingCalls();\n };\n\n private initCall(call: MatrixCall): void {\n const opponentMemberId = getCallUserId(call);\n\n if (!opponentMemberId) {\n throw new Error(\"Cannot init call without user id\");\n }\n\n const onCallFeedsChanged = (): void => this.onCallFeedsChanged(call);\n const onCallStateChanged = (state: CallState, oldState?: CallState): void =>\n this.onCallStateChanged(call, state, oldState);\n const onCallHangup = this.onCallHangup;\n const onCallReplaced = (newCall: MatrixCall): void => this.onCallReplaced(call, newCall);\n\n let deviceMap = this.callHandlers.get(opponentMemberId);\n if (deviceMap === undefined) {\n deviceMap = new Map();\n this.callHandlers.set(opponentMemberId, deviceMap);\n }\n\n deviceMap.set(call.getOpponentDeviceId()!, {\n onCallFeedsChanged,\n onCallStateChanged,\n onCallHangup,\n onCallReplaced,\n });\n\n call.on(CallEvent.FeedsChanged, onCallFeedsChanged);\n call.on(CallEvent.State, onCallStateChanged);\n call.on(CallEvent.Hangup, onCallHangup);\n call.on(CallEvent.Replaced, onCallReplaced);\n\n call.isPtt = this.isPtt;\n\n this.reEmitter.reEmit(call, Object.values(CallEvent));\n\n call.initStats(this.stats);\n\n onCallFeedsChanged();\n }\n\n private disposeCall(call: MatrixCall, hangupReason: CallErrorCode): void {\n const opponentMemberId = getCallUserId(call);\n const opponentDeviceId = call.getOpponentDeviceId()!;\n\n if (!opponentMemberId) {\n throw new Error(\"Cannot dispose call without user id\");\n }\n\n const deviceMap = this.callHandlers.get(opponentMemberId)!;\n const { onCallFeedsChanged, onCallStateChanged, onCallHangup, onCallReplaced } =\n deviceMap.get(opponentDeviceId)!;\n\n call.removeListener(CallEvent.FeedsChanged, onCallFeedsChanged);\n call.removeListener(CallEvent.State, onCallStateChanged);\n call.removeListener(CallEvent.Hangup, onCallHangup);\n call.removeListener(CallEvent.Replaced, onCallReplaced);\n\n deviceMap.delete(opponentMemberId);\n if (deviceMap.size === 0) this.callHandlers.delete(opponentMemberId);\n\n if (call.hangupReason === CallErrorCode.Replaced) {\n return;\n }\n\n const usermediaFeed = this.getUserMediaFeed(opponentMemberId, opponentDeviceId);\n\n if (usermediaFeed) {\n this.removeUserMediaFeed(usermediaFeed);\n }\n\n const screenshareFeed = this.getScreenshareFeed(opponentMemberId, opponentDeviceId);\n\n if (screenshareFeed) {\n this.removeScreenshareFeed(screenshareFeed);\n }\n }\n\n private onCallFeedsChanged = (call: MatrixCall): void => {\n const opponentMemberId = getCallUserId(call);\n const opponentDeviceId = call.getOpponentDeviceId()!;\n\n if (!opponentMemberId) {\n throw new Error(\"Cannot change call feeds without user id\");\n }\n\n const currentUserMediaFeed = this.getUserMediaFeed(opponentMemberId, opponentDeviceId);\n const remoteUsermediaFeed = call.remoteUsermediaFeed;\n const remoteFeedChanged = remoteUsermediaFeed !== currentUserMediaFeed;\n\n if (remoteFeedChanged) {\n if (!currentUserMediaFeed && remoteUsermediaFeed) {\n this.addUserMediaFeed(remoteUsermediaFeed);\n } else if (currentUserMediaFeed && remoteUsermediaFeed) {\n this.replaceUserMediaFeed(currentUserMediaFeed, remoteUsermediaFeed);\n } else if (currentUserMediaFeed && !remoteUsermediaFeed) {\n this.removeUserMediaFeed(currentUserMediaFeed);\n }\n }\n\n const currentScreenshareFeed = this.getScreenshareFeed(opponentMemberId, opponentDeviceId);\n const remoteScreensharingFeed = call.remoteScreensharingFeed;\n const remoteScreenshareFeedChanged = remoteScreensharingFeed !== currentScreenshareFeed;\n\n if (remoteScreenshareFeedChanged) {\n if (!currentScreenshareFeed && remoteScreensharingFeed) {\n this.addScreenshareFeed(remoteScreensharingFeed);\n } else if (currentScreenshareFeed && remoteScreensharingFeed) {\n this.replaceScreenshareFeed(currentScreenshareFeed, remoteScreensharingFeed);\n } else if (currentScreenshareFeed && !remoteScreensharingFeed) {\n this.removeScreenshareFeed(currentScreenshareFeed);\n }\n }\n };\n\n private onCallStateChanged = (call: MatrixCall, state: CallState, _oldState: CallState | undefined): void => {\n if (state === CallState.Ended) return;\n\n const audioMuted = this.localCallFeed!.isAudioMuted();\n\n if (call.localUsermediaStream && call.isMicrophoneMuted() !== audioMuted) {\n call.setMicrophoneMuted(audioMuted);\n }\n\n const videoMuted = this.localCallFeed!.isVideoMuted();\n\n if (call.localUsermediaStream && call.isLocalVideoMuted() !== videoMuted) {\n call.setLocalVideoMuted(videoMuted);\n }\n\n const opponentUserId = call.getOpponentMember()?.userId;\n if (state === CallState.Connected && opponentUserId) {\n const retriesMap = this.retryCallCounts.get(opponentUserId);\n retriesMap?.delete(call.getOpponentDeviceId()!);\n if (retriesMap?.size === 0) this.retryCallCounts.delete(opponentUserId);\n }\n };\n\n private onCallHangup = (call: MatrixCall): void => {\n if (call.hangupReason === CallErrorCode.Replaced) return;\n\n const opponentUserId = call.getOpponentMember()?.userId ?? this.room.getMember(call.invitee!)!.userId;\n const deviceMap = this.calls.get(opponentUserId);\n\n // Sanity check that this call is in fact in the map\n if (deviceMap?.get(call.getOpponentDeviceId()!) === call) {\n this.disposeCall(call, call.hangupReason as CallErrorCode);\n deviceMap.delete(call.getOpponentDeviceId()!);\n if (deviceMap.size === 0) this.calls.delete(opponentUserId);\n this.emit(GroupCallEvent.CallsChanged, this.calls);\n }\n };\n\n private onCallReplaced = (prevCall: MatrixCall, newCall: MatrixCall): void => {\n const opponentUserId = prevCall.getOpponentMember()!.userId;\n\n let deviceMap = this.calls.get(opponentUserId);\n if (deviceMap === undefined) {\n deviceMap = new Map();\n this.calls.set(opponentUserId, deviceMap);\n }\n\n prevCall.hangup(CallErrorCode.Replaced, false);\n this.initCall(newCall);\n deviceMap.set(prevCall.getOpponentDeviceId()!, newCall);\n this.emit(GroupCallEvent.CallsChanged, this.calls);\n };\n\n /*\n * UserMedia CallFeed Event Handlers\n */\n\n public getUserMediaFeed(userId: string, deviceId: string): CallFeed | undefined {\n return this.userMediaFeeds.find((f) => f.userId === userId && f.deviceId! === deviceId);\n }\n\n private addUserMediaFeed(callFeed: CallFeed): void {\n this.userMediaFeeds.push(callFeed);\n callFeed.measureVolumeActivity(true);\n this.emit(GroupCallEvent.UserMediaFeedsChanged, this.userMediaFeeds);\n }\n\n private replaceUserMediaFeed(existingFeed: CallFeed, replacementFeed: CallFeed): void {\n const feedIndex = this.userMediaFeeds.findIndex(\n (f) => f.userId === existingFeed.userId && f.deviceId! === existingFeed.deviceId,\n );\n\n if (feedIndex === -1) {\n throw new Error(\"Couldn't find user media feed to replace\");\n }\n\n this.userMediaFeeds.splice(feedIndex, 1, replacementFeed);\n\n existingFeed.dispose();\n replacementFeed.measureVolumeActivity(true);\n this.emit(GroupCallEvent.UserMediaFeedsChanged, this.userMediaFeeds);\n }\n\n private removeUserMediaFeed(callFeed: CallFeed): void {\n const feedIndex = this.userMediaFeeds.findIndex(\n (f) => f.userId === callFeed.userId && f.deviceId! === callFeed.deviceId,\n );\n\n if (feedIndex === -1) {\n throw new Error(\"Couldn't find user media feed to remove\");\n }\n\n this.userMediaFeeds.splice(feedIndex, 1);\n\n callFeed.dispose();\n this.emit(GroupCallEvent.UserMediaFeedsChanged, this.userMediaFeeds);\n\n if (this.activeSpeaker === callFeed) {\n this.activeSpeaker = this.userMediaFeeds[0];\n this.emit(GroupCallEvent.ActiveSpeakerChanged, this.activeSpeaker);\n }\n }\n\n private onActiveSpeakerLoop = (): void => {\n let topAvg: number | undefined = undefined;\n let nextActiveSpeaker: CallFeed | undefined = undefined;\n\n for (const callFeed of this.userMediaFeeds) {\n if (callFeed.isLocal() && this.userMediaFeeds.length > 1) continue;\n\n const total = callFeed.speakingVolumeSamples.reduce(\n (acc, volume) => acc + Math.max(volume, SPEAKING_THRESHOLD),\n );\n const avg = total / callFeed.speakingVolumeSamples.length;\n\n if (!topAvg || avg > topAvg) {\n topAvg = avg;\n nextActiveSpeaker = callFeed;\n }\n }\n\n if (nextActiveSpeaker && this.activeSpeaker !== nextActiveSpeaker && topAvg && topAvg > SPEAKING_THRESHOLD) {\n this.activeSpeaker = nextActiveSpeaker;\n this.emit(GroupCallEvent.ActiveSpeakerChanged, this.activeSpeaker);\n }\n };\n\n /*\n * Screenshare Call Feed Event Handlers\n */\n\n public getScreenshareFeed(userId: string, deviceId: string): CallFeed | undefined {\n return this.screenshareFeeds.find((f) => f.userId === userId && f.deviceId! === deviceId);\n }\n\n private addScreenshareFeed(callFeed: CallFeed): void {\n this.screenshareFeeds.push(callFeed);\n this.emit(GroupCallEvent.ScreenshareFeedsChanged, this.screenshareFeeds);\n }\n\n private replaceScreenshareFeed(existingFeed: CallFeed, replacementFeed: CallFeed): void {\n const feedIndex = this.screenshareFeeds.findIndex(\n (f) => f.userId === existingFeed.userId && f.deviceId! === existingFeed.deviceId,\n );\n\n if (feedIndex === -1) {\n throw new Error(\"Couldn't find screenshare feed to replace\");\n }\n\n this.screenshareFeeds.splice(feedIndex, 1, replacementFeed);\n\n existingFeed.dispose();\n this.emit(GroupCallEvent.ScreenshareFeedsChanged, this.screenshareFeeds);\n }\n\n private removeScreenshareFeed(callFeed: CallFeed): void {\n const feedIndex = this.screenshareFeeds.findIndex(\n (f) => f.userId === callFeed.userId && f.deviceId! === callFeed.deviceId,\n );\n\n if (feedIndex === -1) {\n throw new Error(\"Couldn't find screenshare feed to remove\");\n }\n\n this.screenshareFeeds.splice(feedIndex, 1);\n\n callFeed.dispose();\n this.emit(GroupCallEvent.ScreenshareFeedsChanged, this.screenshareFeeds);\n }\n\n /**\n * Recalculates and updates the participant map to match the room state.\n */\n private updateParticipants(): void {\n const localMember = this.room.getMember(this.client.getUserId()!)!;\n if (!localMember) {\n // The client hasn't fetched enough of the room state to get our own member\n // event. This probably shouldn't happen, but sanity check & exit for now.\n logger.warn(\n `GroupCall ${this.groupCallId} updateParticipants() tried to update participants before local room member is available`,\n );\n return;\n }\n\n if (this.participantsExpirationTimer !== null) {\n clearTimeout(this.participantsExpirationTimer);\n this.participantsExpirationTimer = null;\n }\n\n if (this.state === GroupCallState.Ended) {\n this.participants = new Map();\n return;\n }\n\n const participants = new Map<RoomMember, Map<string, ParticipantState>>();\n const now = Date.now();\n const entered = this.state === GroupCallState.Entered || this.enteredViaAnotherSession;\n let nextExpiration = Infinity;\n\n for (const e of this.getMemberStateEvents()) {\n const member = this.room.getMember(e.getStateKey()!);\n const content = e.getContent<Record<any, unknown>>();\n const calls: Record<any, unknown>[] = Array.isArray(content[\"m.calls\"]) ? content[\"m.calls\"] : [];\n const call = calls.find((call) => call[\"m.call_id\"] === this.groupCallId);\n const devices: Record<any, unknown>[] = Array.isArray(call?.[\"m.devices\"]) ? call![\"m.devices\"] : [];\n\n // Filter out invalid and expired devices\n let validDevices = devices.filter(\n (d) =>\n typeof d.device_id === \"string\" &&\n typeof d.session_id === \"string\" &&\n typeof d.expires_ts === \"number\" &&\n d.expires_ts > now &&\n Array.isArray(d.feeds),\n ) as unknown as IGroupCallRoomMemberDevice[];\n\n // Apply local echo for the unentered case\n if (!entered && member?.userId === this.client.getUserId()!) {\n validDevices = validDevices.filter((d) => d.device_id !== this.client.getDeviceId()!);\n }\n\n // Must have a connected device and be joined to the room\n if (validDevices.length > 0 && member?.membership === \"join\") {\n const deviceMap = new Map<string, ParticipantState>();\n participants.set(member, deviceMap);\n\n for (const d of validDevices) {\n deviceMap.set(d.device_id, {\n sessionId: d.session_id,\n screensharing: d.feeds.some((f) => f.purpose === SDPStreamMetadataPurpose.Screenshare),\n });\n if (d.expires_ts < nextExpiration) nextExpiration = d.expires_ts;\n }\n }\n }\n\n // Apply local echo for the entered case\n if (entered) {\n let deviceMap = participants.get(localMember);\n if (deviceMap === undefined) {\n deviceMap = new Map();\n participants.set(localMember, deviceMap);\n }\n\n if (!deviceMap.has(this.client.getDeviceId()!)) {\n deviceMap.set(this.client.getDeviceId()!, {\n sessionId: this.client.getSessionId(),\n screensharing: this.getLocalFeeds().some((f) => f.purpose === SDPStreamMetadataPurpose.Screenshare),\n });\n }\n }\n\n this.participants = participants;\n if (nextExpiration < Infinity) {\n this.participantsExpirationTimer = setTimeout(() => this.updateParticipants(), nextExpiration - now);\n }\n }\n\n /**\n * Updates the local user's member state with the devices returned by the given function.\n * @param fn - A function from the current devices to the new devices. If it\n * returns null, the update will be skipped.\n * @param keepAlive - Whether the request should outlive the window.\n */\n private async updateDevices(\n fn: (devices: IGroupCallRoomMemberDevice[]) => IGroupCallRoomMemberDevice[] | null,\n keepAlive = false,\n ): Promise<void> {\n const now = Date.now();\n const localUserId = this.client.getUserId()!;\n\n const event = this.getMemberStateEvents(localUserId);\n const content = event?.getContent<Record<any, unknown>>() ?? {};\n const calls: Record<any, unknown>[] = Array.isArray(content[\"m.calls\"]) ? content[\"m.calls\"] : [];\n\n let call: Record<any, unknown> | null = null;\n const otherCalls: Record<any, unknown>[] = [];\n for (const c of calls) {\n if (c[\"m.call_id\"] === this.groupCallId) {\n call = c;\n } else {\n otherCalls.push(c);\n }\n }\n if (call === null) call = {};\n\n const devices: Record<any, unknown>[] = Array.isArray(call[\"m.devices\"]) ? call[\"m.devices\"] : [];\n\n // Filter out invalid and expired devices\n const validDevices = devices.filter(\n (d) =>\n typeof d.device_id === \"string\" &&\n typeof d.session_id === \"string\" &&\n typeof d.expires_ts === \"number\" &&\n d.expires_ts > now &&\n Array.isArray(d.feeds),\n ) as unknown as IGroupCallRoomMemberDevice[];\n\n const newDevices = fn(validDevices);\n if (newDevices === null) return;\n\n const newCalls = [...(otherCalls as unknown as IGroupCallRoomMemberCallState[])];\n if (newDevices.length > 0) {\n newCalls.push({\n ...call,\n \"m.call_id\": this.groupCallId,\n \"m.devices\": newDevices,\n });\n }\n\n const newContent: IGroupCallRoomMemberState = { \"m.calls\": newCalls };\n\n await this.client.sendStateEvent(this.room.roomId, EventType.GroupCallMemberPrefix, newContent, localUserId, {\n keepAlive,\n });\n }\n\n private async addDeviceToMemberState(): Promise<void> {\n await this.updateDevices((devices) => [\n ...devices.filter((d) => d.device_id !== this.client.getDeviceId()!),\n {\n device_id: this.client.getDeviceId()!,\n session_id: this.client.getSessionId(),\n expires_ts: Date.now() + DEVICE_TIMEOUT,\n feeds: this.getLocalFeeds().map((feed) => ({ purpose: feed.purpose })),\n // TODO: Add data channels\n },\n ]);\n }\n\n private async updateMemberState(): Promise<void> {\n // Clear the old update interval before proceeding\n if (this.resendMemberStateTimer !== null) {\n clearInterval(this.resendMemberStateTimer);\n this.resendMemberStateTimer = null;\n }\n\n if (this.state === GroupCallState.Entered) {\n // Add the local device\n await this.addDeviceToMemberState();\n\n // Resend the state event every so often so it doesn't become stale\n this.resendMemberStateTimer = setInterval(async () => {\n logger.log(`GroupCall ${this.groupCallId} updateMemberState() resending call member state\"`);\n try {\n await this.addDeviceToMemberState();\n } catch (e) {\n logger.error(\n `GroupCall ${this.groupCallId} updateMemberState() failed to resend call member state`,\n e,\n );\n }\n }, (DEVICE_TIMEOUT * 3) / 4);\n } else {\n // Remove the local device\n await this.updateDevices(\n (devices) => devices.filter((d) => d.device_id !== this.client.getDeviceId()!),\n true,\n );\n }\n }\n\n /**\n * Cleans up our member state by filtering out logged out devices, inactive\n * devices, and our own device (if we know we haven't entered).\n */\n public async cleanMemberState(): Promise<void> {\n const { devices: myDevices } = await this.client.getDevices();\n const deviceMap = new Map<string, IMyDevice>(myDevices.map((d) => [d.device_id, d]));\n\n // updateDevices takes care of filtering out inactive devices for us\n await this.updateDevices((devices) => {\n const newDevices = devices.filter((d) => {\n const device = deviceMap.get(d.device_id);\n return (\n device?.last_seen_ts !== undefined &&\n !(\n d.device_id === this.client.getDeviceId()! &&\n this.state !== GroupCallState.Entered &&\n !this.enteredViaAnotherSession\n )\n );\n });\n\n // Skip the update if the devices are unchanged\n return newDevices.length === devices.length ? null : newDevices;\n });\n }\n\n private onRoomState = (): void => this.updateParticipants();\n\n private onParticipantsChanged = (): void => {\n // Re-run setTracksEnabled on all calls, so that participants that just\n // left get denied access to our media, and participants that just\n // joined get granted access\n this.forEachCall((call) => {\n const expected = this.callExpected(call);\n for (const feed of call.getLocalFeeds()) {\n setTracksEnabled(feed.stream.getAudioTracks(), !feed.isAudioMuted() && expected);\n setTracksEnabled(feed.stream.getVideoTracks(), !feed.isVideoMuted() && expected);\n }\n });\n\n if (this.state === GroupCallState.Entered) this.placeOutgoingCalls();\n };\n\n private onStateChanged = (newState: GroupCallState, oldState: GroupCallState): void => {\n if (\n newState === GroupCallState.Entered ||\n oldState === GroupCallState.Entered ||\n newState === GroupCallState.Ended\n ) {\n // We either entered, left, or ended the call\n this.updateParticipants();\n this.updateMemberState().catch((e) =>\n logger.error(\n `GroupCall ${this.groupCallId} onStateChanged() failed to update member state devices\"`,\n e,\n ),\n );\n }\n };\n\n private onLocalFeedsChanged = (): void => {\n if (this.state === GroupCallState.Entered) {\n this.updateMemberState().catch((e) =>\n logger.error(\n `GroupCall ${this.groupCallId} onLocalFeedsChanged() failed to update member state feeds`,\n e,\n ),\n );\n }\n };\n\n public getGroupCallStats(): GroupCallStats {\n return this.stats;\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAaA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AAEA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AACA,IAAAS,sBAAA,GAAAT,OAAA;AAEA,IAAAU,M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