ringcentral-softphone 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/call-session/inbound.cjs +41 -83
- package/dist/call-session/inbound.d.cts +2 -0
- package/dist/call-session/inbound.d.mts +2 -0
- package/dist/call-session/inbound.mjs +51 -0
- package/dist/call-session/index.cjs +212 -273
- package/dist/call-session/index.d.cts +2 -0
- package/dist/call-session/index.d.mts +2 -0
- package/dist/call-session/index.mjs +209 -0
- package/dist/call-session/outbound.cjs +56 -99
- package/dist/call-session/outbound.d.cts +2 -0
- package/dist/call-session/outbound.d.mts +2 -0
- package/dist/call-session/outbound.mjs +57 -0
- package/dist/call-session/streamer.cjs +66 -111
- package/dist/call-session/streamer.d.cts +2 -0
- package/dist/call-session/streamer.d.mts +2 -0
- package/dist/call-session/streamer.mjs +65 -0
- package/dist/chunk-CKQMccvm.cjs +28 -0
- package/dist/codec-Bh7v8J-S.d.mts +18 -0
- package/dist/codec-C-VrtVkq.d.cts +18 -0
- package/dist/codec.cjs +68 -84
- package/dist/codec.d.cts +2 -0
- package/dist/codec.d.mts +2 -0
- package/dist/codec.mjs +68 -0
- package/dist/dtmf-B13Fz2VR.d.mts +10 -0
- package/dist/dtmf-DcQ-5vSG.d.cts +10 -0
- package/dist/dtmf.cjs +37 -60
- package/dist/dtmf.d.cts +2 -0
- package/dist/dtmf.d.mts +2 -0
- package/dist/dtmf.mjs +42 -0
- package/dist/inbound--wGoGqLS.d.mts +103 -0
- package/dist/inbound-DquvTSj1.d.cts +103 -0
- package/dist/index--UjWgLK-.d.mts +8 -0
- package/dist/index-BhN2W8AV.d.mts +8 -0
- package/dist/index-CEgs-Dz2.d.cts +1 -0
- package/dist/index-Cf2Cev52.d.cts +8 -0
- package/dist/index-XMDop59x.d.cts +8 -0
- package/dist/index-q_LXL61M.d.mts +1 -0
- package/dist/index.cjs +166 -250
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +172 -0
- package/dist/request-B_auLSJn.d.cts +10 -0
- package/dist/request-pBe7_mYv.d.mts +10 -0
- package/dist/response-LRRpY8lX.d.mts +9 -0
- package/dist/response-ReKvb5x9.d.cts +9 -0
- package/dist/sip-message/inbound/index.cjs +16 -50
- package/dist/sip-message/inbound/index.d.cts +2 -0
- package/dist/sip-message/inbound/index.d.mts +2 -0
- package/dist/sip-message/inbound/index.mjs +17 -0
- package/dist/sip-message/index.cjs +11 -49
- package/dist/sip-message/index.d.cts +6 -0
- package/dist/sip-message/index.d.mts +6 -0
- package/dist/sip-message/index.mjs +6 -0
- package/dist/sip-message/outbound/index.cjs +10 -40
- package/dist/sip-message/outbound/index.d.cts +2 -0
- package/dist/sip-message/outbound/index.d.mts +2 -0
- package/dist/sip-message/outbound/index.mjs +11 -0
- package/dist/sip-message/outbound/request.cjs +20 -61
- package/dist/sip-message/outbound/request.d.cts +2 -0
- package/dist/sip-message/outbound/request.d.mts +2 -0
- package/dist/sip-message/outbound/request.mjs +21 -0
- package/dist/sip-message/outbound/response.cjs +25 -54
- package/dist/sip-message/outbound/response.d.cts +2 -0
- package/dist/sip-message/outbound/response.d.mts +2 -0
- package/dist/sip-message/outbound/response.mjs +26 -0
- package/dist/sip-message/response-codes.cjs +80 -100
- package/dist/sip-message/response-codes.d.cts +5 -0
- package/dist/sip-message/response-codes.d.mts +6 -0
- package/dist/sip-message/response-codes.mjs +82 -0
- package/dist/sip-message/sip-message.cjs +25 -52
- package/dist/sip-message/sip-message.d.cts +2 -0
- package/dist/sip-message/sip-message.d.mts +2 -0
- package/dist/sip-message/sip-message.mjs +26 -0
- package/dist/sip-message-B2D5MPBI.d.cts +13 -0
- package/dist/sip-message-PaPho4qU.d.mts +13 -0
- package/dist/types-DOQ9wmX6.d.mts +12 -0
- package/dist/types-DZxCsbZE.d.cts +12 -0
- package/dist/types.cjs +0 -15
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/dist/utils.cjs +27 -73
- package/dist/utils.d.cts +12 -0
- package/dist/utils.d.mts +12 -0
- package/dist/utils.mjs +25 -0
- package/package.json +14 -14
- package/dist/call-session/inbound.d.ts +0 -8
- package/dist/call-session/inbound.js +0 -64
- package/dist/call-session/index.d.ts +0 -46
- package/dist/call-session/index.js +0 -248
- package/dist/call-session/outbound.d.ts +0 -11
- package/dist/call-session/outbound.js +0 -71
- package/dist/call-session/streamer.d.ts +0 -17
- package/dist/call-session/streamer.js +0 -83
- package/dist/codec.d.ts +0 -15
- package/dist/codec.js +0 -66
- package/dist/dtmf.d.ts +0 -7
- package/dist/dtmf.js +0 -47
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -242
- package/dist/sip-message/inbound/index.d.ts +0 -5
- package/dist/sip-message/inbound/index.js +0 -22
- package/dist/sip-message/index.d.ts +0 -5
- package/dist/sip-message/index.js +0 -12
- package/dist/sip-message/outbound/index.d.ts +0 -5
- package/dist/sip-message/outbound/index.js +0 -12
- package/dist/sip-message/outbound/request.d.ts +0 -7
- package/dist/sip-message/outbound/request.js +0 -33
- package/dist/sip-message/outbound/response.d.ts +0 -6
- package/dist/sip-message/outbound/response.js +0 -26
- package/dist/sip-message/response-codes.d.ts +0 -4
- package/dist/sip-message/response-codes.js +0 -83
- package/dist/sip-message/sip-message.d.ts +0 -11
- package/dist/sip-message/sip-message.js +0 -34
- package/dist/types.d.ts +0 -9
- package/dist/types.js +0 -0
- package/dist/utils.d.ts +0 -8
- package/dist/utils.js +0 -41
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import EventEmitter from "node:events";
|
|
3
|
+
import { RtpHeader, RtpPacket } from "werift-rtp";
|
|
4
|
+
//#region src/call-session/streamer.ts
|
|
5
|
+
var Streamer = class extends EventEmitter {
|
|
6
|
+
paused = false;
|
|
7
|
+
callSession;
|
|
8
|
+
buffer;
|
|
9
|
+
originalBuffer;
|
|
10
|
+
constructor(callSession, buffer) {
|
|
11
|
+
super();
|
|
12
|
+
this.callSession = callSession;
|
|
13
|
+
this.buffer = buffer;
|
|
14
|
+
this.originalBuffer = buffer;
|
|
15
|
+
}
|
|
16
|
+
start() {
|
|
17
|
+
this.buffer = this.originalBuffer;
|
|
18
|
+
this.paused = false;
|
|
19
|
+
this.sendPacket();
|
|
20
|
+
}
|
|
21
|
+
stop() {
|
|
22
|
+
this.buffer = Buffer.alloc(0);
|
|
23
|
+
}
|
|
24
|
+
pause() {
|
|
25
|
+
this.paused = true;
|
|
26
|
+
}
|
|
27
|
+
resume() {
|
|
28
|
+
this.paused = false;
|
|
29
|
+
this.sendPacket();
|
|
30
|
+
}
|
|
31
|
+
get finished() {
|
|
32
|
+
return this.callSession.disposed || this.buffer.length < this.callSession.softphone.codec.packetSize;
|
|
33
|
+
}
|
|
34
|
+
sendPacket() {
|
|
35
|
+
if (!this.paused && !this.finished) {
|
|
36
|
+
const temp = this.callSession.encoder.encode(this.buffer.subarray(0, this.callSession.softphone.codec.packetSize));
|
|
37
|
+
const rtpPacket = new RtpPacket(new RtpHeader({
|
|
38
|
+
version: 2,
|
|
39
|
+
padding: false,
|
|
40
|
+
paddingSize: 0,
|
|
41
|
+
extension: false,
|
|
42
|
+
marker: false,
|
|
43
|
+
payloadOffset: 12,
|
|
44
|
+
payloadType: this.callSession.softphone.codec.id,
|
|
45
|
+
sequenceNumber: this.callSession.sequenceNumber,
|
|
46
|
+
timestamp: this.callSession.timestamp,
|
|
47
|
+
ssrc: this.callSession.ssrc,
|
|
48
|
+
csrcLength: 0,
|
|
49
|
+
csrc: [],
|
|
50
|
+
extensionProfile: 48862,
|
|
51
|
+
extensionLength: void 0,
|
|
52
|
+
extensions: []
|
|
53
|
+
}), temp);
|
|
54
|
+
this.callSession.send(this.callSession.srtpSession.encrypt(rtpPacket.payload, rtpPacket.header));
|
|
55
|
+
this.callSession.sequenceNumber += 1;
|
|
56
|
+
if (this.callSession.sequenceNumber > 65535) this.callSession.sequenceNumber = 0;
|
|
57
|
+
this.callSession.timestamp += this.callSession.softphone.codec.timestampInterval;
|
|
58
|
+
this.buffer = this.buffer.subarray(this.callSession.softphone.codec.packetSize);
|
|
59
|
+
if (this.finished) this.emit("finished");
|
|
60
|
+
else setTimeout(() => this.sendPacket(), 20);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { Streamer as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
Object.defineProperty(exports, "__toESM", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return __toESM;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
|
|
3
|
+
//#region src/codec.d.ts
|
|
4
|
+
declare class Codec {
|
|
5
|
+
id: number;
|
|
6
|
+
name: "OPUS/16000" | "OPUS/48000/2" | "PCMU/8000";
|
|
7
|
+
packetSize: number;
|
|
8
|
+
timestampInterval: number;
|
|
9
|
+
createEncoder: () => {
|
|
10
|
+
encode: (pcm: Buffer) => Buffer;
|
|
11
|
+
};
|
|
12
|
+
createDecoder: () => {
|
|
13
|
+
decode: (audio: Buffer) => Buffer;
|
|
14
|
+
};
|
|
15
|
+
constructor(name: "OPUS/16000" | "OPUS/48000/2" | "PCMU/8000");
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { Codec as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
|
|
3
|
+
//#region src/codec.d.ts
|
|
4
|
+
declare class Codec {
|
|
5
|
+
id: number;
|
|
6
|
+
name: "OPUS/16000" | "OPUS/48000/2" | "PCMU/8000";
|
|
7
|
+
packetSize: number;
|
|
8
|
+
timestampInterval: number;
|
|
9
|
+
createEncoder: () => {
|
|
10
|
+
encode: (pcm: Buffer) => Buffer;
|
|
11
|
+
};
|
|
12
|
+
createDecoder: () => {
|
|
13
|
+
decode: (audio: Buffer) => Buffer;
|
|
14
|
+
};
|
|
15
|
+
constructor(name: "OPUS/16000" | "OPUS/48000/2" | "PCMU/8000");
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { Codec as t };
|
package/dist/codec.cjs
CHANGED
|
@@ -1,85 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
require("./chunk-CKQMccvm.cjs");
|
|
2
|
+
let node_buffer = require("node:buffer");
|
|
3
|
+
let _evan_opus = require("@evan/opus");
|
|
4
|
+
//#region src/codec.ts
|
|
5
|
+
var Codec = class {
|
|
6
|
+
id;
|
|
7
|
+
name;
|
|
8
|
+
packetSize;
|
|
9
|
+
timestampInterval;
|
|
10
|
+
createEncoder;
|
|
11
|
+
createDecoder;
|
|
12
|
+
constructor(name) {
|
|
13
|
+
this.name = name;
|
|
14
|
+
switch (name) {
|
|
15
|
+
case "OPUS/16000":
|
|
16
|
+
this.createEncoder = () => {
|
|
17
|
+
const encoder = new _evan_opus.Encoder({
|
|
18
|
+
channels: 1,
|
|
19
|
+
sample_rate: 16e3
|
|
20
|
+
});
|
|
21
|
+
return { encode: (pcm) => node_buffer.Buffer.from(encoder.encode(pcm)) };
|
|
22
|
+
};
|
|
23
|
+
this.createDecoder = () => {
|
|
24
|
+
const decoder = new _evan_opus.Decoder({
|
|
25
|
+
channels: 1,
|
|
26
|
+
sample_rate: 16e3
|
|
27
|
+
});
|
|
28
|
+
return { decode: (opus) => node_buffer.Buffer.from(decoder.decode(opus)) };
|
|
29
|
+
};
|
|
30
|
+
this.id = 109;
|
|
31
|
+
this.packetSize = 640;
|
|
32
|
+
this.timestampInterval = 320;
|
|
33
|
+
break;
|
|
34
|
+
case "OPUS/48000/2":
|
|
35
|
+
this.createEncoder = () => {
|
|
36
|
+
const encoder = new _evan_opus.Encoder({
|
|
37
|
+
channels: 2,
|
|
38
|
+
sample_rate: 48e3
|
|
39
|
+
});
|
|
40
|
+
return { encode: (pcm) => node_buffer.Buffer.from(encoder.encode(pcm)) };
|
|
41
|
+
};
|
|
42
|
+
this.createDecoder = () => {
|
|
43
|
+
const decoder = new _evan_opus.Decoder({
|
|
44
|
+
channels: 2,
|
|
45
|
+
sample_rate: 48e3
|
|
46
|
+
});
|
|
47
|
+
return { decode: (opus) => node_buffer.Buffer.from(decoder.decode(opus)) };
|
|
48
|
+
};
|
|
49
|
+
this.id = 111;
|
|
50
|
+
this.packetSize = 3840;
|
|
51
|
+
this.timestampInterval = 960;
|
|
52
|
+
break;
|
|
53
|
+
case "PCMU/8000":
|
|
54
|
+
this.createEncoder = () => {
|
|
55
|
+
return { encode: (pcm) => pcm };
|
|
56
|
+
};
|
|
57
|
+
this.createDecoder = () => {
|
|
58
|
+
return { decode: (audio) => audio };
|
|
59
|
+
};
|
|
60
|
+
this.id = 0;
|
|
61
|
+
this.packetSize = 160;
|
|
62
|
+
this.timestampInterval = 160;
|
|
63
|
+
break;
|
|
64
|
+
default: throw new Error(`unsupported codec: ${name}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
8
67
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var codec_exports = {};
|
|
19
|
-
__export(codec_exports, {
|
|
20
|
-
default: () => codec_default
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(codec_exports);
|
|
23
|
-
var import_node_buffer = require("node:buffer");
|
|
24
|
-
var import_opus = require("@evan/opus");
|
|
25
|
-
class Codec {
|
|
26
|
-
id;
|
|
27
|
-
name;
|
|
28
|
-
packetSize;
|
|
29
|
-
timestampInterval;
|
|
30
|
-
createEncoder;
|
|
31
|
-
createDecoder;
|
|
32
|
-
constructor(name) {
|
|
33
|
-
this.name = name;
|
|
34
|
-
switch (name) {
|
|
35
|
-
case "OPUS/16000": {
|
|
36
|
-
this.createEncoder = () => {
|
|
37
|
-
const encoder = new import_opus.Encoder({ channels: 1, sample_rate: 16e3 });
|
|
38
|
-
return { encode: (pcm) => import_node_buffer.Buffer.from(encoder.encode(pcm)) };
|
|
39
|
-
};
|
|
40
|
-
this.createDecoder = () => {
|
|
41
|
-
const decoder = new import_opus.Decoder({ channels: 1, sample_rate: 16e3 });
|
|
42
|
-
return {
|
|
43
|
-
decode: (opus) => import_node_buffer.Buffer.from(decoder.decode(opus))
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
this.id = 109;
|
|
47
|
-
this.packetSize = 640;
|
|
48
|
-
this.timestampInterval = 320;
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
case "OPUS/48000/2": {
|
|
52
|
-
this.createEncoder = () => {
|
|
53
|
-
const encoder = new import_opus.Encoder({ channels: 2, sample_rate: 48e3 });
|
|
54
|
-
return { encode: (pcm) => import_node_buffer.Buffer.from(encoder.encode(pcm)) };
|
|
55
|
-
};
|
|
56
|
-
this.createDecoder = () => {
|
|
57
|
-
const decoder = new import_opus.Decoder({ channels: 2, sample_rate: 48e3 });
|
|
58
|
-
return {
|
|
59
|
-
decode: (opus) => import_node_buffer.Buffer.from(decoder.decode(opus))
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
this.id = 111;
|
|
63
|
-
this.packetSize = 3840;
|
|
64
|
-
this.timestampInterval = 960;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
case "PCMU/8000": {
|
|
68
|
-
this.createEncoder = () => {
|
|
69
|
-
return { encode: (pcm) => pcm };
|
|
70
|
-
};
|
|
71
|
-
this.createDecoder = () => {
|
|
72
|
-
return { decode: (audio) => audio };
|
|
73
|
-
};
|
|
74
|
-
this.id = 0;
|
|
75
|
-
this.packetSize = 160;
|
|
76
|
-
this.timestampInterval = 160;
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
default: {
|
|
80
|
-
throw new Error(`unsupported codec: ${name}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
var codec_default = Codec;
|
|
68
|
+
//#endregion
|
|
69
|
+
module.exports = Codec;
|
package/dist/codec.d.cts
ADDED
package/dist/codec.d.mts
ADDED
package/dist/codec.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { Decoder, Encoder } from "@evan/opus";
|
|
3
|
+
//#region src/codec.ts
|
|
4
|
+
var Codec = class {
|
|
5
|
+
id;
|
|
6
|
+
name;
|
|
7
|
+
packetSize;
|
|
8
|
+
timestampInterval;
|
|
9
|
+
createEncoder;
|
|
10
|
+
createDecoder;
|
|
11
|
+
constructor(name) {
|
|
12
|
+
this.name = name;
|
|
13
|
+
switch (name) {
|
|
14
|
+
case "OPUS/16000":
|
|
15
|
+
this.createEncoder = () => {
|
|
16
|
+
const encoder = new Encoder({
|
|
17
|
+
channels: 1,
|
|
18
|
+
sample_rate: 16e3
|
|
19
|
+
});
|
|
20
|
+
return { encode: (pcm) => Buffer.from(encoder.encode(pcm)) };
|
|
21
|
+
};
|
|
22
|
+
this.createDecoder = () => {
|
|
23
|
+
const decoder = new Decoder({
|
|
24
|
+
channels: 1,
|
|
25
|
+
sample_rate: 16e3
|
|
26
|
+
});
|
|
27
|
+
return { decode: (opus) => Buffer.from(decoder.decode(opus)) };
|
|
28
|
+
};
|
|
29
|
+
this.id = 109;
|
|
30
|
+
this.packetSize = 640;
|
|
31
|
+
this.timestampInterval = 320;
|
|
32
|
+
break;
|
|
33
|
+
case "OPUS/48000/2":
|
|
34
|
+
this.createEncoder = () => {
|
|
35
|
+
const encoder = new Encoder({
|
|
36
|
+
channels: 2,
|
|
37
|
+
sample_rate: 48e3
|
|
38
|
+
});
|
|
39
|
+
return { encode: (pcm) => Buffer.from(encoder.encode(pcm)) };
|
|
40
|
+
};
|
|
41
|
+
this.createDecoder = () => {
|
|
42
|
+
const decoder = new Decoder({
|
|
43
|
+
channels: 2,
|
|
44
|
+
sample_rate: 48e3
|
|
45
|
+
});
|
|
46
|
+
return { decode: (opus) => Buffer.from(decoder.decode(opus)) };
|
|
47
|
+
};
|
|
48
|
+
this.id = 111;
|
|
49
|
+
this.packetSize = 3840;
|
|
50
|
+
this.timestampInterval = 960;
|
|
51
|
+
break;
|
|
52
|
+
case "PCMU/8000":
|
|
53
|
+
this.createEncoder = () => {
|
|
54
|
+
return { encode: (pcm) => pcm };
|
|
55
|
+
};
|
|
56
|
+
this.createDecoder = () => {
|
|
57
|
+
return { decode: (audio) => audio };
|
|
58
|
+
};
|
|
59
|
+
this.id = 0;
|
|
60
|
+
this.packetSize = 160;
|
|
61
|
+
this.timestampInterval = 160;
|
|
62
|
+
break;
|
|
63
|
+
default: throw new Error(`unsupported codec: ${name}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { Codec as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
|
|
3
|
+
//#region src/dtmf.d.ts
|
|
4
|
+
declare const DTMF: {
|
|
5
|
+
phoneChars: readonly ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "#"];
|
|
6
|
+
charToPayloads(char: string): Buffer<ArrayBuffer>[];
|
|
7
|
+
payloadToChar(payload: Buffer): "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "*" | "#";
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { DTMF as t };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
|
|
3
|
+
//#region src/dtmf.d.ts
|
|
4
|
+
declare const DTMF: {
|
|
5
|
+
phoneChars: readonly ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "#"];
|
|
6
|
+
charToPayloads(char: string): Buffer<ArrayBuffer>[];
|
|
7
|
+
payloadToChar(payload: Buffer): "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "*" | "#";
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { DTMF as t };
|
package/dist/dtmf.cjs
CHANGED
|
@@ -1,66 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var dtmf_exports = {};
|
|
19
|
-
__export(dtmf_exports, {
|
|
20
|
-
default: () => dtmf_default
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(dtmf_exports);
|
|
23
|
-
var import_node_buffer = require("node:buffer");
|
|
1
|
+
require("./chunk-CKQMccvm.cjs");
|
|
2
|
+
let node_buffer = require("node:buffer");
|
|
3
|
+
//#region src/dtmf.ts
|
|
24
4
|
const phoneChars = [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
5
|
+
"0",
|
|
6
|
+
"1",
|
|
7
|
+
"2",
|
|
8
|
+
"3",
|
|
9
|
+
"4",
|
|
10
|
+
"5",
|
|
11
|
+
"6",
|
|
12
|
+
"7",
|
|
13
|
+
"8",
|
|
14
|
+
"9",
|
|
15
|
+
"*",
|
|
16
|
+
"#"
|
|
37
17
|
];
|
|
38
18
|
const payloads = [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
19
|
+
393216,
|
|
20
|
+
393376,
|
|
21
|
+
393536,
|
|
22
|
+
8782624,
|
|
23
|
+
8782624,
|
|
24
|
+
8782624
|
|
45
25
|
];
|
|
46
26
|
const DTMF = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const intBE = payload.readIntBE(0, 4);
|
|
62
|
-
const index = (intBE - 393216) / 16777216;
|
|
63
|
-
return phoneChars[index];
|
|
64
|
-
}
|
|
27
|
+
phoneChars,
|
|
28
|
+
charToPayloads(char) {
|
|
29
|
+
const index = phoneChars.indexOf(char[0]);
|
|
30
|
+
if (index === -1) throw new Error("invalid phone char");
|
|
31
|
+
return payloads.map((payload) => {
|
|
32
|
+
const temp = payload + index * 16777216;
|
|
33
|
+
const buffer = node_buffer.Buffer.alloc(4);
|
|
34
|
+
buffer.writeIntBE(temp, 0, 4);
|
|
35
|
+
return buffer;
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
payloadToChar(payload) {
|
|
39
|
+
return phoneChars[(payload.readIntBE(0, 4) - 393216) / 16777216];
|
|
40
|
+
}
|
|
65
41
|
};
|
|
66
|
-
|
|
42
|
+
//#endregion
|
|
43
|
+
module.exports = DTMF;
|
package/dist/dtmf.d.cts
ADDED
package/dist/dtmf.d.mts
ADDED
package/dist/dtmf.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
//#region src/dtmf.ts
|
|
3
|
+
const phoneChars = [
|
|
4
|
+
"0",
|
|
5
|
+
"1",
|
|
6
|
+
"2",
|
|
7
|
+
"3",
|
|
8
|
+
"4",
|
|
9
|
+
"5",
|
|
10
|
+
"6",
|
|
11
|
+
"7",
|
|
12
|
+
"8",
|
|
13
|
+
"9",
|
|
14
|
+
"*",
|
|
15
|
+
"#"
|
|
16
|
+
];
|
|
17
|
+
const payloads = [
|
|
18
|
+
393216,
|
|
19
|
+
393376,
|
|
20
|
+
393536,
|
|
21
|
+
8782624,
|
|
22
|
+
8782624,
|
|
23
|
+
8782624
|
|
24
|
+
];
|
|
25
|
+
const DTMF = {
|
|
26
|
+
phoneChars,
|
|
27
|
+
charToPayloads(char) {
|
|
28
|
+
const index = phoneChars.indexOf(char[0]);
|
|
29
|
+
if (index === -1) throw new Error("invalid phone char");
|
|
30
|
+
return payloads.map((payload) => {
|
|
31
|
+
const temp = payload + index * 16777216;
|
|
32
|
+
const buffer = Buffer.alloc(4);
|
|
33
|
+
buffer.writeIntBE(temp, 0, 4);
|
|
34
|
+
return buffer;
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
payloadToChar(payload) {
|
|
38
|
+
return phoneChars[(payload.readIntBE(0, 4) - 393216) / 16777216];
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { DTMF as default };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { t as InboundMessage } from "./index-BhN2W8AV.mjs";
|
|
2
|
+
import { t as OutboundMessage } from "./index--UjWgLK-.mjs";
|
|
3
|
+
import { t as DTMF } from "./dtmf-B13Fz2VR.mjs";
|
|
4
|
+
import { t as Codec } from "./codec-Bh7v8J-S.mjs";
|
|
5
|
+
import { t as SoftPhoneOptions } from "./types-DOQ9wmX6.mjs";
|
|
6
|
+
import { Buffer } from "node:buffer";
|
|
7
|
+
import EventEmitter from "node:events";
|
|
8
|
+
import { TLSSocket } from "node:tls";
|
|
9
|
+
import dgram from "node:dgram";
|
|
10
|
+
import { RtpPacket, SrtpSession } from "werift-rtp";
|
|
11
|
+
|
|
12
|
+
//#region src/call-session/streamer.d.ts
|
|
13
|
+
declare class Streamer extends EventEmitter {
|
|
14
|
+
paused: boolean;
|
|
15
|
+
private callSession;
|
|
16
|
+
private buffer;
|
|
17
|
+
private originalBuffer;
|
|
18
|
+
constructor(callSession: CallSession, buffer: Buffer);
|
|
19
|
+
start(): void;
|
|
20
|
+
stop(): void;
|
|
21
|
+
pause(): void;
|
|
22
|
+
resume(): void;
|
|
23
|
+
get finished(): boolean;
|
|
24
|
+
private sendPacket;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/call-session/index.d.ts
|
|
28
|
+
type DtmfChar = (typeof DTMF.phoneChars)[number];
|
|
29
|
+
declare abstract class CallSession extends EventEmitter {
|
|
30
|
+
softphone: Softphone;
|
|
31
|
+
sipMessage: InboundMessage;
|
|
32
|
+
socket: dgram.Socket;
|
|
33
|
+
localPeer: string;
|
|
34
|
+
remotePeer: string;
|
|
35
|
+
remoteIP: string;
|
|
36
|
+
remotePort: number;
|
|
37
|
+
disposed: boolean;
|
|
38
|
+
srtpSession: SrtpSession;
|
|
39
|
+
encoder: {
|
|
40
|
+
encode: (pcm: Buffer) => Buffer;
|
|
41
|
+
};
|
|
42
|
+
decoder: {
|
|
43
|
+
decode: (audio: Buffer) => Buffer;
|
|
44
|
+
};
|
|
45
|
+
sdp: string;
|
|
46
|
+
ssrc: number;
|
|
47
|
+
sequenceNumber: number;
|
|
48
|
+
timestamp: number;
|
|
49
|
+
constructor(softphone: Softphone, sipMessage: InboundMessage);
|
|
50
|
+
set remoteKey(key: string);
|
|
51
|
+
get callId(): string | undefined;
|
|
52
|
+
send(data: string | Buffer): void;
|
|
53
|
+
hangup(): Promise<void>;
|
|
54
|
+
sendDTMF(char: DtmfChar): void;
|
|
55
|
+
sendDTMFs(s: string, delay?: number): Promise<void>;
|
|
56
|
+
streamAudio(input: Buffer): Streamer;
|
|
57
|
+
sendPacket(rtpPacket: RtpPacket): void;
|
|
58
|
+
protected startLocalServices(): void;
|
|
59
|
+
protected dispose(): void;
|
|
60
|
+
transfer(transferTo: string): Promise<void>;
|
|
61
|
+
toggleReceive(toReceive: boolean): Promise<void>;
|
|
62
|
+
hold(): Promise<void>;
|
|
63
|
+
unhold(): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/call-session/outbound.d.ts
|
|
67
|
+
declare class OutboundCallSession extends CallSession {
|
|
68
|
+
constructor(softphone: Softphone, answerMessage: InboundMessage);
|
|
69
|
+
init(): void;
|
|
70
|
+
cancel(): Promise<void>;
|
|
71
|
+
get sessionId(): string;
|
|
72
|
+
get partyId(): string;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/index.d.ts
|
|
76
|
+
declare class Softphone extends EventEmitter {
|
|
77
|
+
sipInfo: SoftPhoneOptions;
|
|
78
|
+
client: TLSSocket;
|
|
79
|
+
codec: Codec;
|
|
80
|
+
fakeDomain: string;
|
|
81
|
+
fakeEmail: string;
|
|
82
|
+
private intervalHandle?;
|
|
83
|
+
private connected;
|
|
84
|
+
constructor(sipInfo: SoftPhoneOptions);
|
|
85
|
+
private instanceId;
|
|
86
|
+
private registerCallId;
|
|
87
|
+
register(): Promise<void>;
|
|
88
|
+
enableDebugMode(): void;
|
|
89
|
+
revoke(): void;
|
|
90
|
+
send(message: OutboundMessage, waitForReply?: true): Promise<InboundMessage>;
|
|
91
|
+
send(message: OutboundMessage, waitForReply?: false): Promise<undefined>;
|
|
92
|
+
answer(inviteMessage: InboundMessage): Promise<InboundCallSession>;
|
|
93
|
+
decline(inviteMessage: InboundMessage): Promise<void>;
|
|
94
|
+
call(callee: string): Promise<OutboundCallSession>;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/call-session/inbound.d.ts
|
|
98
|
+
declare class InboundCallSession extends CallSession {
|
|
99
|
+
constructor(softphone: Softphone, inviteMessage: InboundMessage);
|
|
100
|
+
answer(): Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { Streamer as a, CallSession as i, Softphone as n, OutboundCallSession as r, InboundCallSession as t };
|