@voicenter-team/opensips-js 1.0.21 → 1.0.42
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +737 -0
- package/dist/opensips-js.cjs.js +155 -0
- package/dist/opensips-js.es.js +21363 -0
- package/dist/opensips-js.iife.js +155 -0
- package/dist/opensips-js.umd.js +155 -0
- package/package.json +15 -9
- package/src/types/Dialog.d.ts +7 -0
- package/src/types/Socket.d.ts +8 -0
- package/src/types/Transactions.d.ts +9 -0
- package/src/types/UAExtended.d.ts +86 -0
- package/src/types/listeners.d.ts +26 -2
- package/src/types/msrp.d.ts +55 -0
- package/src/types/rtc.d.ts +23 -4
- package/src/types/timer.d.ts +7 -0
- package/build/enum/call.event.listener.type.d.ts +0 -7
- package/build/enum/call.event.listener.type.js +0 -10
- package/build/enum/metric.keys.to.include.d.ts +0 -2
- package/build/enum/metric.keys.to.include.js +0 -4
- package/build/helpers/UA/index.d.ts +0 -6
- package/build/helpers/UA/index.js +0 -9
- package/build/helpers/audio.helper.d.ts +0 -9
- package/build/helpers/audio.helper.js +0 -61
- package/build/helpers/filter.helper.d.ts +0 -2
- package/build/helpers/filter.helper.js +0 -14
- package/build/helpers/time.helper.d.ts +0 -16
- package/build/helpers/time.helper.js +0 -28
- package/build/helpers/volume.helper.d.ts +0 -2
- package/build/helpers/volume.helper.js +0 -76
- package/build/helpers/webrtcmetrics/collector.d.ts +0 -32
- package/build/helpers/webrtcmetrics/collector.js +0 -282
- package/build/helpers/webrtcmetrics/engine.d.ts +0 -20
- package/build/helpers/webrtcmetrics/engine.js +0 -164
- package/build/helpers/webrtcmetrics/exporter.d.ts +0 -116
- package/build/helpers/webrtcmetrics/exporter.js +0 -528
- package/build/helpers/webrtcmetrics/extractor.d.ts +0 -1
- package/build/helpers/webrtcmetrics/extractor.js +0 -976
- package/build/helpers/webrtcmetrics/index.d.ts +0 -63
- package/build/helpers/webrtcmetrics/index.js +0 -93
- package/build/helpers/webrtcmetrics/metrics.d.ts +0 -2
- package/build/helpers/webrtcmetrics/metrics.js +0 -8
- package/build/helpers/webrtcmetrics/probe.d.ts +0 -76
- package/build/helpers/webrtcmetrics/probe.js +0 -153
- package/build/helpers/webrtcmetrics/utils/config.d.ts +0 -12
- package/build/helpers/webrtcmetrics/utils/config.js +0 -28
- package/build/helpers/webrtcmetrics/utils/helper.d.ts +0 -13
- package/build/helpers/webrtcmetrics/utils/helper.js +0 -134
- package/build/helpers/webrtcmetrics/utils/log.d.ts +0 -7
- package/build/helpers/webrtcmetrics/utils/log.js +0 -71
- package/build/helpers/webrtcmetrics/utils/models.d.ts +0 -309
- package/build/helpers/webrtcmetrics/utils/models.js +0 -298
- package/build/helpers/webrtcmetrics/utils/score.d.ts +0 -4
- package/build/helpers/webrtcmetrics/utils/score.js +0 -235
- package/build/helpers/webrtcmetrics/utils/shortUUId.d.ts +0 -1
- package/build/helpers/webrtcmetrics/utils/shortUUId.js +0 -7
- package/build/index.d.ts +0 -181
- package/build/index.js +0 -911
package/package.json
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
{
|
2
2
|
"name": "@voicenter-team/opensips-js",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.42",
|
4
4
|
"description": "The JS package for opensips",
|
5
5
|
"default": "src/index.ts",
|
6
|
-
"
|
7
|
-
"
|
6
|
+
"jsdelivr": "dist/opensips-js.umd.js",
|
7
|
+
"main": "dist/opensips-js.cjs.js",
|
8
|
+
"module": "dist/opensips-js.es.js",
|
9
|
+
"unpkg": "dist/opensips-js.umd.js",
|
10
|
+
"types": "dist/index.d.ts",
|
8
11
|
"scripts": {
|
9
|
-
"build": "
|
12
|
+
"build": "yarn run vite-build",
|
13
|
+
"build-no-check": "tsc --noEmit --skipLibCheck --project tsconfig.json && tsc-alias -p tsconfig.json",
|
10
14
|
"dev": "vite",
|
11
|
-
"
|
12
|
-
"docs-build": "yarn run
|
15
|
+
"vite-build": "vite build",
|
16
|
+
"docs-build": "yarn run vite-build && cd docs && yarn && yarn run build",
|
13
17
|
"test": "echo \"Error: no test specified\" && exit 1",
|
14
18
|
"ts-check": "tsc --noEmit",
|
15
19
|
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts --fix --ignore-path .gitignore"
|
@@ -35,6 +39,7 @@
|
|
35
39
|
"@typescript-eslint/eslint-plugin": "^5.53.0",
|
36
40
|
"@typescript-eslint/parser": "^5.53.0",
|
37
41
|
"@vitejs/plugin-vue": "^4.2.3",
|
42
|
+
"@voicenter-team/eslint-config-ts": "^1.0.21",
|
38
43
|
"dotenv": "^16.0.3",
|
39
44
|
"eslint": "^8.35.0",
|
40
45
|
"pre-commit": "^1.2.2",
|
@@ -42,20 +47,21 @@
|
|
42
47
|
"regenerator-runtime": "^0.13.11",
|
43
48
|
"tsc-alias": "^1.8.6",
|
44
49
|
"typescript": "^4.9.5",
|
45
|
-
"vite": "4.
|
50
|
+
"vite": "4.4.11",
|
51
|
+
"vite-plugin-dts": "3.5.3",
|
46
52
|
"vite-plugin-singlefile": "^0.13.5",
|
47
53
|
"vue": "3.2.25"
|
48
54
|
},
|
49
55
|
"dependencies": {
|
50
56
|
"@types/mime": "^3.0.1",
|
51
57
|
"generate-unique-id": "^2.0.1",
|
52
|
-
"jssip": "
|
58
|
+
"jssip": "3.10.0",
|
53
59
|
"loglevel": "^1.8.1",
|
54
60
|
"mime": "^3.0.0",
|
55
61
|
"p-iteration": "^1.1.8"
|
56
62
|
},
|
57
63
|
"files": [
|
58
|
-
"
|
64
|
+
"dist",
|
59
65
|
"src/types"
|
60
66
|
]
|
61
67
|
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import { Transport } from 'jssip/lib/Transport'
|
2
|
+
import { MSRPSession, MSRPSessionEventMap, DialogType } from '@/lib/msrp/session'
|
3
|
+
import { Socket, WeightedSocket } from 'jssip/lib/Socket'
|
4
|
+
import { IncomingRequest } from 'jssip/lib/SIPMessage'
|
5
|
+
import { AnswerOptions, RTCSession } from 'jssip/lib/RTCSession'
|
6
|
+
import { CallOptionsExtended } from '@/types/rtc'
|
7
|
+
|
8
|
+
declare module 'jssip' {
|
9
|
+
export class UA {
|
10
|
+
protected _transport: Transport
|
11
|
+
protected _sessions: any[]
|
12
|
+
protected _msrp_sessions: any[]
|
13
|
+
protected _registrator: any
|
14
|
+
protected _applicants: any[]
|
15
|
+
protected _dynConfiguration: object
|
16
|
+
protected _status: number
|
17
|
+
protected _closeTimer: any
|
18
|
+
protected _configuration: any
|
19
|
+
protected _contact: any
|
20
|
+
|
21
|
+
_findDialog(call_id: string, from: string, to: string): DialogType
|
22
|
+
receiveRequest(request): void
|
23
|
+
_findSession(request): MSRPSession
|
24
|
+
call(target: string, options: CallOptionsExtended): RTCSession
|
25
|
+
}
|
26
|
+
|
27
|
+
export class Message {
|
28
|
+
constructor(ua: UA)
|
29
|
+
init_incoming(request: IncomingRequest): void
|
30
|
+
}
|
31
|
+
|
32
|
+
export class Options {
|
33
|
+
constructor(ua: UA)
|
34
|
+
init_incoming(request: IncomingRequest): void
|
35
|
+
}
|
36
|
+
|
37
|
+
export interface MSRPOptions extends AnswerOptions {
|
38
|
+
eventHandlers?: Partial<MSRPSessionEventMap>;
|
39
|
+
anonymous?: boolean;
|
40
|
+
fromUserName?: string;
|
41
|
+
fromDisplayName?: string;
|
42
|
+
}
|
43
|
+
export interface UAConfiguration {
|
44
|
+
// mandatory parameters
|
45
|
+
sockets: Socket | Socket[] | WeightedSocket[] ;
|
46
|
+
uri: string;
|
47
|
+
// optional parameters
|
48
|
+
authorization_jwt?: string;
|
49
|
+
authorization_user?: string;
|
50
|
+
connection_recovery_max_interval?: number;
|
51
|
+
connection_recovery_min_interval?: number;
|
52
|
+
contact_uri?: string;
|
53
|
+
display_name?: string;
|
54
|
+
instance_id?: string;
|
55
|
+
no_answer_timeout?: number;
|
56
|
+
session_timers?: boolean;
|
57
|
+
session_timers_refresh_method?: string;
|
58
|
+
session_timers_force_refresher?: boolean;
|
59
|
+
password?: string;
|
60
|
+
realm?: string;
|
61
|
+
ha1?: string;
|
62
|
+
register?: boolean;
|
63
|
+
register_expires?: number;
|
64
|
+
registrar_server?: string;
|
65
|
+
use_preloaded_route?: boolean;
|
66
|
+
user_agent?: string;
|
67
|
+
extra_headers?: string[];
|
68
|
+
}
|
69
|
+
export class RTCSessiono {
|
70
|
+
init_incoming(request: IncomingRequest): void
|
71
|
+
constructor(ua: UA)
|
72
|
+
}
|
73
|
+
|
74
|
+
/*export class Dialog {
|
75
|
+
|
76
|
+
}*/
|
77
|
+
}
|
78
|
+
|
79
|
+
declare module 'jssip/lib/URI' {
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
/*declare module 'jssip/lib/Dialog' {
|
84
|
+
export class owner: object
|
85
|
+
receiveRequest (request: any): void
|
86
|
+
}*/
|
package/src/types/listeners.d.ts
CHANGED
@@ -1,11 +1,23 @@
|
|
1
|
-
import { ICall, RoomChangeEmitType, ICallStatus } from '@/types/rtc'
|
2
1
|
import { UAEventMap } from 'jssip/lib/UA'
|
3
2
|
|
3
|
+
import { IMessage, MSRPSessionExtended } from '@/types/msrp'
|
4
|
+
import { ICall, RoomChangeEmitType, ICallStatus } from '@/types/rtc'
|
5
|
+
import MSRPMessage from '@/lib/msrp/message'
|
6
|
+
import { ITimeData } from '@/types/timer'
|
7
|
+
import { IncomingMSRPSessionEvent, OutgoingMSRPSessionEvent } from '@/helpers/UA'
|
8
|
+
|
9
|
+
export type MSRPMessageEventType = {
|
10
|
+
message: MSRPMessage,
|
11
|
+
session: MSRPSessionExtended
|
12
|
+
}
|
13
|
+
|
4
14
|
export type readyListener = (value: boolean) => void
|
5
15
|
export type changeActiveCallsListener = (event: { [key: string]: ICall }) => void
|
16
|
+
export type changeActiveMessagesListener = (event: { [key: string]: IMessage }) => void
|
6
17
|
export type TestEventListener = (event: { test: string }) => void
|
7
18
|
export type ActiveRoomListener = (event: number | undefined) => void
|
8
19
|
export type CallAddingProgressListener = (callId: string | undefined) => void
|
20
|
+
export type MSRPInitializingListener = (sessionId: string | undefined) => void
|
9
21
|
export type RoomDeletedListener = (roomId: number) => void
|
10
22
|
export type changeActiveInputMediaDeviceListener = (event: string) => void
|
11
23
|
export type changeActiveOutputMediaDeviceListener = (event: string) => void
|
@@ -17,14 +29,22 @@ export type changeOriginalStreamListener = (value: MediaStream) => void
|
|
17
29
|
export type addRoomListener = (value: RoomChangeEmitType) => void
|
18
30
|
export type updateRoomListener = (value: RoomChangeEmitType) => void
|
19
31
|
export type removeRoomListener = (value: RoomChangeEmitType) => void
|
32
|
+
export type IncomingMSRPSessionListener = (event: IncomingMSRPSessionEvent) => void;
|
33
|
+
export type OutgoingMSRPSessionListener = (event: OutgoingMSRPSessionEvent) => void;
|
34
|
+
export type MSRPSessionListener = IncomingMSRPSessionListener | OutgoingMSRPSessionListener;
|
35
|
+
export type MSRPMessageListener = (event: MSRPMessageEventType) => void;
|
20
36
|
export type changeCallStatusListener = (event: { [key: string]: ICallStatus }) => void
|
37
|
+
export type changeCallTimeListener = (event: { [key: string]: ITimeData }) => void
|
38
|
+
export type changeCallMetricsListener = (event: { [key: string]: any }) => void
|
21
39
|
|
22
40
|
export interface OpenSIPSEventMap extends UAEventMap {
|
23
41
|
ready: readyListener
|
24
42
|
changeActiveCalls: changeActiveCallsListener
|
43
|
+
changeActiveMessages: changeActiveMessagesListener
|
25
44
|
callConfirmed: TestEventListener
|
26
45
|
currentActiveRoomChanged: ActiveRoomListener
|
27
46
|
callAddingInProgressChanged: CallAddingProgressListener
|
47
|
+
isMSRPInitializingChanged: MSRPInitializingListener
|
28
48
|
roomDeleted: RoomDeletedListener
|
29
49
|
changeActiveInputMediaDevice: changeActiveInputMediaDeviceListener
|
30
50
|
changeActiveOutputMediaDevice: changeActiveOutputMediaDeviceListener
|
@@ -37,8 +57,12 @@ export interface OpenSIPSEventMap extends UAEventMap {
|
|
37
57
|
updateRoom: updateRoomListener
|
38
58
|
removeRoom: removeRoomListener
|
39
59
|
changeCallStatus: changeCallStatusListener
|
60
|
+
changeCallTime: changeCallTimeListener
|
61
|
+
changeCallMetrics: changeCallMetricsListener
|
62
|
+
newMSRPMessage: MSRPMessageListener
|
63
|
+
newMSRPSession: MSRPSessionListener
|
40
64
|
}
|
41
65
|
|
42
66
|
export type ListenersKeyType = keyof OpenSIPSEventMap
|
43
67
|
export type ListenersCallbackFnType = OpenSIPSEventMap[ListenersKeyType]
|
44
|
-
export type ListenerCallbackFnType<T extends ListenersKeyType> = OpenSIPSEventMap[T]
|
68
|
+
export type ListenerCallbackFnType<T extends ListenersKeyType> = OpenSIPSEventMap[T]
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import {
|
2
|
+
MSRPSession,
|
3
|
+
MSRPSessionEventMap
|
4
|
+
} from '@/lib/msrp/session'
|
5
|
+
import { EndEvent,
|
6
|
+
IncomingAckEvent,
|
7
|
+
IncomingEvent,
|
8
|
+
OutgoingAckEvent,
|
9
|
+
OutgoingEvent,
|
10
|
+
SessionDirection } from 'jssip/lib/RTCSession'
|
11
|
+
|
12
|
+
import { StreamMediaType } from '@/types/rtc'
|
13
|
+
import MSRPMessage from '@/lib/msrp/message'
|
14
|
+
|
15
|
+
export { MSRPMessage }
|
16
|
+
|
17
|
+
export type ListenerEventType = EndEvent | IncomingEvent | OutgoingEvent | IncomingAckEvent | OutgoingAckEvent
|
18
|
+
|
19
|
+
export interface IMessage extends MSRPSessionExtended {
|
20
|
+
roomId?: number
|
21
|
+
localMuted?: boolean
|
22
|
+
localHold?: boolean
|
23
|
+
audioTag?: StreamMediaType
|
24
|
+
terminate(): void
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
export interface MSRPSessionExtended extends MSRPSession {
|
29
|
+
id: string
|
30
|
+
status: string
|
31
|
+
start_time: Date
|
32
|
+
direction: SessionDirection
|
33
|
+
_id: string
|
34
|
+
_cancel_reason: string
|
35
|
+
_contact: string
|
36
|
+
_end_time: Date
|
37
|
+
_eventsCount: number
|
38
|
+
_from_tag: string
|
39
|
+
_is_canceled: boolean
|
40
|
+
_is_confirmed: boolean
|
41
|
+
_late_sdp: string
|
42
|
+
_status: number
|
43
|
+
_remote_identity: string
|
44
|
+
target_addr: Array<string>
|
45
|
+
answer(options?: any): void
|
46
|
+
_init_incomeing(): void
|
47
|
+
sendMSRP(body: string): void
|
48
|
+
on<T extends keyof MSRPSessionEventMap>(type: T, listener: MSRPSessionEventMap[T]): this;
|
49
|
+
}
|
50
|
+
|
51
|
+
export interface TriggerMSRPListenerOptions {
|
52
|
+
listenerType: string
|
53
|
+
session: MSRPSessionExtended
|
54
|
+
event?: ListenerEventType
|
55
|
+
}
|
package/src/types/rtc.d.ts
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
import { MediaStreamConstraints } from 'lib.dom.d.ts'
|
2
|
-
import { Partial } from 'lib.es5.d.ts'
|
3
1
|
import {
|
4
2
|
AnswerOptions,
|
5
3
|
EndEvent,
|
@@ -7,8 +5,13 @@ import {
|
|
7
5
|
IncomingEvent,
|
8
6
|
OutgoingAckEvent,
|
9
7
|
OutgoingEvent,
|
10
|
-
RTCSession,
|
8
|
+
RTCSession,
|
9
|
+
RTCSessionEventMap,
|
10
|
+
MediaConstraints
|
11
11
|
} from 'jssip/lib/RTCSession'
|
12
|
+
import {
|
13
|
+
IncomingRequest
|
14
|
+
} from 'jssip/lib/SIPMessage'
|
12
15
|
import { UAConfiguration } from 'jssip/lib/UA'
|
13
16
|
|
14
17
|
export type IntervalType = ReturnType<typeof setInterval>
|
@@ -39,8 +42,15 @@ export interface StreamMediaType extends HTMLAudioElement {
|
|
39
42
|
setSinkId (id: string): Promise<void>
|
40
43
|
}
|
41
44
|
|
45
|
+
type ExactConstraints = {
|
46
|
+
audio?: {
|
47
|
+
deviceId: {exact: string}
|
48
|
+
}
|
49
|
+
video?: boolean;
|
50
|
+
}
|
51
|
+
|
42
52
|
export interface AnswerOptionsExtended extends AnswerOptions {
|
43
|
-
mediaConstraints?:
|
53
|
+
mediaConstraints?: MediaConstraints | ExactConstraints
|
44
54
|
}
|
45
55
|
|
46
56
|
export interface RemoteIdentityCallType {
|
@@ -68,6 +78,7 @@ export interface RTCSessionExtended extends RTCSession {
|
|
68
78
|
_status: number
|
69
79
|
_remote_identity: RemoteIdentityCallType
|
70
80
|
answer(options?: AnswerOptionsExtended): void
|
81
|
+
init_icncoming(request: IncomingRequest): void
|
71
82
|
}
|
72
83
|
|
73
84
|
export interface ICall extends RTCSessionExtended {
|
@@ -131,6 +142,14 @@ export interface TriggerListenerOptions {
|
|
131
142
|
session: RTCSessionExtended
|
132
143
|
event?: ListenerEventType
|
133
144
|
}
|
145
|
+
type CommonLogMethodType = (...args: unknown[]) => void
|
146
|
+
|
147
|
+
export interface CustomLoggerType {
|
148
|
+
log: CommonLogMethodType
|
149
|
+
warn: CommonLogMethodType
|
150
|
+
error: CommonLogMethodType
|
151
|
+
debug: CommonLogMethodType
|
152
|
+
}
|
134
153
|
|
135
154
|
/* UA */
|
136
155
|
export interface CallOptionsExtended extends AnswerOptionsExtended {
|
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.CALL_EVENT_LISTENER_TYPE = void 0;
|
4
|
-
exports.CALL_EVENT_LISTENER_TYPE = {
|
5
|
-
NEW_CALL: 'new_call',
|
6
|
-
CALL_CONFIRMED: 'confirmed',
|
7
|
-
CALL_FAILED: 'failed',
|
8
|
-
CALL_PROGRESS: 'progress',
|
9
|
-
CALL_ENDED: 'ended'
|
10
|
-
};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { ICall, MediaEvent } from '@/types/rtc';
|
2
|
-
import { Writeable } from '@/types/generic';
|
3
|
-
type ICallKey = keyof ICall;
|
4
|
-
declare const CALL_KEYS_TO_INCLUDE: Array<ICallKey>;
|
5
|
-
export type ICallSimplified = Writeable<Pick<ICall, typeof CALL_KEYS_TO_INCLUDE[number]>>;
|
6
|
-
export declare function simplifyCallObject(call: ICall): ICallSimplified;
|
7
|
-
export declare function processAudioVolume(stream: MediaStream, volume: number): MediaStream;
|
8
|
-
export declare function syncStream(event: MediaEvent, call: ICall, outputDevice: string, volume: number): void;
|
9
|
-
export {};
|
@@ -1,61 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.syncStream = exports.processAudioVolume = 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
|
-
function simplifyCallObject(call) {
|
30
|
-
const simplified = {};
|
31
|
-
CALL_KEYS_TO_INCLUDE.forEach(key => {
|
32
|
-
if (call[key] !== undefined) {
|
33
|
-
simplified[key] = call[key];
|
34
|
-
}
|
35
|
-
});
|
36
|
-
simplified.localHold = call._localHold;
|
37
|
-
return simplified;
|
38
|
-
}
|
39
|
-
exports.simplifyCallObject = simplifyCallObject;
|
40
|
-
function processAudioVolume(stream, volume) {
|
41
|
-
const audioContext = new AudioContext();
|
42
|
-
const audioSource = audioContext.createMediaStreamSource(stream);
|
43
|
-
const audioDestination = audioContext.createMediaStreamDestination();
|
44
|
-
const gainNode = audioContext.createGain();
|
45
|
-
audioSource.connect(gainNode);
|
46
|
-
gainNode.connect(audioDestination);
|
47
|
-
gainNode.gain.value = volume;
|
48
|
-
return audioDestination.stream;
|
49
|
-
}
|
50
|
-
exports.processAudioVolume = processAudioVolume;
|
51
|
-
function syncStream(event, call, outputDevice, volume) {
|
52
|
-
const audio = document.createElement('audio');
|
53
|
-
audio.id = call._id;
|
54
|
-
audio.className = 'audioTag';
|
55
|
-
audio.srcObject = event.stream;
|
56
|
-
audio.setSinkId(outputDevice);
|
57
|
-
audio.volume = volume;
|
58
|
-
audio.play();
|
59
|
-
call.audioTag = audio;
|
60
|
-
}
|
61
|
-
exports.syncStream = syncStream;
|
@@ -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,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,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";
|