@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,364 +0,0 @@
1
- /*
2
- Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import { SDPStreamMetadataPurpose } from "./callEventTypes.ts";
18
- import { acquireContext, releaseContext } from "./audioContext.ts";
19
- import { MatrixClient } from "../client.ts";
20
- import { RoomMember } from "../models/room-member.ts";
21
- import { logger } from "../logger.ts";
22
- import { TypedEventEmitter } from "../models/typed-event-emitter.ts";
23
- import { CallEvent, CallState, MatrixCall } from "./call.ts";
24
-
25
- const POLLING_INTERVAL = 200; // ms
26
- export const SPEAKING_THRESHOLD = -60; // dB
27
- const SPEAKING_SAMPLE_COUNT = 8; // samples
28
-
29
- export interface ICallFeedOpts {
30
- client: MatrixClient;
31
- roomId?: string;
32
- userId: string;
33
- deviceId: string | undefined;
34
- stream: MediaStream;
35
- purpose: SDPStreamMetadataPurpose;
36
- /**
37
- * Whether or not the remote SDPStreamMetadata says audio is muted
38
- */
39
- audioMuted: boolean;
40
- /**
41
- * Whether or not the remote SDPStreamMetadata says video is muted
42
- */
43
- videoMuted: boolean;
44
- /**
45
- * The MatrixCall which is the source of this CallFeed
46
- */
47
- call?: MatrixCall;
48
- }
49
-
50
- export enum CallFeedEvent {
51
- NewStream = "new_stream",
52
- MuteStateChanged = "mute_state_changed",
53
- LocalVolumeChanged = "local_volume_changed",
54
- VolumeChanged = "volume_changed",
55
- ConnectedChanged = "connected_changed",
56
- Speaking = "speaking",
57
- Disposed = "disposed",
58
- }
59
-
60
- type EventHandlerMap = {
61
- [CallFeedEvent.NewStream]: (stream: MediaStream) => void;
62
- [CallFeedEvent.MuteStateChanged]: (audioMuted: boolean, videoMuted: boolean) => void;
63
- [CallFeedEvent.LocalVolumeChanged]: (localVolume: number) => void;
64
- [CallFeedEvent.VolumeChanged]: (volume: number) => void;
65
- [CallFeedEvent.ConnectedChanged]: (connected: boolean) => void;
66
- [CallFeedEvent.Speaking]: (speaking: boolean) => void;
67
- [CallFeedEvent.Disposed]: () => void;
68
- };
69
-
70
- export class CallFeed extends TypedEventEmitter<CallFeedEvent, EventHandlerMap> {
71
- public stream: MediaStream;
72
- public sdpMetadataStreamId: string;
73
- public userId: string;
74
- public readonly deviceId: string | undefined;
75
- public purpose: SDPStreamMetadataPurpose;
76
- public speakingVolumeSamples: number[];
77
-
78
- private client: MatrixClient;
79
- private call?: MatrixCall;
80
- private roomId?: string;
81
- private audioMuted: boolean;
82
- private videoMuted: boolean;
83
- private localVolume = 1;
84
- private measuringVolumeActivity = false;
85
- private audioContext?: AudioContext;
86
- private analyser?: AnalyserNode;
87
- private frequencyBinCount?: Float32Array;
88
- private speakingThreshold = SPEAKING_THRESHOLD;
89
- private speaking = false;
90
- private volumeLooperTimeout?: ReturnType<typeof setTimeout>;
91
- private _disposed = false;
92
- private _connected = false;
93
-
94
- public constructor(opts: ICallFeedOpts) {
95
- super();
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
-
108
- this.updateStream(null, opts.stream);
109
- this.stream = opts.stream; // updateStream does this, but this makes TS happier
110
-
111
- if (this.hasAudioTrack) {
112
- this.initVolumeMeasuring();
113
- }
114
-
115
- if (opts.call) {
116
- opts.call.addListener(CallEvent.State, this.onCallState);
117
- this.onCallState(opts.call.state);
118
- }
119
- }
120
-
121
- public get connected(): boolean {
122
- // Local feeds are always considered connected
123
- return this.isLocal() || this._connected;
124
- }
125
-
126
- private set connected(connected: boolean) {
127
- this._connected = connected;
128
- this.emit(CallFeedEvent.ConnectedChanged, this.connected);
129
- }
130
-
131
- public get hasAudioTrack(): boolean {
132
- return this.stream.getAudioTracks().length > 0;
133
- }
134
-
135
- private updateStream(oldStream: MediaStream | null, newStream: MediaStream): void {
136
- if (newStream === oldStream) return;
137
-
138
- const wasMeasuringVolumeActivity = this.measuringVolumeActivity;
139
-
140
- if (oldStream) {
141
- oldStream.removeEventListener("addtrack", this.onAddTrack);
142
- this.measureVolumeActivity(false);
143
- }
144
-
145
- this.stream = newStream;
146
- newStream.addEventListener("addtrack", this.onAddTrack);
147
-
148
- if (this.hasAudioTrack) {
149
- this.initVolumeMeasuring();
150
- if (wasMeasuringVolumeActivity) this.measureVolumeActivity(true);
151
- } else {
152
- this.measureVolumeActivity(false);
153
- }
154
-
155
- this.emit(CallFeedEvent.NewStream, this.stream);
156
- }
157
-
158
- private initVolumeMeasuring(): void {
159
- if (!this.hasAudioTrack) return;
160
- if (!this.audioContext) this.audioContext = acquireContext();
161
-
162
- this.analyser = this.audioContext.createAnalyser();
163
- this.analyser.fftSize = 512;
164
- this.analyser.smoothingTimeConstant = 0.1;
165
-
166
- const mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream);
167
- mediaStreamAudioSourceNode.connect(this.analyser);
168
-
169
- this.frequencyBinCount = new Float32Array(this.analyser.frequencyBinCount);
170
- }
171
-
172
- private onAddTrack = (): void => {
173
- this.emit(CallFeedEvent.NewStream, this.stream);
174
- };
175
-
176
- private onCallState = (state: CallState): void => {
177
- if (state === CallState.Connected) {
178
- this.connected = true;
179
- } else if (state === CallState.Connecting) {
180
- this.connected = false;
181
- }
182
- };
183
-
184
- /**
185
- * Returns callRoom member
186
- * @returns member of the callRoom
187
- */
188
- public getMember(): RoomMember | null {
189
- const callRoom = this.client.getRoom(this.roomId);
190
- return callRoom?.getMember(this.userId) ?? null;
191
- }
192
-
193
- /**
194
- * Returns true if CallFeed is local, otherwise returns false
195
- * @returns is local?
196
- */
197
- public isLocal(): boolean {
198
- return (
199
- this.userId === this.client.getUserId() &&
200
- (this.deviceId === undefined || this.deviceId === this.client.getDeviceId())
201
- );
202
- }
203
-
204
- /**
205
- * Returns true if audio is muted or if there are no audio
206
- * tracks, otherwise returns false
207
- * @returns is audio muted?
208
- */
209
- public isAudioMuted(): boolean {
210
- return this.stream.getAudioTracks().length === 0 || this.audioMuted;
211
- }
212
-
213
- /**
214
- * Returns true video is muted or if there are no video
215
- * tracks, otherwise returns false
216
- * @returns is video muted?
217
- */
218
- public isVideoMuted(): boolean {
219
- // We assume only one video track
220
- return this.stream.getVideoTracks().length === 0 || this.videoMuted;
221
- }
222
-
223
- public isSpeaking(): boolean {
224
- return this.speaking;
225
- }
226
-
227
- /**
228
- * Replaces the current MediaStream with a new one.
229
- * The stream will be different and new stream as remote parties are
230
- * concerned, but this can be used for convenience locally to set up
231
- * volume listeners automatically on the new stream etc.
232
- * @param newStream - new stream with which to replace the current one
233
- */
234
- public setNewStream(newStream: MediaStream): void {
235
- this.updateStream(this.stream, newStream);
236
- }
237
-
238
- /**
239
- * Set one or both of feed's internal audio and video video mute state
240
- * Either value may be null to leave it as-is
241
- * @param audioMuted - is the feed's audio muted?
242
- * @param videoMuted - is the feed's video muted?
243
- */
244
- public setAudioVideoMuted(audioMuted: boolean | null, videoMuted: boolean | null): void {
245
- if (audioMuted !== null) {
246
- if (this.audioMuted !== audioMuted) {
247
- this.speakingVolumeSamples.fill(-Infinity);
248
- }
249
- this.audioMuted = audioMuted;
250
- }
251
- if (videoMuted !== null) this.videoMuted = videoMuted;
252
- this.emit(CallFeedEvent.MuteStateChanged, this.audioMuted, this.videoMuted);
253
- }
254
-
255
- /**
256
- * Starts emitting volume_changed events where the emitter value is in decibels
257
- * @param enabled - emit volume changes
258
- */
259
- public measureVolumeActivity(enabled: boolean): void {
260
- if (enabled) {
261
- if (!this.analyser || !this.frequencyBinCount || !this.hasAudioTrack) return;
262
-
263
- this.measuringVolumeActivity = true;
264
- this.volumeLooper();
265
- } else {
266
- this.measuringVolumeActivity = false;
267
- this.speakingVolumeSamples.fill(-Infinity);
268
- this.emit(CallFeedEvent.VolumeChanged, -Infinity);
269
- }
270
- }
271
-
272
- public setSpeakingThreshold(threshold: number): void {
273
- this.speakingThreshold = threshold;
274
- }
275
-
276
- private volumeLooper = (): void => {
277
- if (!this.analyser) return;
278
-
279
- if (!this.measuringVolumeActivity) return;
280
-
281
- this.analyser.getFloatFrequencyData(this.frequencyBinCount!);
282
-
283
- let maxVolume = -Infinity;
284
- for (const volume of this.frequencyBinCount!) {
285
- if (volume > maxVolume) {
286
- maxVolume = volume;
287
- }
288
- }
289
-
290
- this.speakingVolumeSamples.shift();
291
- this.speakingVolumeSamples.push(maxVolume);
292
-
293
- this.emit(CallFeedEvent.VolumeChanged, maxVolume);
294
-
295
- let newSpeaking = false;
296
-
297
- for (const volume of this.speakingVolumeSamples) {
298
- if (volume > this.speakingThreshold) {
299
- newSpeaking = true;
300
- break;
301
- }
302
- }
303
-
304
- if (this.speaking !== newSpeaking) {
305
- this.speaking = newSpeaking;
306
- this.emit(CallFeedEvent.Speaking, this.speaking);
307
- }
308
-
309
- this.volumeLooperTimeout = setTimeout(this.volumeLooper, POLLING_INTERVAL);
310
- };
311
-
312
- public clone(): CallFeed {
313
- const mediaHandler = this.client.getMediaHandler();
314
- const stream = this.stream.clone();
315
- logger.log(`CallFeed clone() cloning stream (originalStreamId=${this.stream.id}, newStreamId${stream.id})`);
316
-
317
- if (this.purpose === SDPStreamMetadataPurpose.Usermedia) {
318
- mediaHandler.userMediaStreams.push(stream);
319
- } else {
320
- mediaHandler.screensharingStreams.push(stream);
321
- }
322
-
323
- return new CallFeed({
324
- client: this.client,
325
- roomId: this.roomId,
326
- userId: this.userId,
327
- deviceId: this.deviceId,
328
- stream,
329
- purpose: this.purpose,
330
- audioMuted: this.audioMuted,
331
- videoMuted: this.videoMuted,
332
- });
333
- }
334
-
335
- public dispose(): void {
336
- clearTimeout(this.volumeLooperTimeout);
337
- this.stream?.removeEventListener("addtrack", this.onAddTrack);
338
- this.call?.removeListener(CallEvent.State, this.onCallState);
339
- if (this.audioContext) {
340
- this.audioContext = undefined;
341
- this.analyser = undefined;
342
- releaseContext();
343
- }
344
- this._disposed = true;
345
- this.emit(CallFeedEvent.Disposed);
346
- }
347
-
348
- public get disposed(): boolean {
349
- return this._disposed;
350
- }
351
-
352
- private set disposed(value: boolean) {
353
- this._disposed = value;
354
- }
355
-
356
- public getLocalVolume(): number {
357
- return this.localVolume;
358
- }
359
-
360
- public setLocalVolume(localVolume: number): void {
361
- this.localVolume = localVolume;
362
- this.emit(CallFeedEvent.LocalVolumeChanged, localVolume);
363
- }
364
- }