@voicenter-team/opensips-js 1.0.22 → 1.0.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/dist/index.d.ts +737 -0
  2. package/dist/opensips-js.cjs.js +155 -0
  3. package/dist/opensips-js.es.js +21363 -0
  4. package/dist/opensips-js.iife.js +155 -0
  5. package/dist/opensips-js.umd.js +155 -0
  6. package/package.json +14 -8
  7. package/src/types/Dialog.d.ts +7 -0
  8. package/src/types/Socket.d.ts +8 -0
  9. package/src/types/UAExtended.d.ts +24 -12
  10. package/src/types/listeners.d.ts +12 -4
  11. package/src/types/msrp.d.ts +15 -9
  12. package/src/types/rtc.d.ts +15 -5
  13. package/src/types/timer.d.ts +7 -0
  14. package/build/enum/call.event.listener.type.d.ts +0 -7
  15. package/build/enum/call.event.listener.type.js +0 -10
  16. package/build/enum/message.event.listener.type.d.ts +0 -5
  17. package/build/enum/message.event.listener.type.js +0 -8
  18. package/build/enum/metric.keys.to.include.d.ts +0 -2
  19. package/build/enum/metric.keys.to.include.js +0 -4
  20. package/build/enum/session.direction.enum.d.ts +0 -2
  21. package/build/enum/session.direction.enum.js +0 -5
  22. package/build/helpers/UA/index.d.ts +0 -41
  23. package/build/helpers/UA/index.js +0 -318
  24. package/build/helpers/audio.helper.d.ts +0 -15
  25. package/build/helpers/audio.helper.js +0 -97
  26. package/build/helpers/filter.helper.d.ts +0 -2
  27. package/build/helpers/filter.helper.js +0 -14
  28. package/build/helpers/jssip.d.ts +0 -5
  29. package/build/helpers/jssip.js +0 -30
  30. package/build/helpers/time.helper.d.ts +0 -16
  31. package/build/helpers/time.helper.js +0 -28
  32. package/build/helpers/volume.helper.d.ts +0 -2
  33. package/build/helpers/volume.helper.js +0 -76
  34. package/build/helpers/webrtcmetrics/collector.d.ts +0 -32
  35. package/build/helpers/webrtcmetrics/collector.js +0 -282
  36. package/build/helpers/webrtcmetrics/engine.d.ts +0 -20
  37. package/build/helpers/webrtcmetrics/engine.js +0 -164
  38. package/build/helpers/webrtcmetrics/exporter.d.ts +0 -116
  39. package/build/helpers/webrtcmetrics/exporter.js +0 -528
  40. package/build/helpers/webrtcmetrics/extractor.d.ts +0 -1
  41. package/build/helpers/webrtcmetrics/extractor.js +0 -976
  42. package/build/helpers/webrtcmetrics/index.d.ts +0 -63
  43. package/build/helpers/webrtcmetrics/index.js +0 -93
  44. package/build/helpers/webrtcmetrics/metrics.d.ts +0 -2
  45. package/build/helpers/webrtcmetrics/metrics.js +0 -8
  46. package/build/helpers/webrtcmetrics/probe.d.ts +0 -76
  47. package/build/helpers/webrtcmetrics/probe.js +0 -153
  48. package/build/helpers/webrtcmetrics/utils/config.d.ts +0 -12
  49. package/build/helpers/webrtcmetrics/utils/config.js +0 -28
  50. package/build/helpers/webrtcmetrics/utils/helper.d.ts +0 -13
  51. package/build/helpers/webrtcmetrics/utils/helper.js +0 -134
  52. package/build/helpers/webrtcmetrics/utils/log.d.ts +0 -7
  53. package/build/helpers/webrtcmetrics/utils/log.js +0 -71
  54. package/build/helpers/webrtcmetrics/utils/models.d.ts +0 -309
  55. package/build/helpers/webrtcmetrics/utils/models.js +0 -298
  56. package/build/helpers/webrtcmetrics/utils/score.d.ts +0 -4
  57. package/build/helpers/webrtcmetrics/utils/score.js +0 -235
  58. package/build/helpers/webrtcmetrics/utils/shortUUId.d.ts +0 -1
  59. package/build/helpers/webrtcmetrics/utils/shortUUId.js +0 -7
  60. package/build/index.d.ts +0 -180
  61. package/build/index.js +0 -1141
  62. package/build/lib/msrp/message.d.ts +0 -12
  63. package/build/lib/msrp/message.js +0 -82
  64. package/build/lib/msrp/session.d.ts +0 -94
  65. package/build/lib/msrp/session.js +0 -621
@@ -1,318 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const jssip_1 = require("jssip");
30
- const UA_1 = __importDefault(require("jssip/lib/UA"));
31
- const JsSIP_C = __importStar(require("jssip/lib/Constants"));
32
- const Transactions_1 = __importDefault(require("jssip/lib/Transactions"));
33
- const session_1 = require("../../lib/msrp/session");
34
- const logger = console;
35
- const C = {
36
- // UA status codes.
37
- STATUS_INIT: 0,
38
- STATUS_READY: 1,
39
- STATUS_USER_CLOSED: 2,
40
- STATUS_NOT_READY: 3,
41
- // UA error codes.
42
- CONFIGURATION_ERROR: 1,
43
- NETWORK_ERROR: 2
44
- };
45
- const UAConstructor = UA_1.default;
46
- class UAExtended extends UAConstructor {
47
- constructor(configuration) {
48
- console.log(configuration);
49
- // const _proto = configuration.uri.split(':').shift()
50
- // const _user = (configuration.uri.split(':').pop()).split('@').shift()
51
- // const _realm = (configuration.uri.split(':').pop()).split('@').pop()
52
- // configuration.uri = URI.parse(configuration.uri)
53
- super(configuration);
54
- this._msrp_sessions = [];
55
- this._transactions = { nist: {},
56
- nict: {},
57
- ist: {},
58
- ict: {}
59
- };
60
- // console.log(configuration.uri)
61
- }
62
- call(target, options) {
63
- return super.call(target, options);
64
- }
65
- /**
66
- * new MSRPSession
67
- */
68
- newMSRPSession(session, data) {
69
- // Listening for message history update
70
- session.on('msgHistoryUpdate', (obj) => {
71
- console.log(obj);
72
- });
73
- this._msrp_sessions[session.id] = session;
74
- this.emit('newMSRPSession', data);
75
- }
76
- /**
77
- * MSRPSession destroyed.
78
- */
79
- destroyMSRPSession(session) {
80
- delete this._msrp_sessions[session.id];
81
- }
82
- receiveRequest(request) {
83
- const method = request.method;
84
- console.log('-----------');
85
- // Check that request URI points to us.
86
- if (request.ruri.user !== this._configuration.uri.user &&
87
- request.ruri.user !== this._contact.uri.user) {
88
- logger.debug('Request-URI does not point to us');
89
- if (request.method !== JsSIP_C.ACK) {
90
- request.reply_sl(404);
91
- }
92
- return;
93
- }
94
- // Check request URI scheme.
95
- if (request.ruri.scheme === JsSIP_C.SIPS) {
96
- request.reply_sl(416);
97
- return;
98
- }
99
- // Check transaction.
100
- if (Transactions_1.default.checkTransaction(this, request)) {
101
- return;
102
- }
103
- // Create the server transaction.
104
- if (method === JsSIP_C.INVITE) {
105
- /* eslint-disable no-new */
106
- new Transactions_1.default.InviteServerTransaction(this, this._transport, request);
107
- /* eslint-enable no-new */
108
- }
109
- else if (method !== JsSIP_C.ACK && method !== JsSIP_C.CANCEL) {
110
- /* eslint-disable no-new */
111
- new Transactions_1.default.NonInviteServerTransaction(this, this._transport, request);
112
- /* eslint-enable no-new */
113
- }
114
- /* RFC3261 12.2.2
115
- * Requests that do not change in any way the state of a dialog may be
116
- * received within a dialog (for example, an OPTIONS request).
117
- * They are processed as if they had been received outside the dialog.
118
- */
119
- if (method === JsSIP_C.OPTIONS) {
120
- if (this.listeners('newOptions').length === 0) {
121
- request.reply(200);
122
- return;
123
- }
124
- const message = new jssip_1.Options(this);
125
- message.init_incoming(request);
126
- }
127
- else if (method === JsSIP_C.MESSAGE) {
128
- if (this.listeners('newMessage').length === 0) {
129
- request.reply(405);
130
- return;
131
- }
132
- const message = new jssip_1.Message(this);
133
- message.init_incoming(request);
134
- }
135
- else if (method === JsSIP_C.INVITE) {
136
- // Initial INVITE.
137
- if (!request.to_tag && this.listeners('newRTCSession').length === 0) {
138
- request.reply(405);
139
- return;
140
- }
141
- }
142
- let dialog;
143
- let session;
144
- // Initial Request.
145
- if (!request.to_tag) {
146
- switch (method) {
147
- case JsSIP_C.INVITE:
148
- if (window.RTCPeerConnection) { // TODO
149
- if (request.hasHeader('replaces')) {
150
- const replaces = request.replaces;
151
- dialog = this._findDialog(replaces.call_id, replaces.from_tag, replaces.to_tag);
152
- if (dialog) {
153
- session = dialog.owner;
154
- if (!session.isEnded()) {
155
- session.receiveRequest(request);
156
- }
157
- else {
158
- request.reply(603);
159
- }
160
- }
161
- else {
162
- request.reply(481);
163
- }
164
- }
165
- else {
166
- if (request.body.search(/MSRP/ig)) {
167
- session = new session_1.MSRPSession(this);
168
- session.init_incoming(request);
169
- }
170
- else {
171
- session = new jssip_1.RTCSessiono(this);
172
- session.init_incoming(request);
173
- }
174
- }
175
- }
176
- else {
177
- logger.warn('INVITE received but WebRTC is not supported');
178
- request.reply(488);
179
- }
180
- break;
181
- case JsSIP_C.BYE:
182
- // Out of dialog BYE received.
183
- request.reply(481);
184
- break;
185
- case JsSIP_C.CANCEL:
186
- session = this._findSession(request);
187
- if (session) {
188
- session.receiveRequest(request);
189
- }
190
- else {
191
- logger.debug('received CANCEL request for a non existent session');
192
- }
193
- break;
194
- case JsSIP_C.ACK:
195
- /* Absorb it.
196
- * ACK request without a corresponding Invite Transaction
197
- * and without To tag.
198
- */
199
- break;
200
- case JsSIP_C.NOTIFY:
201
- // Receive new sip event.
202
- this.emit('sipEvent', {
203
- event: request.event,
204
- request
205
- });
206
- request.reply(200);
207
- break;
208
- default:
209
- request.reply(405);
210
- break;
211
- }
212
- }
213
- // In-dialog request.
214
- else {
215
- dialog = this._findDialog(request.call_id, request.from_tag, request.to_tag);
216
- if (dialog) {
217
- dialog.receiveRequest(request);
218
- }
219
- else if (method === JsSIP_C.NOTIFY) {
220
- session = this._findSession(request);
221
- if (session) {
222
- session.receiveRequest(request);
223
- }
224
- else {
225
- logger.debug('received NOTIFY request for a non existent subscription');
226
- request.reply(481, 'Subscription does not exist');
227
- }
228
- }
229
- /* RFC3261 12.2.2
230
- * Request with to tag, but no matching dialog found.
231
- * Exception: ACK for an Invite request for which a dialog has not
232
- * been created.
233
- */
234
- else if (method !== JsSIP_C.ACK) {
235
- request.reply(481);
236
- }
237
- }
238
- }
239
- startMSRP(target, options) {
240
- logger.debug('startMSRP()', options);
241
- const session = new session_1.MSRPSession(this);
242
- session.connect(target);
243
- return session;
244
- }
245
- terminateMSRPSessions(options) {
246
- logger.debug('terminateSessions()');
247
- for (const idx in this._msrp_sessions) {
248
- if (!this._msrp_sessions[idx].isEnded()) {
249
- this._msrp_sessions[idx].terminate(options);
250
- }
251
- }
252
- }
253
- stop() {
254
- logger.debug('stop()');
255
- // Remove dynamic settings.
256
- this._dynConfiguration = {};
257
- if (this._status === C.STATUS_USER_CLOSED) {
258
- logger.debug('UA already closed');
259
- return;
260
- }
261
- // Close registrator.
262
- this._registrator.close();
263
- // If there are session wait a bit so CANCEL/BYE can be sent and their responses received.
264
- const num_sessions = Object.keys(this._sessions).length;
265
- // Run _terminate_ on every Session.
266
- for (const session in this._sessions) {
267
- if (Object.prototype.hasOwnProperty.call(this._sessions, session)) {
268
- logger.debug(`closing session ${session}`);
269
- try {
270
- this._sessions[session].terminate();
271
- }
272
- catch (error) {
273
- console.error(error);
274
- }
275
- }
276
- }
277
- // If there are session wait a bit so CANCEL/BYE can be sent and their responses received.
278
- // const num_msrp_sessions = Object.keys(this._msrp_sessions).length
279
- // Run _terminate_ on every Session.
280
- for (const msrp_session in this._msrp_sessions) {
281
- if (Object.prototype.hasOwnProperty.call(this._msrp_sessions, msrp_session)) {
282
- logger.debug(`closing session ${msrp_session}`);
283
- try {
284
- this._msrp_sessions[msrp_session].terminate();
285
- }
286
- catch (error) {
287
- console.error(error);
288
- }
289
- }
290
- }
291
- // Run _close_ on every applicant.
292
- for (const applicant in this._applicants) {
293
- if (Object.prototype.hasOwnProperty.call(this._applicants, applicant)) {
294
- try {
295
- this._applicants[applicant].close();
296
- }
297
- catch (error) {
298
- console.error(error);
299
- }
300
- }
301
- }
302
- this._status = C.STATUS_USER_CLOSED;
303
- const num_transactions = Object.keys(this._transactions.nict).length +
304
- Object.keys(this._transactions.nist).length +
305
- Object.keys(this._transactions.ict).length +
306
- Object.keys(this._transactions.ist).length;
307
- if (num_transactions === 0 && num_sessions === 0) {
308
- this._transport.disconnect();
309
- }
310
- else {
311
- this._closeTimer = setTimeout(() => {
312
- this._closeTimer = null;
313
- this._transport.disconnect();
314
- }, 2000);
315
- }
316
- }
317
- }
318
- exports.default = UAExtended;
@@ -1,15 +0,0 @@
1
- import { ICall, MediaEvent, CustomLoggerType } from '@/types/rtc';
2
- import { Writeable } from '@/types/generic';
3
- import { IMessage } from '@/types/msrp';
4
- type ICallKey = keyof ICall;
5
- declare const CALL_KEYS_TO_INCLUDE: Array<ICallKey>;
6
- type IMessageKey = keyof IMessage;
7
- declare const MESSAGE_KEYS_TO_INCLUDE: Array<IMessageKey>;
8
- export type ICallSimplified = Writeable<Pick<ICall, typeof CALL_KEYS_TO_INCLUDE[number]>>;
9
- export type IMessageSimplified = Writeable<Pick<IMessage, typeof MESSAGE_KEYS_TO_INCLUDE[number]>>;
10
- export declare function simplifyCallObject(call: ICall): ICallSimplified;
11
- export declare function simplifyMessageObject(call: IMessage): IMessageSimplified;
12
- export declare function processAudioVolume(stream: MediaStream, volume: number): MediaStream;
13
- export declare function syncStream(event: MediaEvent, call: ICall, outputDevice: string, volume: number): void;
14
- export declare function isLoggerCompatible(logger: CustomLoggerType): true | undefined;
15
- export {};
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLoggerCompatible = exports.syncStream = exports.processAudioVolume = exports.simplifyMessageObject = exports.simplifyCallObject = void 0;
4
- const CALL_KEYS_TO_INCLUDE = [
5
- 'roomId',
6
- '_audioMuted',
7
- '_cancel_reason',
8
- '_contact',
9
- 'direction',
10
- '_end_time',
11
- '_eventsCount',
12
- '_from_tag',
13
- '_id',
14
- '_is_canceled',
15
- '_is_confirmed',
16
- '_late_sdp',
17
- '_localHold',
18
- '_videoMuted',
19
- 'status',
20
- 'start_time',
21
- '_remote_identity',
22
- 'audioTag',
23
- //'audioQuality',
24
- 'isOnHold',
25
- //'originalStream',
26
- 'localMuted',
27
- 'autoAnswer'
28
- ];
29
- const MESSAGE_KEYS_TO_INCLUDE = [
30
- //'roomId',
31
- '_cancel_reason',
32
- '_contact',
33
- 'direction',
34
- '_end_time',
35
- '_eventsCount',
36
- '_from_tag',
37
- '_id',
38
- '_is_canceled',
39
- '_is_confirmed',
40
- '_late_sdp',
41
- 'status',
42
- 'start_time',
43
- '_remote_identity',
44
- 'target_addr'
45
- ];
46
- function simplifyCallObject(call) {
47
- const simplified = {};
48
- CALL_KEYS_TO_INCLUDE.forEach(key => {
49
- if (call[key] !== undefined) {
50
- simplified[key] = call[key];
51
- }
52
- });
53
- simplified.localHold = call._localHold;
54
- return simplified;
55
- }
56
- exports.simplifyCallObject = simplifyCallObject;
57
- function simplifyMessageObject(call) {
58
- const simplified = {};
59
- MESSAGE_KEYS_TO_INCLUDE.forEach(key => {
60
- if (call[key] !== undefined) {
61
- simplified[key] = call[key];
62
- }
63
- });
64
- return simplified;
65
- }
66
- exports.simplifyMessageObject = simplifyMessageObject;
67
- function processAudioVolume(stream, volume) {
68
- const audioContext = new AudioContext();
69
- const audioSource = audioContext.createMediaStreamSource(stream);
70
- const audioDestination = audioContext.createMediaStreamDestination();
71
- const gainNode = audioContext.createGain();
72
- audioSource.connect(gainNode);
73
- gainNode.connect(audioDestination);
74
- gainNode.gain.value = volume;
75
- return audioDestination.stream;
76
- }
77
- exports.processAudioVolume = processAudioVolume;
78
- function syncStream(event, call, outputDevice, volume) {
79
- const audio = document.createElement('audio');
80
- audio.id = call._id;
81
- audio.className = 'audioTag';
82
- audio.srcObject = event.stream;
83
- audio.setSinkId(outputDevice);
84
- audio.volume = volume;
85
- audio.play();
86
- call.audioTag = audio;
87
- }
88
- exports.syncStream = syncStream;
89
- function isLoggerCompatible(logger) {
90
- if (logger
91
- && typeof logger.log === 'function'
92
- && typeof logger.warn === 'function'
93
- && typeof logger.error === 'function') {
94
- return true;
95
- }
96
- }
97
- exports.isLoggerCompatible = isLoggerCompatible;
@@ -1,2 +0,0 @@
1
- import { ProbeMetricInType } from '@/types/webrtcmetrics';
2
- export declare function filterObjectKeys(fullObj: ProbeMetricInType, keys: Array<keyof ProbeMetricInType>): ProbeMetricInType;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterObjectKeys = void 0;
4
- function filterObjectKeys(fullObj, keys) {
5
- return Object.keys(fullObj)
6
- .filter((key) => keys.includes(key))
7
- .reduce((obj, key) => {
8
- const k = key;
9
- //const o = obj as ProbeMetricInType
10
- //o[k] = fullObj[k] //as ProbeMetricInType[keyof ProbeMetricInType]
11
- return Object.assign(Object.assign({}, obj), { [k]: fullObj[k] });
12
- }, {});
13
- }
14
- exports.filterObjectKeys = filterObjectKeys;
@@ -1,5 +0,0 @@
1
- import JsSIP, { UA } from 'jssip';
2
- import { IncomingAckEvent, IncomingEvent, OutgoingAckEvent, OutgoingEvent } from 'jssip/lib/RTCSession';
3
- import { RTCSessionEvent, UAConfiguration, UAEventMap } from 'jssip/lib/UA';
4
- export default JsSIP;
5
- export { UA, IncomingAckEvent, IncomingEvent, OutgoingAckEvent, OutgoingEvent, RTCSessionEvent, UAConfiguration, UAEventMap };
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.UA = void 0;
27
- // @ts-nocheck
28
- const jssip_1 = __importStar(require("jssip"));
29
- Object.defineProperty(exports, "UA", { enumerable: true, get: function () { return jssip_1.UA; } });
30
- exports.default = jssip_1.default;
@@ -1,16 +0,0 @@
1
- export interface ITimeData {
2
- callId: string;
3
- hours: number;
4
- minutes: number;
5
- seconds: number;
6
- formatted: string;
7
- }
8
- export type TempTimeData = Omit<ITimeData, 'callId'> & {
9
- callId: string | undefined;
10
- };
11
- export declare function setupTime(time: TempTimeData): {
12
- seconds: number;
13
- minutes: number;
14
- hours: number;
15
- formatted: string;
16
- };
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupTime = void 0;
4
- function formatTime(time) {
5
- return time < 10 ? `0${time}` : `${time}`;
6
- }
7
- function setupTime(time) {
8
- let hours = time.hours || 0;
9
- let minutes = time.minutes || 0;
10
- let seconds = time.seconds || 0;
11
- seconds++;
12
- if (seconds === 60) {
13
- seconds = 0;
14
- minutes++;
15
- if (minutes === 60) {
16
- minutes = 0;
17
- hours++;
18
- }
19
- }
20
- const formatted = `${formatTime(hours)}:${formatTime(minutes)}:${formatTime(seconds)}`;
21
- return {
22
- seconds,
23
- minutes,
24
- hours,
25
- formatted
26
- };
27
- }
28
- exports.setupTime = setupTime;
@@ -1,2 +0,0 @@
1
- export declare const runIndicator: (stream: MediaStream, deviceId: string) => void;
2
- export declare const clearVolumeInterval: () => void;
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clearVolumeInterval = exports.runIndicator = void 0;
4
- const height = 20;
5
- const lineWidth = 4;
6
- let interval = undefined;
7
- const runIndicator = (stream, deviceId) => {
8
- if (stream && stream.getTracks().length) {
9
- //console.log('RUN INDICATOR IF')
10
- getVolumeLevelBar(stream, deviceId);
11
- }
12
- else {
13
- //console.log('RUN INDICATOR ELSE')
14
- (0, exports.clearVolumeInterval)();
15
- }
16
- };
17
- exports.runIndicator = runIndicator;
18
- const clearVolumeInterval = () => {
19
- clearInterval(interval);
20
- };
21
- exports.clearVolumeInterval = clearVolumeInterval;
22
- const getMaxSmallIndicatorHeight = (value) => {
23
- const halfLineHeight = height / 4;
24
- return value < halfLineHeight ? value : halfLineHeight;
25
- };
26
- const getVolumeLevelBar = (stream, deviceId) => {
27
- //console.log('IN GET VOLUME LEVEL BAR')
28
- //console.log('TRACKS LENGTH', stream.getTracks().length)
29
- clearInterval(interval);
30
- const audioContext = new AudioContext();
31
- const analyser = audioContext.createAnalyser();
32
- const microphone = audioContext.createMediaStreamSource(stream);
33
- const javascriptNode = audioContext.createScriptProcessor(2048, 1, 1);
34
- analyser.smoothingTimeConstant = 0.8;
35
- analyser.fftSize = 1024;
36
- microphone.connect(analyser);
37
- analyser.connect(javascriptNode);
38
- javascriptNode.connect(audioContext.destination);
39
- const canvas = document.getElementById(`canvas-${deviceId}`);
40
- if (!canvas) {
41
- return;
42
- }
43
- const indicatorWidth = lineWidth * 5;
44
- const halfLineHeight = height / 2;
45
- canvas.setAttribute('width', `${indicatorWidth}`);
46
- canvas.setAttribute('height', `${height}`);
47
- const canvasContext = canvas.getContext('2d');
48
- interval = setInterval(() => {
49
- if (!canvasContext) {
50
- return;
51
- }
52
- const array = new Uint8Array(analyser.frequencyBinCount);
53
- analyser.getByteFrequencyData(array);
54
- let values = 0;
55
- const length = array.length;
56
- for (let i = 0; i < length; i++) {
57
- values += (array[i]);
58
- }
59
- const average = values / length;
60
- //console.log('average', average)
61
- canvasContext.fillStyle = 'blue'; //getComputedStyle(document.body).getPropertyValue('--primary-actions')
62
- const halfValue = average / 2;
63
- canvasContext.clearRect(0, halfLineHeight, lineWidth, halfLineHeight);
64
- canvasContext.fillRect(0, halfLineHeight, lineWidth, getMaxSmallIndicatorHeight(halfValue));
65
- canvasContext.clearRect(0, halfLineHeight, lineWidth, -halfLineHeight);
66
- canvasContext.fillRect(0, halfLineHeight, lineWidth, 0 - getMaxSmallIndicatorHeight(halfValue));
67
- canvasContext.clearRect(lineWidth * 2, halfLineHeight, lineWidth, halfLineHeight);
68
- canvasContext.fillRect(lineWidth * 2, halfLineHeight, lineWidth, average);
69
- canvasContext.clearRect(lineWidth * 2, halfLineHeight, lineWidth, -halfLineHeight);
70
- canvasContext.fillRect(lineWidth * 2, halfLineHeight, lineWidth, 0 - average);
71
- canvasContext.clearRect(lineWidth * 4, halfLineHeight, lineWidth, halfLineHeight);
72
- canvasContext.fillRect(lineWidth * 4, halfLineHeight, lineWidth, getMaxSmallIndicatorHeight(halfValue));
73
- canvasContext.clearRect(lineWidth * 4, halfLineHeight, lineWidth, -halfLineHeight);
74
- canvasContext.fillRect(lineWidth * 4, halfLineHeight, lineWidth, 0 - getMaxSmallIndicatorHeight(halfValue));
75
- }, 200);
76
- };
@@ -1,32 +0,0 @@
1
- export default class Collector {
2
- constructor(cfg: any, refProbeId: any);
3
- _callbacks: {
4
- onreport: null;
5
- onticket: null;
6
- };
7
- _id: string;
8
- _moduleName: string;
9
- _probeId: any;
10
- _config: any;
11
- _exporter: Exporter;
12
- _state: string;
13
- analyze(stats: any, previousReport: any, beforeLastReport: any, referenceReport: any): any;
14
- takeReferenceStats(): Promise<any>;
15
- collectStats(): Promise<any>;
16
- start(): Promise<void>;
17
- set state(arg: string);
18
- get state(): string;
19
- _startedTime: Date | undefined;
20
- mute(): Promise<void>;
21
- unmute(): Promise<void>;
22
- stop(forced: any): Promise<void>;
23
- _stoppedTime: Date | undefined;
24
- registerCallback(name: any, callback: any, context: any): void;
25
- unregisterCallback(name: any): void;
26
- fireOnReport(report: any): void;
27
- fireOnTicket(ticket: any): void;
28
- updateConfig(config: any): void;
29
- addCustomEvent(at: any, category: any, name: any, description: any): void;
30
- registerToPCEvents(): Promise<void>;
31
- }
32
- import Exporter from "./exporter";