@unwanted/matrix-sdk-mini 34.12.0-1 → 34.12.0-2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. package/git-revision.txt +1 -1
  2. package/lib/@types/event.d.ts +0 -19
  3. package/lib/@types/event.d.ts.map +1 -1
  4. package/lib/@types/event.js.map +1 -1
  5. package/lib/client.d.ts +2 -50
  6. package/lib/client.d.ts.map +1 -1
  7. package/lib/client.js +391 -501
  8. package/lib/client.js.map +1 -1
  9. package/lib/embedded.d.ts.map +1 -1
  10. package/lib/embedded.js +0 -1
  11. package/lib/embedded.js.map +1 -1
  12. package/lib/matrix.d.ts +0 -6
  13. package/lib/matrix.d.ts.map +1 -1
  14. package/lib/matrix.js +1 -5
  15. package/lib/matrix.js.map +1 -1
  16. package/package.json +1 -1
  17. package/src/@types/event.ts +2 -36
  18. package/src/client.ts +1 -150
  19. package/src/embedded.ts +0 -2
  20. package/src/matrix.ts +0 -13
  21. package/lib/matrixrtc/CallMembership.d.ts +0 -66
  22. package/lib/matrixrtc/CallMembership.d.ts.map +0 -1
  23. package/lib/matrixrtc/CallMembership.js +0 -197
  24. package/lib/matrixrtc/CallMembership.js.map +0 -1
  25. package/lib/matrixrtc/LivekitFocus.d.ts +0 -16
  26. package/lib/matrixrtc/LivekitFocus.d.ts.map +0 -1
  27. package/lib/matrixrtc/LivekitFocus.js +0 -20
  28. package/lib/matrixrtc/LivekitFocus.js.map +0 -1
  29. package/lib/matrixrtc/MatrixRTCSession.d.ts +0 -295
  30. package/lib/matrixrtc/MatrixRTCSession.d.ts.map +0 -1
  31. package/lib/matrixrtc/MatrixRTCSession.js +0 -1043
  32. package/lib/matrixrtc/MatrixRTCSession.js.map +0 -1
  33. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +0 -40
  34. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +0 -1
  35. package/lib/matrixrtc/MatrixRTCSessionManager.js +0 -146
  36. package/lib/matrixrtc/MatrixRTCSessionManager.js.map +0 -1
  37. package/lib/matrixrtc/focus.d.ts +0 -10
  38. package/lib/matrixrtc/focus.d.ts.map +0 -1
  39. package/lib/matrixrtc/focus.js +0 -1
  40. package/lib/matrixrtc/focus.js.map +0 -1
  41. package/lib/matrixrtc/index.d.ts +0 -7
  42. package/lib/matrixrtc/index.d.ts.map +0 -1
  43. package/lib/matrixrtc/index.js +0 -21
  44. package/lib/matrixrtc/index.js.map +0 -1
  45. package/lib/matrixrtc/types.d.ts +0 -19
  46. package/lib/matrixrtc/types.d.ts.map +0 -1
  47. package/lib/matrixrtc/types.js +0 -1
  48. package/lib/matrixrtc/types.js.map +0 -1
  49. package/lib/webrtc/audioContext.d.ts +0 -15
  50. package/lib/webrtc/audioContext.d.ts.map +0 -1
  51. package/lib/webrtc/audioContext.js +0 -46
  52. package/lib/webrtc/audioContext.js.map +0 -1
  53. package/lib/webrtc/call.d.ts +0 -560
  54. package/lib/webrtc/call.d.ts.map +0 -1
  55. package/lib/webrtc/call.js +0 -2541
  56. package/lib/webrtc/call.js.map +0 -1
  57. package/lib/webrtc/callEventHandler.d.ts +0 -37
  58. package/lib/webrtc/callEventHandler.d.ts.map +0 -1
  59. package/lib/webrtc/callEventHandler.js +0 -344
  60. package/lib/webrtc/callEventHandler.js.map +0 -1
  61. package/lib/webrtc/callEventTypes.d.ts +0 -73
  62. package/lib/webrtc/callEventTypes.d.ts.map +0 -1
  63. package/lib/webrtc/callEventTypes.js +0 -13
  64. package/lib/webrtc/callEventTypes.js.map +0 -1
  65. package/lib/webrtc/callFeed.d.ts +0 -128
  66. package/lib/webrtc/callFeed.d.ts.map +0 -1
  67. package/lib/webrtc/callFeed.js +0 -289
  68. package/lib/webrtc/callFeed.js.map +0 -1
  69. package/lib/webrtc/groupCall.d.ts +0 -323
  70. package/lib/webrtc/groupCall.d.ts.map +0 -1
  71. package/lib/webrtc/groupCall.js +0 -1337
  72. package/lib/webrtc/groupCall.js.map +0 -1
  73. package/lib/webrtc/groupCallEventHandler.d.ts +0 -31
  74. package/lib/webrtc/groupCallEventHandler.d.ts.map +0 -1
  75. package/lib/webrtc/groupCallEventHandler.js +0 -178
  76. package/lib/webrtc/groupCallEventHandler.js.map +0 -1
  77. package/lib/webrtc/mediaHandler.d.ts +0 -89
  78. package/lib/webrtc/mediaHandler.d.ts.map +0 -1
  79. package/lib/webrtc/mediaHandler.js +0 -437
  80. package/lib/webrtc/mediaHandler.js.map +0 -1
  81. package/lib/webrtc/stats/callFeedStatsReporter.d.ts +0 -8
  82. package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +0 -1
  83. package/lib/webrtc/stats/callFeedStatsReporter.js +0 -82
  84. package/lib/webrtc/stats/callFeedStatsReporter.js.map +0 -1
  85. package/lib/webrtc/stats/callStatsReportGatherer.d.ts +0 -25
  86. package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +0 -1
  87. package/lib/webrtc/stats/callStatsReportGatherer.js +0 -199
  88. package/lib/webrtc/stats/callStatsReportGatherer.js.map +0 -1
  89. package/lib/webrtc/stats/callStatsReportSummary.d.ts +0 -17
  90. package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +0 -1
  91. package/lib/webrtc/stats/callStatsReportSummary.js +0 -1
  92. package/lib/webrtc/stats/callStatsReportSummary.js.map +0 -1
  93. package/lib/webrtc/stats/connectionStats.d.ts +0 -28
  94. package/lib/webrtc/stats/connectionStats.d.ts.map +0 -1
  95. package/lib/webrtc/stats/connectionStats.js +0 -26
  96. package/lib/webrtc/stats/connectionStats.js.map +0 -1
  97. package/lib/webrtc/stats/connectionStatsBuilder.d.ts +0 -5
  98. package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +0 -1
  99. package/lib/webrtc/stats/connectionStatsBuilder.js +0 -27
  100. package/lib/webrtc/stats/connectionStatsBuilder.js.map +0 -1
  101. package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +0 -7
  102. package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +0 -1
  103. package/lib/webrtc/stats/connectionStatsReportBuilder.js +0 -121
  104. package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +0 -1
  105. package/lib/webrtc/stats/groupCallStats.d.ts +0 -22
  106. package/lib/webrtc/stats/groupCallStats.d.ts.map +0 -1
  107. package/lib/webrtc/stats/groupCallStats.js +0 -78
  108. package/lib/webrtc/stats/groupCallStats.js.map +0 -1
  109. package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +0 -10
  110. package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +0 -1
  111. package/lib/webrtc/stats/media/mediaSsrcHandler.js +0 -57
  112. package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +0 -1
  113. package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +0 -12
  114. package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +0 -1
  115. package/lib/webrtc/stats/media/mediaTrackHandler.js +0 -62
  116. package/lib/webrtc/stats/media/mediaTrackHandler.js.map +0 -1
  117. package/lib/webrtc/stats/media/mediaTrackStats.d.ts +0 -86
  118. package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +0 -1
  119. package/lib/webrtc/stats/media/mediaTrackStats.js +0 -142
  120. package/lib/webrtc/stats/media/mediaTrackStats.js.map +0 -1
  121. package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +0 -22
  122. package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +0 -1
  123. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +0 -76
  124. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +0 -1
  125. package/lib/webrtc/stats/statsReport.d.ts +0 -99
  126. package/lib/webrtc/stats/statsReport.d.ts.map +0 -1
  127. package/lib/webrtc/stats/statsReport.js +0 -32
  128. package/lib/webrtc/stats/statsReport.js.map +0 -1
  129. package/lib/webrtc/stats/statsReportEmitter.d.ts +0 -15
  130. package/lib/webrtc/stats/statsReportEmitter.d.ts.map +0 -1
  131. package/lib/webrtc/stats/statsReportEmitter.js +0 -33
  132. package/lib/webrtc/stats/statsReportEmitter.js.map +0 -1
  133. package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +0 -16
  134. package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +0 -1
  135. package/lib/webrtc/stats/summaryStatsReportGatherer.js +0 -116
  136. package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +0 -1
  137. package/lib/webrtc/stats/trackStatsBuilder.d.ts +0 -19
  138. package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +0 -1
  139. package/lib/webrtc/stats/trackStatsBuilder.js +0 -168
  140. package/lib/webrtc/stats/trackStatsBuilder.js.map +0 -1
  141. package/lib/webrtc/stats/transportStats.d.ts +0 -11
  142. package/lib/webrtc/stats/transportStats.d.ts.map +0 -1
  143. package/lib/webrtc/stats/transportStats.js +0 -1
  144. package/lib/webrtc/stats/transportStats.js.map +0 -1
  145. package/lib/webrtc/stats/transportStatsBuilder.d.ts +0 -5
  146. package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +0 -1
  147. package/lib/webrtc/stats/transportStatsBuilder.js +0 -34
  148. package/lib/webrtc/stats/transportStatsBuilder.js.map +0 -1
  149. package/lib/webrtc/stats/valueFormatter.d.ts +0 -4
  150. package/lib/webrtc/stats/valueFormatter.d.ts.map +0 -1
  151. package/lib/webrtc/stats/valueFormatter.js +0 -25
  152. package/lib/webrtc/stats/valueFormatter.js.map +0 -1
  153. package/src/matrixrtc/CallMembership.ts +0 -247
  154. package/src/matrixrtc/LivekitFocus.ts +0 -39
  155. package/src/matrixrtc/MatrixRTCSession.ts +0 -1319
  156. package/src/matrixrtc/MatrixRTCSessionManager.ts +0 -166
  157. package/src/matrixrtc/focus.ts +0 -25
  158. package/src/matrixrtc/index.ts +0 -22
  159. package/src/matrixrtc/types.ts +0 -36
  160. package/src/webrtc/audioContext.ts +0 -44
  161. package/src/webrtc/call.ts +0 -3074
  162. package/src/webrtc/callEventHandler.ts +0 -425
  163. package/src/webrtc/callEventTypes.ts +0 -93
  164. package/src/webrtc/callFeed.ts +0 -364
  165. package/src/webrtc/groupCall.ts +0 -1735
  166. package/src/webrtc/groupCallEventHandler.ts +0 -234
  167. package/src/webrtc/mediaHandler.ts +0 -484
  168. package/src/webrtc/stats/callFeedStatsReporter.ts +0 -94
  169. package/src/webrtc/stats/callStatsReportGatherer.ts +0 -219
  170. package/src/webrtc/stats/callStatsReportSummary.ts +0 -30
  171. package/src/webrtc/stats/connectionStats.ts +0 -47
  172. package/src/webrtc/stats/connectionStatsBuilder.ts +0 -28
  173. package/src/webrtc/stats/connectionStatsReportBuilder.ts +0 -140
  174. package/src/webrtc/stats/groupCallStats.ts +0 -93
  175. package/src/webrtc/stats/media/mediaSsrcHandler.ts +0 -57
  176. package/src/webrtc/stats/media/mediaTrackHandler.ts +0 -76
  177. package/src/webrtc/stats/media/mediaTrackStats.ts +0 -176
  178. package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +0 -90
  179. package/src/webrtc/stats/statsReport.ts +0 -133
  180. package/src/webrtc/stats/statsReportEmitter.ts +0 -49
  181. package/src/webrtc/stats/summaryStatsReportGatherer.ts +0 -148
  182. package/src/webrtc/stats/trackStatsBuilder.ts +0 -207
  183. package/src/webrtc/stats/transportStats.ts +0 -26
  184. package/src/webrtc/stats/transportStatsBuilder.ts +0 -48
  185. package/src/webrtc/stats/valueFormatter.ts +0 -27
@@ -1,289 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /*
3
- Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- */
17
-
18
- import { SDPStreamMetadataPurpose } from "./callEventTypes.js";
19
- import { acquireContext, releaseContext } from "./audioContext.js";
20
- import { logger } from "../logger.js";
21
- import { TypedEventEmitter } from "../models/typed-event-emitter.js";
22
- import { CallEvent, CallState } from "./call.js";
23
- var POLLING_INTERVAL = 200; // ms
24
- export var SPEAKING_THRESHOLD = -60; // dB
25
- var SPEAKING_SAMPLE_COUNT = 8; // samples
26
-
27
- export var CallFeedEvent = /*#__PURE__*/function (CallFeedEvent) {
28
- CallFeedEvent["NewStream"] = "new_stream";
29
- CallFeedEvent["MuteStateChanged"] = "mute_state_changed";
30
- CallFeedEvent["LocalVolumeChanged"] = "local_volume_changed";
31
- CallFeedEvent["VolumeChanged"] = "volume_changed";
32
- CallFeedEvent["ConnectedChanged"] = "connected_changed";
33
- CallFeedEvent["Speaking"] = "speaking";
34
- CallFeedEvent["Disposed"] = "disposed";
35
- return CallFeedEvent;
36
- }({});
37
- export class CallFeed extends TypedEventEmitter {
38
- constructor(opts) {
39
- super();
40
- _defineProperty(this, "stream", void 0);
41
- _defineProperty(this, "sdpMetadataStreamId", void 0);
42
- _defineProperty(this, "userId", void 0);
43
- _defineProperty(this, "deviceId", void 0);
44
- _defineProperty(this, "purpose", void 0);
45
- _defineProperty(this, "speakingVolumeSamples", void 0);
46
- _defineProperty(this, "client", void 0);
47
- _defineProperty(this, "call", void 0);
48
- _defineProperty(this, "roomId", void 0);
49
- _defineProperty(this, "audioMuted", void 0);
50
- _defineProperty(this, "videoMuted", void 0);
51
- _defineProperty(this, "localVolume", 1);
52
- _defineProperty(this, "measuringVolumeActivity", false);
53
- _defineProperty(this, "audioContext", void 0);
54
- _defineProperty(this, "analyser", void 0);
55
- _defineProperty(this, "frequencyBinCount", void 0);
56
- _defineProperty(this, "speakingThreshold", SPEAKING_THRESHOLD);
57
- _defineProperty(this, "speaking", false);
58
- _defineProperty(this, "volumeLooperTimeout", void 0);
59
- _defineProperty(this, "_disposed", false);
60
- _defineProperty(this, "_connected", false);
61
- _defineProperty(this, "onAddTrack", () => {
62
- this.emit(CallFeedEvent.NewStream, this.stream);
63
- });
64
- _defineProperty(this, "onCallState", state => {
65
- if (state === CallState.Connected) {
66
- this.connected = true;
67
- } else if (state === CallState.Connecting) {
68
- this.connected = false;
69
- }
70
- });
71
- _defineProperty(this, "volumeLooper", () => {
72
- if (!this.analyser) return;
73
- if (!this.measuringVolumeActivity) return;
74
- this.analyser.getFloatFrequencyData(this.frequencyBinCount);
75
- var maxVolume = -Infinity;
76
- for (var volume of this.frequencyBinCount) {
77
- if (volume > maxVolume) {
78
- maxVolume = volume;
79
- }
80
- }
81
- this.speakingVolumeSamples.shift();
82
- this.speakingVolumeSamples.push(maxVolume);
83
- this.emit(CallFeedEvent.VolumeChanged, maxVolume);
84
- var newSpeaking = false;
85
- for (var _volume of this.speakingVolumeSamples) {
86
- if (_volume > this.speakingThreshold) {
87
- newSpeaking = true;
88
- break;
89
- }
90
- }
91
- if (this.speaking !== newSpeaking) {
92
- this.speaking = newSpeaking;
93
- this.emit(CallFeedEvent.Speaking, this.speaking);
94
- }
95
- this.volumeLooperTimeout = setTimeout(this.volumeLooper, POLLING_INTERVAL);
96
- });
97
- this.client = opts.client;
98
- this.call = opts.call;
99
- this.roomId = opts.roomId;
100
- this.userId = opts.userId;
101
- this.deviceId = opts.deviceId;
102
- this.purpose = opts.purpose;
103
- this.audioMuted = opts.audioMuted;
104
- this.videoMuted = opts.videoMuted;
105
- this.speakingVolumeSamples = new Array(SPEAKING_SAMPLE_COUNT).fill(-Infinity);
106
- this.sdpMetadataStreamId = opts.stream.id;
107
- this.updateStream(null, opts.stream);
108
- this.stream = opts.stream; // updateStream does this, but this makes TS happier
109
-
110
- if (this.hasAudioTrack) {
111
- this.initVolumeMeasuring();
112
- }
113
- if (opts.call) {
114
- opts.call.addListener(CallEvent.State, this.onCallState);
115
- this.onCallState(opts.call.state);
116
- }
117
- }
118
- get connected() {
119
- // Local feeds are always considered connected
120
- return this.isLocal() || this._connected;
121
- }
122
- set connected(connected) {
123
- this._connected = connected;
124
- this.emit(CallFeedEvent.ConnectedChanged, this.connected);
125
- }
126
- get hasAudioTrack() {
127
- return this.stream.getAudioTracks().length > 0;
128
- }
129
- updateStream(oldStream, newStream) {
130
- if (newStream === oldStream) return;
131
- var wasMeasuringVolumeActivity = this.measuringVolumeActivity;
132
- if (oldStream) {
133
- oldStream.removeEventListener("addtrack", this.onAddTrack);
134
- this.measureVolumeActivity(false);
135
- }
136
- this.stream = newStream;
137
- newStream.addEventListener("addtrack", this.onAddTrack);
138
- if (this.hasAudioTrack) {
139
- this.initVolumeMeasuring();
140
- if (wasMeasuringVolumeActivity) this.measureVolumeActivity(true);
141
- } else {
142
- this.measureVolumeActivity(false);
143
- }
144
- this.emit(CallFeedEvent.NewStream, this.stream);
145
- }
146
- initVolumeMeasuring() {
147
- if (!this.hasAudioTrack) return;
148
- if (!this.audioContext) this.audioContext = acquireContext();
149
- this.analyser = this.audioContext.createAnalyser();
150
- this.analyser.fftSize = 512;
151
- this.analyser.smoothingTimeConstant = 0.1;
152
- var mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream);
153
- mediaStreamAudioSourceNode.connect(this.analyser);
154
- this.frequencyBinCount = new Float32Array(this.analyser.frequencyBinCount);
155
- }
156
- /**
157
- * Returns callRoom member
158
- * @returns member of the callRoom
159
- */
160
- getMember() {
161
- var _callRoom$getMember;
162
- var callRoom = this.client.getRoom(this.roomId);
163
- return (_callRoom$getMember = callRoom === null || callRoom === void 0 ? void 0 : callRoom.getMember(this.userId)) !== null && _callRoom$getMember !== void 0 ? _callRoom$getMember : null;
164
- }
165
-
166
- /**
167
- * Returns true if CallFeed is local, otherwise returns false
168
- * @returns is local?
169
- */
170
- isLocal() {
171
- return this.userId === this.client.getUserId() && (this.deviceId === undefined || this.deviceId === this.client.getDeviceId());
172
- }
173
-
174
- /**
175
- * Returns true if audio is muted or if there are no audio
176
- * tracks, otherwise returns false
177
- * @returns is audio muted?
178
- */
179
- isAudioMuted() {
180
- return this.stream.getAudioTracks().length === 0 || this.audioMuted;
181
- }
182
-
183
- /**
184
- * Returns true video is muted or if there are no video
185
- * tracks, otherwise returns false
186
- * @returns is video muted?
187
- */
188
- isVideoMuted() {
189
- // We assume only one video track
190
- return this.stream.getVideoTracks().length === 0 || this.videoMuted;
191
- }
192
- isSpeaking() {
193
- return this.speaking;
194
- }
195
-
196
- /**
197
- * Replaces the current MediaStream with a new one.
198
- * The stream will be different and new stream as remote parties are
199
- * concerned, but this can be used for convenience locally to set up
200
- * volume listeners automatically on the new stream etc.
201
- * @param newStream - new stream with which to replace the current one
202
- */
203
- setNewStream(newStream) {
204
- this.updateStream(this.stream, newStream);
205
- }
206
-
207
- /**
208
- * Set one or both of feed's internal audio and video video mute state
209
- * Either value may be null to leave it as-is
210
- * @param audioMuted - is the feed's audio muted?
211
- * @param videoMuted - is the feed's video muted?
212
- */
213
- setAudioVideoMuted(audioMuted, videoMuted) {
214
- if (audioMuted !== null) {
215
- if (this.audioMuted !== audioMuted) {
216
- this.speakingVolumeSamples.fill(-Infinity);
217
- }
218
- this.audioMuted = audioMuted;
219
- }
220
- if (videoMuted !== null) this.videoMuted = videoMuted;
221
- this.emit(CallFeedEvent.MuteStateChanged, this.audioMuted, this.videoMuted);
222
- }
223
-
224
- /**
225
- * Starts emitting volume_changed events where the emitter value is in decibels
226
- * @param enabled - emit volume changes
227
- */
228
- measureVolumeActivity(enabled) {
229
- if (enabled) {
230
- if (!this.analyser || !this.frequencyBinCount || !this.hasAudioTrack) return;
231
- this.measuringVolumeActivity = true;
232
- this.volumeLooper();
233
- } else {
234
- this.measuringVolumeActivity = false;
235
- this.speakingVolumeSamples.fill(-Infinity);
236
- this.emit(CallFeedEvent.VolumeChanged, -Infinity);
237
- }
238
- }
239
- setSpeakingThreshold(threshold) {
240
- this.speakingThreshold = threshold;
241
- }
242
- clone() {
243
- var mediaHandler = this.client.getMediaHandler();
244
- var stream = this.stream.clone();
245
- logger.log("CallFeed clone() cloning stream (originalStreamId=".concat(this.stream.id, ", newStreamId").concat(stream.id, ")"));
246
- if (this.purpose === SDPStreamMetadataPurpose.Usermedia) {
247
- mediaHandler.userMediaStreams.push(stream);
248
- } else {
249
- mediaHandler.screensharingStreams.push(stream);
250
- }
251
- return new CallFeed({
252
- client: this.client,
253
- roomId: this.roomId,
254
- userId: this.userId,
255
- deviceId: this.deviceId,
256
- stream,
257
- purpose: this.purpose,
258
- audioMuted: this.audioMuted,
259
- videoMuted: this.videoMuted
260
- });
261
- }
262
- dispose() {
263
- var _this$stream, _this$call;
264
- clearTimeout(this.volumeLooperTimeout);
265
- (_this$stream = this.stream) === null || _this$stream === void 0 || _this$stream.removeEventListener("addtrack", this.onAddTrack);
266
- (_this$call = this.call) === null || _this$call === void 0 || _this$call.removeListener(CallEvent.State, this.onCallState);
267
- if (this.audioContext) {
268
- this.audioContext = undefined;
269
- this.analyser = undefined;
270
- releaseContext();
271
- }
272
- this._disposed = true;
273
- this.emit(CallFeedEvent.Disposed);
274
- }
275
- get disposed() {
276
- return this._disposed;
277
- }
278
- set disposed(value) {
279
- this._disposed = value;
280
- }
281
- getLocalVolume() {
282
- return this.localVolume;
283
- }
284
- setLocalVolume(localVolume) {
285
- this.localVolume = localVolume;
286
- this.emit(CallFeedEvent.LocalVolumeChanged, localVolume);
287
- }
288
- }
289
- //# sourceMappingURL=callFeed.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"callFeed.js","names":["SDPStreamMetadataPurpose","acquireContext","releaseContext","logger","TypedEventEmitter","CallEvent","CallState","POLLING_INTERVAL","SPEAKING_THRESHOLD","SPEAKING_SAMPLE_COUNT","CallFeedEvent","CallFeed","constructor","opts","_defineProperty","emit","NewStream","stream","state","Connected","connected","Connecting","analyser","measuringVolumeActivity","getFloatFrequencyData","frequencyBinCount","maxVolume","Infinity","volume","speakingVolumeSamples","shift","push","VolumeChanged","newSpeaking","speakingThreshold","speaking","Speaking","volumeLooperTimeout","setTimeout","volumeLooper","client","call","roomId","userId","deviceId","purpose","audioMuted","videoMuted","Array","fill","sdpMetadataStreamId","id","updateStream","hasAudioTrack","initVolumeMeasuring","addListener","State","onCallState","isLocal","_connected","ConnectedChanged","getAudioTracks","length","oldStream","newStream","wasMeasuringVolumeActivity","removeEventListener","onAddTrack","measureVolumeActivity","addEventListener","audioContext","createAnalyser","fftSize","smoothingTimeConstant","mediaStreamAudioSourceNode","createMediaStreamSource","connect","Float32Array","getMember","_callRoom$getMember","callRoom","getRoom","getUserId","undefined","getDeviceId","isAudioMuted","isVideoMuted","getVideoTracks","isSpeaking","setNewStream","setAudioVideoMuted","MuteStateChanged","enabled","setSpeakingThreshold","threshold","clone","mediaHandler","getMediaHandler","log","concat","Usermedia","userMediaStreams","screensharingStreams","dispose","_this$stream","_this$call","clearTimeout","removeListener","_disposed","Disposed","disposed","value","getLocalVolume","localVolume","setLocalVolume","LocalVolumeChanged"],"sources":["../../src/webrtc/callFeed.ts"],"sourcesContent":["/*\nCopyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { SDPStreamMetadataPurpose } from \"./callEventTypes.ts\";\nimport { acquireContext, releaseContext } from \"./audioContext.ts\";\nimport { MatrixClient } from \"../client.ts\";\nimport { RoomMember } from \"../models/room-member.ts\";\nimport { logger } from \"../logger.ts\";\nimport { TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\nimport { CallEvent, CallState, MatrixCall } from \"./call.ts\";\n\nconst POLLING_INTERVAL = 200; // ms\nexport const SPEAKING_THRESHOLD = -60; // dB\nconst SPEAKING_SAMPLE_COUNT = 8; // samples\n\nexport interface ICallFeedOpts {\n client: MatrixClient;\n roomId?: string;\n userId: string;\n deviceId: string | undefined;\n stream: MediaStream;\n purpose: SDPStreamMetadataPurpose;\n /**\n * Whether or not the remote SDPStreamMetadata says audio is muted\n */\n audioMuted: boolean;\n /**\n * Whether or not the remote SDPStreamMetadata says video is muted\n */\n videoMuted: boolean;\n /**\n * The MatrixCall which is the source of this CallFeed\n */\n call?: MatrixCall;\n}\n\nexport enum CallFeedEvent {\n NewStream = \"new_stream\",\n MuteStateChanged = \"mute_state_changed\",\n LocalVolumeChanged = \"local_volume_changed\",\n VolumeChanged = \"volume_changed\",\n ConnectedChanged = \"connected_changed\",\n Speaking = \"speaking\",\n Disposed = \"disposed\",\n}\n\ntype EventHandlerMap = {\n [CallFeedEvent.NewStream]: (stream: MediaStream) => void;\n [CallFeedEvent.MuteStateChanged]: (audioMuted: boolean, videoMuted: boolean) => void;\n [CallFeedEvent.LocalVolumeChanged]: (localVolume: number) => void;\n [CallFeedEvent.VolumeChanged]: (volume: number) => void;\n [CallFeedEvent.ConnectedChanged]: (connected: boolean) => void;\n [CallFeedEvent.Speaking]: (speaking: boolean) => void;\n [CallFeedEvent.Disposed]: () => void;\n};\n\nexport class CallFeed extends TypedEventEmitter<CallFeedEvent, EventHandlerMap> {\n public stream: MediaStream;\n public sdpMetadataStreamId: string;\n public userId: string;\n public readonly deviceId: string | undefined;\n public purpose: SDPStreamMetadataPurpose;\n public speakingVolumeSamples: number[];\n\n private client: MatrixClient;\n private call?: MatrixCall;\n private roomId?: string;\n private audioMuted: boolean;\n private videoMuted: boolean;\n private localVolume = 1;\n private measuringVolumeActivity = false;\n private audioContext?: AudioContext;\n private analyser?: AnalyserNode;\n private frequencyBinCount?: Float32Array;\n private speakingThreshold = SPEAKING_THRESHOLD;\n private speaking = false;\n private volumeLooperTimeout?: ReturnType<typeof setTimeout>;\n private _disposed = false;\n private _connected = false;\n\n public constructor(opts: ICallFeedOpts) {\n super();\n\n this.client = opts.client;\n this.call = opts.call;\n this.roomId = opts.roomId;\n this.userId = opts.userId;\n this.deviceId = opts.deviceId;\n this.purpose = opts.purpose;\n this.audioMuted = opts.audioMuted;\n this.videoMuted = opts.videoMuted;\n this.speakingVolumeSamples = new Array(SPEAKING_SAMPLE_COUNT).fill(-Infinity);\n this.sdpMetadataStreamId = opts.stream.id;\n\n this.updateStream(null, opts.stream);\n this.stream = opts.stream; // updateStream does this, but this makes TS happier\n\n if (this.hasAudioTrack) {\n this.initVolumeMeasuring();\n }\n\n if (opts.call) {\n opts.call.addListener(CallEvent.State, this.onCallState);\n this.onCallState(opts.call.state);\n }\n }\n\n public get connected(): boolean {\n // Local feeds are always considered connected\n return this.isLocal() || this._connected;\n }\n\n private set connected(connected: boolean) {\n this._connected = connected;\n this.emit(CallFeedEvent.ConnectedChanged, this.connected);\n }\n\n public get hasAudioTrack(): boolean {\n return this.stream.getAudioTracks().length > 0;\n }\n\n private updateStream(oldStream: MediaStream | null, newStream: MediaStream): void {\n if (newStream === oldStream) return;\n\n const wasMeasuringVolumeActivity = this.measuringVolumeActivity;\n\n if (oldStream) {\n oldStream.removeEventListener(\"addtrack\", this.onAddTrack);\n this.measureVolumeActivity(false);\n }\n\n this.stream = newStream;\n newStream.addEventListener(\"addtrack\", this.onAddTrack);\n\n if (this.hasAudioTrack) {\n this.initVolumeMeasuring();\n if (wasMeasuringVolumeActivity) this.measureVolumeActivity(true);\n } else {\n this.measureVolumeActivity(false);\n }\n\n this.emit(CallFeedEvent.NewStream, this.stream);\n }\n\n private initVolumeMeasuring(): void {\n if (!this.hasAudioTrack) return;\n if (!this.audioContext) this.audioContext = acquireContext();\n\n this.analyser = this.audioContext.createAnalyser();\n this.analyser.fftSize = 512;\n this.analyser.smoothingTimeConstant = 0.1;\n\n const mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream);\n mediaStreamAudioSourceNode.connect(this.analyser);\n\n this.frequencyBinCount = new Float32Array(this.analyser.frequencyBinCount);\n }\n\n private onAddTrack = (): void => {\n this.emit(CallFeedEvent.NewStream, this.stream);\n };\n\n private onCallState = (state: CallState): void => {\n if (state === CallState.Connected) {\n this.connected = true;\n } else if (state === CallState.Connecting) {\n this.connected = false;\n }\n };\n\n /**\n * Returns callRoom member\n * @returns member of the callRoom\n */\n public getMember(): RoomMember | null {\n const callRoom = this.client.getRoom(this.roomId);\n return callRoom?.getMember(this.userId) ?? null;\n }\n\n /**\n * Returns true if CallFeed is local, otherwise returns false\n * @returns is local?\n */\n public isLocal(): boolean {\n return (\n this.userId === this.client.getUserId() &&\n (this.deviceId === undefined || this.deviceId === this.client.getDeviceId())\n );\n }\n\n /**\n * Returns true if audio is muted or if there are no audio\n * tracks, otherwise returns false\n * @returns is audio muted?\n */\n public isAudioMuted(): boolean {\n return this.stream.getAudioTracks().length === 0 || this.audioMuted;\n }\n\n /**\n * Returns true video is muted or if there are no video\n * tracks, otherwise returns false\n * @returns is video muted?\n */\n public isVideoMuted(): boolean {\n // We assume only one video track\n return this.stream.getVideoTracks().length === 0 || this.videoMuted;\n }\n\n public isSpeaking(): boolean {\n return this.speaking;\n }\n\n /**\n * Replaces the current MediaStream with a new one.\n * The stream will be different and new stream as remote parties are\n * concerned, but this can be used for convenience locally to set up\n * volume listeners automatically on the new stream etc.\n * @param newStream - new stream with which to replace the current one\n */\n public setNewStream(newStream: MediaStream): void {\n this.updateStream(this.stream, newStream);\n }\n\n /**\n * Set one or both of feed's internal audio and video video mute state\n * Either value may be null to leave it as-is\n * @param audioMuted - is the feed's audio muted?\n * @param videoMuted - is the feed's video muted?\n */\n public setAudioVideoMuted(audioMuted: boolean | null, videoMuted: boolean | null): void {\n if (audioMuted !== null) {\n if (this.audioMuted !== audioMuted) {\n this.speakingVolumeSamples.fill(-Infinity);\n }\n this.audioMuted = audioMuted;\n }\n if (videoMuted !== null) this.videoMuted = videoMuted;\n this.emit(CallFeedEvent.MuteStateChanged, this.audioMuted, this.videoMuted);\n }\n\n /**\n * Starts emitting volume_changed events where the emitter value is in decibels\n * @param enabled - emit volume changes\n */\n public measureVolumeActivity(enabled: boolean): void {\n if (enabled) {\n if (!this.analyser || !this.frequencyBinCount || !this.hasAudioTrack) return;\n\n this.measuringVolumeActivity = true;\n this.volumeLooper();\n } else {\n this.measuringVolumeActivity = false;\n this.speakingVolumeSamples.fill(-Infinity);\n this.emit(CallFeedEvent.VolumeChanged, -Infinity);\n }\n }\n\n public setSpeakingThreshold(threshold: number): void {\n this.speakingThreshold = threshold;\n }\n\n private volumeLooper = (): void => {\n if (!this.analyser) return;\n\n if (!this.measuringVolumeActivity) return;\n\n this.analyser.getFloatFrequencyData(this.frequencyBinCount!);\n\n let maxVolume = -Infinity;\n for (const volume of this.frequencyBinCount!) {\n if (volume > maxVolume) {\n maxVolume = volume;\n }\n }\n\n this.speakingVolumeSamples.shift();\n this.speakingVolumeSamples.push(maxVolume);\n\n this.emit(CallFeedEvent.VolumeChanged, maxVolume);\n\n let newSpeaking = false;\n\n for (const volume of this.speakingVolumeSamples) {\n if (volume > this.speakingThreshold) {\n newSpeaking = true;\n break;\n }\n }\n\n if (this.speaking !== newSpeaking) {\n this.speaking = newSpeaking;\n this.emit(CallFeedEvent.Speaking, this.speaking);\n }\n\n this.volumeLooperTimeout = setTimeout(this.volumeLooper, POLLING_INTERVAL);\n };\n\n public clone(): CallFeed {\n const mediaHandler = this.client.getMediaHandler();\n const stream = this.stream.clone();\n logger.log(`CallFeed clone() cloning stream (originalStreamId=${this.stream.id}, newStreamId${stream.id})`);\n\n if (this.purpose === SDPStreamMetadataPurpose.Usermedia) {\n mediaHandler.userMediaStreams.push(stream);\n } else {\n mediaHandler.screensharingStreams.push(stream);\n }\n\n return new CallFeed({\n client: this.client,\n roomId: this.roomId,\n userId: this.userId,\n deviceId: this.deviceId,\n stream,\n purpose: this.purpose,\n audioMuted: this.audioMuted,\n videoMuted: this.videoMuted,\n });\n }\n\n public dispose(): void {\n clearTimeout(this.volumeLooperTimeout);\n this.stream?.removeEventListener(\"addtrack\", this.onAddTrack);\n this.call?.removeListener(CallEvent.State, this.onCallState);\n if (this.audioContext) {\n this.audioContext = undefined;\n this.analyser = undefined;\n releaseContext();\n }\n this._disposed = true;\n this.emit(CallFeedEvent.Disposed);\n }\n\n public get disposed(): boolean {\n return this._disposed;\n }\n\n private set disposed(value: boolean) {\n this._disposed = value;\n }\n\n public getLocalVolume(): number {\n return this.localVolume;\n }\n\n public setLocalVolume(localVolume: number): void {\n this.localVolume = localVolume;\n this.emit(CallFeedEvent.LocalVolumeChanged, localVolume);\n }\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,wBAAwB,QAAQ,qBAAqB;AAC9D,SAASC,cAAc,EAAEC,cAAc,QAAQ,mBAAmB;AAGlE,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,SAAS,EAAEC,SAAS,QAAoB,WAAW;AAE5D,IAAMC,gBAAgB,GAAG,GAAG,CAAC,CAAC;AAC9B,OAAO,IAAMC,kBAAkB,GAAG,CAAC,EAAE,CAAC,CAAC;AACvC,IAAMC,qBAAqB,GAAG,CAAC,CAAC,CAAC;;AAuBjC,WAAYC,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAoBzB,OAAO,MAAMC,QAAQ,SAASP,iBAAiB,CAAiC;EAwBrEQ,WAAWA,CAACC,IAAmB,EAAE;IACpC,KAAK,CAAC,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,sBAZU,CAAC;IAAAA,eAAA,kCACW,KAAK;IAAAA,eAAA;IAAAA,eAAA;IAAAA,e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C,CAAAmE,YAAA,OAAI,CAACvF,MAAM,cAAAuF,YAAA,eAAXA,YAAA,CAAatC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAACC,UAAU,CAAC;IAC7D,CAAAsC,UAAA,OAAI,CAAChE,IAAI,cAAAgE,UAAA,eAATA,UAAA,CAAWE,cAAc,CAACtG,SAAS,CAACmD,KAAK,EAAE,IAAI,CAACC,WAAW,CAAC;IAC5D,IAAI,IAAI,CAACa,YAAY,EAAE;MACnB,IAAI,CAACA,YAAY,GAAGa,SAAS;MAC7B,IAAI,CAAC7D,QAAQ,GAAG6D,SAAS;MACzBjF,cAAc,CAAC,CAAC;IACpB;IACA,IAAI,CAAC0G,SAAS,GAAG,IAAI;IACrB,IAAI,CAAC7F,IAAI,CAACL,aAAa,CAACmG,QAAQ,CAAC;EACrC;EAEA,IAAWC,QAAQA,CAAA,EAAY;IAC3B,OAAO,IAAI,CAACF,SAAS;EACzB;EAEA,IAAYE,QAAQA,CAACC,KAAc,EAAE;IACjC,IAAI,CAACH,SAAS,GAAGG,KAAK;EAC1B;EAEOC,cAAcA,CAAA,EAAW;IAC5B,OAAO,IAAI,CAACC,WAAW;EAC3B;EAEOC,cAAcA,CAACD,WAAmB,EAAQ;IAC7C,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAAClG,IAAI,CAACL,aAAa,CAACyG,kBAAkB,EAAEF,WAAW,CAAC;EAC5D;AACJ","ignoreList":[]}
@@ -1,323 +0,0 @@
1
- import { TypedEventEmitter } from "../models/typed-event-emitter.ts";
2
- import { CallFeed } from "./callFeed.ts";
3
- import { MatrixClient } from "../client.ts";
4
- import { CallEvent, CallEventHandlerMap, MatrixCall } from "./call.ts";
5
- import { RoomMember } from "../models/room-member.ts";
6
- import { Room } from "../models/room.ts";
7
- import { SDPStreamMetadataPurpose } from "./callEventTypes.ts";
8
- import { IScreensharingOpts } from "./mediaHandler.ts";
9
- import { GroupCallStats } from "./stats/groupCallStats.ts";
10
- import { ByteSentStatsReport, CallFeedReport, ConnectionStatsReport, SummaryStatsReport } from "./stats/statsReport.ts";
11
- import { CallMembershipData } from "../matrixrtc/CallMembership.ts";
12
- export declare enum GroupCallIntent {
13
- Ring = "m.ring",
14
- Prompt = "m.prompt",
15
- Room = "m.room"
16
- }
17
- export declare enum GroupCallType {
18
- Video = "m.video",
19
- Voice = "m.voice"
20
- }
21
- export declare enum GroupCallTerminationReason {
22
- CallEnded = "call_ended"
23
- }
24
- export type CallsByUserAndDevice = Map<string, Map<string, MatrixCall>>;
25
- /**
26
- * Because event names are just strings, they do need
27
- * to be unique over all event types of event emitter.
28
- * Some objects could emit more then one set of events.
29
- */
30
- export declare enum GroupCallEvent {
31
- GroupCallStateChanged = "group_call_state_changed",
32
- ActiveSpeakerChanged = "active_speaker_changed",
33
- CallsChanged = "calls_changed",
34
- UserMediaFeedsChanged = "user_media_feeds_changed",
35
- ScreenshareFeedsChanged = "screenshare_feeds_changed",
36
- LocalScreenshareStateChanged = "local_screenshare_state_changed",
37
- LocalMuteStateChanged = "local_mute_state_changed",
38
- ParticipantsChanged = "participants_changed",
39
- Error = "group_call_error"
40
- }
41
- export type GroupCallEventHandlerMap = {
42
- [GroupCallEvent.GroupCallStateChanged]: (newState: GroupCallState, oldState: GroupCallState) => void;
43
- [GroupCallEvent.ActiveSpeakerChanged]: (activeSpeaker: CallFeed | undefined) => void;
44
- [GroupCallEvent.CallsChanged]: (calls: CallsByUserAndDevice) => void;
45
- [GroupCallEvent.UserMediaFeedsChanged]: (feeds: CallFeed[]) => void;
46
- [GroupCallEvent.ScreenshareFeedsChanged]: (feeds: CallFeed[]) => void;
47
- [GroupCallEvent.LocalScreenshareStateChanged]: (isScreensharing: boolean, feed?: CallFeed, sourceId?: string) => void;
48
- [GroupCallEvent.LocalMuteStateChanged]: (audioMuted: boolean, videoMuted: boolean) => void;
49
- [GroupCallEvent.ParticipantsChanged]: (participants: Map<RoomMember, Map<string, ParticipantState>>) => void;
50
- /**
51
- * Fires whenever an error occurs when call.js encounters an issue with setting up the call.
52
- * <p>
53
- * The error given will have a code equal to either `MatrixCall.ERR_LOCAL_OFFER_FAILED` or
54
- * `MatrixCall.ERR_NO_USER_MEDIA`. `ERR_LOCAL_OFFER_FAILED` is emitted when the local client
55
- * fails to create an offer. `ERR_NO_USER_MEDIA` is emitted when the user has denied access
56
- * to their audio/video hardware.
57
- * @param error - The error raised by MatrixCall.
58
- * @example
59
- * ```
60
- * matrixCall.on("error", function(err){
61
- * console.error(err.code, err);
62
- * });
63
- * ```
64
- */
65
- [GroupCallEvent.Error]: (error: GroupCallError) => void;
66
- };
67
- export declare enum GroupCallStatsReportEvent {
68
- ConnectionStats = "GroupCall.connection_stats",
69
- ByteSentStats = "GroupCall.byte_sent_stats",
70
- SummaryStats = "GroupCall.summary_stats",
71
- CallFeedStats = "GroupCall.call_feed_stats"
72
- }
73
- /**
74
- * The final report-events that get consumed by client.
75
- */
76
- export type GroupCallStatsReportEventHandlerMap = {
77
- [GroupCallStatsReportEvent.ConnectionStats]: (report: GroupCallStatsReport<ConnectionStatsReport>) => void;
78
- [GroupCallStatsReportEvent.ByteSentStats]: (report: GroupCallStatsReport<ByteSentStatsReport>) => void;
79
- [GroupCallStatsReportEvent.SummaryStats]: (report: GroupCallStatsReport<SummaryStatsReport>) => void;
80
- [GroupCallStatsReportEvent.CallFeedStats]: (report: GroupCallStatsReport<CallFeedReport>) => void;
81
- };
82
- export declare enum GroupCallErrorCode {
83
- NoUserMedia = "no_user_media",
84
- UnknownDevice = "unknown_device",
85
- PlaceCallFailed = "place_call_failed"
86
- }
87
- export interface GroupCallStatsReport<T extends ConnectionStatsReport | ByteSentStatsReport | SummaryStatsReport | CallFeedReport> {
88
- report: T;
89
- }
90
- export declare class GroupCallError extends Error {
91
- code: string;
92
- constructor(code: GroupCallErrorCode, msg: string, err?: Error);
93
- }
94
- export declare class GroupCallUnknownDeviceError extends GroupCallError {
95
- userId: string;
96
- constructor(userId: string);
97
- }
98
- export declare class OtherUserSpeakingError extends Error {
99
- constructor();
100
- }
101
- export interface IGroupCallDataChannelOptions {
102
- ordered: boolean;
103
- maxPacketLifeTime: number;
104
- maxRetransmits: number;
105
- protocol: string;
106
- }
107
- export interface IGroupCallRoomState {
108
- "m.intent": GroupCallIntent;
109
- "m.type": GroupCallType;
110
- "m.terminated"?: GroupCallTerminationReason;
111
- "io.element.ptt"?: boolean;
112
- "dataChannelsEnabled"?: boolean;
113
- "dataChannelOptions"?: IGroupCallDataChannelOptions;
114
- "io.element.livekit_service_url"?: string;
115
- }
116
- export interface IGroupCallRoomMemberFeed {
117
- purpose: SDPStreamMetadataPurpose;
118
- }
119
- export interface IGroupCallRoomMemberDevice {
120
- device_id: string;
121
- session_id: string;
122
- expires_ts: number;
123
- feeds: IGroupCallRoomMemberFeed[];
124
- }
125
- export interface IGroupCallRoomMemberCallState {
126
- "m.call_id": string;
127
- "m.foci"?: string[];
128
- "m.devices": IGroupCallRoomMemberDevice[];
129
- }
130
- export interface IGroupCallRoomMemberState {
131
- "m.calls": IGroupCallRoomMemberCallState[];
132
- }
133
- export interface ExperimentalGroupCallRoomMemberState {
134
- memberships: CallMembershipData[];
135
- }
136
- export declare enum GroupCallState {
137
- LocalCallFeedUninitialized = "local_call_feed_uninitialized",
138
- InitializingLocalCallFeed = "initializing_local_call_feed",
139
- LocalCallFeedInitialized = "local_call_feed_initialized",
140
- Entered = "entered",
141
- Ended = "ended"
142
- }
143
- export interface ParticipantState {
144
- sessionId: string;
145
- screensharing: boolean;
146
- }
147
- export declare class GroupCall extends TypedEventEmitter<GroupCallEvent | CallEvent | GroupCallStatsReportEvent, GroupCallEventHandlerMap & CallEventHandlerMap & GroupCallStatsReportEventHandlerMap> {
148
- private client;
149
- room: Room;
150
- type: GroupCallType;
151
- isPtt: boolean;
152
- intent: GroupCallIntent;
153
- private dataChannelsEnabled?;
154
- private dataChannelOptions?;
155
- private useLivekit;
156
- activeSpeakerInterval: number;
157
- retryCallInterval: number;
158
- participantTimeout: number;
159
- pttMaxTransmitTime: number;
160
- activeSpeaker?: CallFeed;
161
- localCallFeed?: CallFeed;
162
- localScreenshareFeed?: CallFeed;
163
- localDesktopCapturerSourceId?: string;
164
- readonly userMediaFeeds: CallFeed[];
165
- readonly screenshareFeeds: CallFeed[];
166
- groupCallId: string;
167
- readonly allowCallWithoutVideoAndAudio: boolean;
168
- private readonly calls;
169
- private callHandlers;
170
- private activeSpeakerLoopInterval?;
171
- private retryCallLoopInterval?;
172
- private retryCallCounts;
173
- private reEmitter;
174
- private transmitTimer;
175
- private participantsExpirationTimer;
176
- private resendMemberStateTimer;
177
- private initWithAudioMuted;
178
- private initWithVideoMuted;
179
- private initCallFeedPromise?;
180
- private _livekitServiceURL?;
181
- private stats;
182
- /**
183
- * Configure default webrtc stats collection interval in ms
184
- * Disable collecting webrtc stats by setting interval to 0
185
- */
186
- private statsCollectIntervalTime;
187
- constructor(client: MatrixClient, room: Room, type: GroupCallType, isPtt: boolean, intent: GroupCallIntent, groupCallId?: string, dataChannelsEnabled?: boolean | undefined, dataChannelOptions?: IGroupCallDataChannelOptions | undefined, isCallWithoutVideoAndAudio?: boolean, useLivekit?: boolean, livekitServiceURL?: string);
188
- private onConnectionStats;
189
- private onByteSentStats;
190
- private onSummaryStats;
191
- private onCallFeedReport;
192
- create(): Promise<GroupCall>;
193
- private sendCallStateEvent;
194
- get livekitServiceURL(): string | undefined;
195
- updateLivekitServiceURL(newURL: string): Promise<void>;
196
- private _state;
197
- /**
198
- * The group call's state.
199
- */
200
- get state(): GroupCallState;
201
- private set state(value);
202
- private _participants;
203
- /**
204
- * The current participants in the call, as a map from members to device IDs
205
- * to participant info.
206
- */
207
- get participants(): Map<RoomMember, Map<string, ParticipantState>>;
208
- private set participants(value);
209
- private _creationTs;
210
- /**
211
- * The timestamp at which the call was created, or null if it has not yet
212
- * been created.
213
- */
214
- get creationTs(): number | null;
215
- private set creationTs(value);
216
- private _enteredViaAnotherSession;
217
- /**
218
- * Whether the local device has entered this call via another session, such
219
- * as a widget.
220
- */
221
- get enteredViaAnotherSession(): boolean;
222
- set enteredViaAnotherSession(value: boolean);
223
- /**
224
- * Executes the given callback on all calls in this group call.
225
- * @param f - The callback.
226
- */
227
- forEachCall(f: (call: MatrixCall) => void): void;
228
- getLocalFeeds(): CallFeed[];
229
- hasLocalParticipant(): boolean;
230
- /**
231
- * Determines whether the given call is one that we were expecting to exist
232
- * given our knowledge of who is participating in the group call.
233
- */
234
- private callExpected;
235
- initLocalCallFeed(): Promise<void>;
236
- private initLocalCallFeedInternal;
237
- updateLocalUsermediaStream(stream: MediaStream): Promise<void>;
238
- enter(): Promise<void>;
239
- private dispose;
240
- leave(): void;
241
- terminate(emitStateEvent?: boolean): Promise<void>;
242
- isLocalVideoMuted(): boolean;
243
- isMicrophoneMuted(): boolean;
244
- /**
245
- * Sets the mute state of the local participants's microphone.
246
- * @param muted - Whether to mute the microphone
247
- * @returns Whether muting/unmuting was successful
248
- */
249
- setMicrophoneMuted(muted: boolean): Promise<boolean>;
250
- /**
251
- * If we allow entering a call without a camera and without video, it can happen that the access rights to the
252
- * devices have not yet been queried. If a stream does not yet have an audio track, we assume that the rights have
253
- * not yet been checked.
254
- *
255
- * `this.client.getMediaHandler().getUserMediaStream` clones the current stream, so it only wanted to be called when
256
- * not Audio Track exists.
257
- * As such, this is a compromise, because, the access rights should always be queried before the call.
258
- */
259
- private checkAudioPermissionIfNecessary;
260
- /**
261
- * Sets the mute state of the local participants's video.
262
- * @param muted - Whether to mute the video
263
- * @returns Whether muting/unmuting was successful
264
- */
265
- setLocalVideoMuted(muted: boolean): Promise<boolean>;
266
- setScreensharingEnabled(enabled: boolean, opts?: IScreensharingOpts): Promise<boolean>;
267
- isScreensharing(): boolean;
268
- private onIncomingCall;
269
- /**
270
- * Determines whether a given participant expects us to call them (versus
271
- * them calling us).
272
- * @param userId - The participant's user ID.
273
- * @param deviceId - The participant's device ID.
274
- * @returns Whether we need to place an outgoing call to the participant.
275
- */
276
- private wantsOutgoingCall;
277
- /**
278
- * Places calls to all participants that we're responsible for calling.
279
- */
280
- private placeOutgoingCalls;
281
- private getMemberStateEvents;
282
- private onRetryCallLoop;
283
- private initCall;
284
- private disposeCall;
285
- private onCallFeedsChanged;
286
- private onCallStateChanged;
287
- private onCallHangup;
288
- private onCallReplaced;
289
- getUserMediaFeed(userId: string, deviceId: string): CallFeed | undefined;
290
- private addUserMediaFeed;
291
- private replaceUserMediaFeed;
292
- private removeUserMediaFeed;
293
- private onActiveSpeakerLoop;
294
- getScreenshareFeed(userId: string, deviceId: string): CallFeed | undefined;
295
- private addScreenshareFeed;
296
- private replaceScreenshareFeed;
297
- private removeScreenshareFeed;
298
- /**
299
- * Recalculates and updates the participant map to match the room state.
300
- */
301
- private updateParticipants;
302
- /**
303
- * Updates the local user's member state with the devices returned by the given function.
304
- * @param fn - A function from the current devices to the new devices. If it
305
- * returns null, the update will be skipped.
306
- * @param keepAlive - Whether the request should outlive the window.
307
- */
308
- private updateDevices;
309
- private addDeviceToMemberState;
310
- private updateMemberState;
311
- /**
312
- * Cleans up our member state by filtering out logged out devices, inactive
313
- * devices, and our own device (if we know we haven't entered).
314
- */
315
- cleanMemberState(): Promise<void>;
316
- private onRoomState;
317
- private onParticipantsChanged;
318
- private onStateChanged;
319
- private onLocalFeedsChanged;
320
- getGroupCallStats(): GroupCallStats;
321
- setGroupCallStatsInterval(interval: number): void;
322
- }
323
- //# sourceMappingURL=groupCall.d.ts.map