sip-lab 1.13.0 → 1.14.0

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/README.md CHANGED
@@ -10,19 +10,22 @@ It permits to:
10
10
  - send and receive DTMF inband/RFC2833/INFO.
11
11
  - play/record wav file on a call
12
12
  - send/receive fax (T.30 only)
13
- - send/receive MRCPv2 messages (experimental)
13
+ - send/receive MRCPv2 messages (TCP only, no TLS)
14
14
 
15
15
  TODO:
16
- - add suport for T.38 fax
17
- - add support for WebRTC
18
16
  - add support for video playing/recording from/to file
17
+ - add support for T.38 fax
18
+ - add support for WebSocket
19
+ - add support for WebRTC
20
+ - add support for SRTP
21
+ - add support for MSRP
19
22
 
20
23
  ### Installation
21
24
 
22
25
  This is a node.js addon and it is known to work on Debian 11, Debian 10, Ubuntu 22.04 and Ubuntu 20.04.
23
26
  It is distributed with prebuild binaries for node.js 15.0.0 and above (but built for Debian 11. For other Debian versions or for Ubuntu a local built of the addon will be executed. Being the case, be patient as the build process will take several minutes to complete).
24
27
 
25
- To install it, first install some dependencies (you might not need them if your are on Debian 11).
28
+ To install it, first install some build dependencies (you might not need them if your are on Debian 11).
26
29
  ```
27
30
  apt install build-essential automake autoconf libtool libspeex-dev libopus-dev libsdl2-dev libavdevice-dev libswscale-dev libv4l-dev libopencore-amrnb-dev libopencore-amrwb-dev libvo-amrwbenc-dev libvo-amrwbenc-dev libboost-dev libtiff-dev libpcap-dev libssl-dev uuid-dev cmake
28
31
  ```
package/binding.gyp CHANGED
@@ -44,7 +44,6 @@
44
44
  '-L ../3rdParty/pjproject/third_party/lib',
45
45
  '-l pjnath-x86_64-unknown-linux-gnu',
46
46
  '-l ilbccodec-x86_64-unknown-linux-gnu',
47
- '-l srtp-x86_64-unknown-linux-gnu',
48
47
  '-l webrtc-x86_64-unknown-linux-gnu',
49
48
  '-l yuv-x86_64-unknown-linux-gnu',
50
49
  '-l speex-x86_64-unknown-linux-gnu',
@@ -87,6 +86,7 @@
87
86
  '-lopencore-amrwb',
88
87
  '-lvo-amrwbenc',
89
88
  '-lspeex',
89
+ '-l srtp-x86_64-unknown-linux-gnu',
90
90
  ],
91
91
  },
92
92
  },
package/build_deps.sh CHANGED
@@ -54,7 +54,8 @@ then
54
54
  #git checkout de3d744c2e1188b59bb907b6ee32ef83740ebc64
55
55
  #git checkout 33a3c9e0a5eb84426edef05a9aa98af17d8011c3 # required for bcg729
56
56
  #git checkout 797088ed133c98492519b7d042b75735f6f9388c # updated as part of #21
57
- git checkout 651df5b50129b7c5a5feec8336dda4468d53d2b0 # updated to latest to see of crash issues improve
57
+ #git checkout 651df5b50129b7c5a5feec8336dda4468d53d2b0 # updated to latest to see of crash issues improve
58
+ git checkout 043926a5846963a2c99378e8daa495230923eaab # update to try to solve ##49 (but issue remains)
58
59
 
59
60
  cat > user.mak <<EOF
60
61
  export CFLAGS += -fPIC -g
@@ -64,7 +65,6 @@ EOF
64
65
  sed -i -r 's/BCG729_LIBS="-lbcg729"/BCG729_LIBS=''/' aconfigure
65
66
  LIBS=`pwd`/../bcg729/src/libbcg729.a ./configure --with-bcg729=`pwd`/../bcg729
66
67
  cat > pjlib/include/pj/config_site.h <<EOF
67
- #define PJMEDIA_HAS_SRTP 0
68
68
  EOF
69
69
  make dep && make clean && make
70
70
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-lab",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -21,18 +21,18 @@
21
21
  "gypfile": true,
22
22
  "homepage": "https://github.com/MayamaTakeshi/sip-lab",
23
23
  "dependencies": {
24
- "@mayama/zeq": "^4.1.17",
24
+ "@mayama/zeq": "^4.7.1",
25
25
  "mrcp": "^1.4.0",
26
26
  "mrcp-matching": "^1.0.0",
27
27
  "node-addon-api": "^5.0.0",
28
28
  "node-gyp": "^9.3.0",
29
29
  "node-gyp-build": "^4.5.0",
30
- "sdp-matching": "^1.2.0",
31
- "sip-matching": "^1.3.34"
30
+ "sip-matching": "^1.5.2"
32
31
  },
33
32
  "devDependencies": {
34
33
  "prebuildify": "^5.0.1",
35
- "prebuildify-cross": "github:MayamaTakeshi/prebuildify-cross#use_existing_images"
34
+ "prebuildify-cross": "github:MayamaTakeshi/prebuildify-cross#use_existing_images",
35
+ "sdp-matching": "^1.3.2"
36
36
  },
37
37
  "files": [
38
38
  "index.js",
Binary file
Binary file
@@ -0,0 +1,246 @@
1
+ var sip = require ('../index.js')
2
+ var Zeq = require('@mayama/zeq')
3
+ var z = new Zeq()
4
+ var m = require('data-matching')
5
+ var sip_msg = require('sip-matching')
6
+ var sdp = require('sdp-matching')
7
+
8
+ async function test() {
9
+ sip.set_log_level(9)
10
+
11
+ //sip.set_log_level(6)
12
+ sip.dtmf_aggregation_on(500)
13
+
14
+ // Let's ignore '100 Trying'
15
+ z.add_event_filter({
16
+ event: 'response',
17
+ msg: sip_msg({
18
+ $rs: '100',
19
+ }),
20
+ })
21
+
22
+ z.trap_events(sip.event_source, 'event', (evt) => {
23
+ var e = evt.args[0]
24
+ return e
25
+ })
26
+
27
+ console.log(sip.start((data) => { console.log(data)} ))
28
+
29
+ t1 = sip.transport.create({address: "127.0.0.1", type: 'udp'})
30
+ t2 = sip.transport.create({address: "127.0.0.1", type: 'udp'})
31
+
32
+ console.log("t1", t1)
33
+ console.log("t2", t2)
34
+
35
+ oc = sip.call.create(t1.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${t2.address}:${t2.port}`})
36
+
37
+ await z.wait([
38
+ {
39
+ event: "incoming_call",
40
+ call_id: m.collect("call_id"),
41
+ },
42
+ ], 1000)
43
+
44
+ ic = {
45
+ id: z.store.call_id,
46
+ sip_call_id: z.store.sip_call_id,
47
+ }
48
+
49
+ sip.call.respond(ic.id, {code: 183, reason: 'Session Progress'})
50
+
51
+ await z.wait([
52
+ {
53
+ event: 'response',
54
+ call_id: oc.id,
55
+ method: 'INVITE',
56
+ msg: sip_msg({
57
+ $rs: '183',
58
+ $rr: 'Session Progress',
59
+ '$(hdrcnt(VIA))': 1,
60
+ $fU: 'alice',
61
+ $fd: 'test.com',
62
+ $tU: 'bob',
63
+ '$hdr(content-type)': 'application/sdp',
64
+ $rb: '!{_}a=sendrecv',
65
+ }),
66
+ },
67
+ {
68
+ event: 'media_update',
69
+ call_id: oc.id,
70
+ status: 'ok',
71
+ media: [
72
+ {
73
+ type: 'audio',
74
+ },
75
+ ],
76
+ },
77
+ {
78
+ event: 'media_update',
79
+ call_id: ic.id,
80
+ status: 'ok',
81
+ media: [
82
+ {
83
+ type: 'audio',
84
+ },
85
+ ],
86
+ },
87
+ ], 1000)
88
+
89
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
90
+ sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
91
+
92
+ await z.wait([
93
+ {
94
+ event: 'dtmf',
95
+ call_id: ic.id,
96
+ digits: '1234',
97
+ mode: 0,
98
+ media_id: 0
99
+ },
100
+ {
101
+ event: 'dtmf',
102
+ call_id: oc.id,
103
+ digits: '4321',
104
+ mode: 1,
105
+ media_id: 0
106
+ },
107
+ ], 2000)
108
+
109
+ await z.sleep(1000)
110
+
111
+ sip.call.respond(ic.id, {code: 200, reason: 'OK'})
112
+
113
+ await z.wait([
114
+ {
115
+ event: 'response',
116
+ call_id: oc.id,
117
+ method: 'INVITE',
118
+ msg: sip_msg({
119
+ $rs: '183',
120
+ $rr: 'Session Progress',
121
+ '$(hdrcnt(VIA))': 1,
122
+ $fU: 'alice',
123
+ $fd: 'test.com',
124
+ $tU: 'bob',
125
+ '$hdr(content-type)': 'application/sdp',
126
+ $rb: '!{_}a=sendrecv',
127
+ }),
128
+ },
129
+ ], 1000)
130
+
131
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
132
+ sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
133
+
134
+ await z.wait([
135
+ {
136
+ event: 'dtmf',
137
+ call_id: ic.id,
138
+ digits: '1234',
139
+ mode: 0,
140
+ media_id: 0
141
+ },
142
+ {
143
+ event: 'dtmf',
144
+ call_id: oc.id,
145
+ digits: '4321',
146
+ mode: 1,
147
+ media_id: 0
148
+ },
149
+ ], 2000)
150
+
151
+ sip.call.reinvite(oc.id)
152
+
153
+ await z.wait([
154
+ {
155
+ event: 'reinvite',
156
+ call_id: ic.id,
157
+ },
158
+ ], 1000)
159
+
160
+ sip.call.respond(ic.id, {code: 200, reason: 'OK'})
161
+
162
+ await z.wait([
163
+ {
164
+ event: 'response',
165
+ call_id: oc.id,
166
+ method: 'INVITE',
167
+ msg: sip_msg({
168
+ $rs: '200',
169
+ }),
170
+ },
171
+ {
172
+ event: 'media_update',
173
+ call_id: ic.id,
174
+ status: 'ok',
175
+ media: [
176
+ {
177
+ type: 'audio',
178
+ },
179
+ ]
180
+ },
181
+ {
182
+ event: 'media_update',
183
+ call_id: oc.id,
184
+ status: 'ok',
185
+ media: [
186
+ {
187
+ type: 'audio',
188
+ },
189
+ ]
190
+ },
191
+ ], 1000)
192
+
193
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
194
+ sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
195
+
196
+ await z.wait([
197
+ {
198
+ event: 'dtmf',
199
+ call_id: ic.id,
200
+ digits: '1234',
201
+ mode: 0,
202
+ media_id: 0
203
+ },
204
+ {
205
+ event: 'dtmf',
206
+ call_id: oc.id,
207
+ digits: '4321',
208
+ mode: 1,
209
+ media_id: 0
210
+ },
211
+ ], 2000)
212
+
213
+ sip.call.terminate(oc.id)
214
+
215
+ await z.wait([
216
+ {
217
+ event: 'call_ended',
218
+ call_id: oc.id,
219
+ },
220
+ {
221
+ event: 'call_ended',
222
+ call_id: ic.id,
223
+ },
224
+ {
225
+ event: 'response',
226
+ call_id: oc.id,
227
+ method: 'BYE',
228
+ msg: sip_msg({
229
+ $rs: '200',
230
+ $rr: 'OK',
231
+ }),
232
+ },
233
+ ], 1000)
234
+
235
+ console.log("Success")
236
+
237
+ sip.stop()
238
+ }
239
+
240
+
241
+ test()
242
+ .catch(e => {
243
+ console.error(e)
244
+ process.exit(1)
245
+ })
246
+
@@ -3,6 +3,7 @@ var Zeq = require('@mayama/zeq')
3
3
  var z = new Zeq()
4
4
  var m = require('data-matching')
5
5
  var sip_msg = require('sip-matching')
6
+ var sdp = require('sdp-matching')
6
7
 
7
8
  async function test() {
8
9
  //sip.set_log_level(6)
@@ -65,15 +66,25 @@ async function test() {
65
66
  $fd: 'test.com',
66
67
  $tU: 'bob',
67
68
  '$hdr(content-type)': 'application/sdp',
68
- $rb: '!{_}a=sendrecv',
69
+ $rb: sdp.matcher({
70
+ media: m.full_match([
71
+ m.partial_match({
72
+ desc: {
73
+ type: 'audio',
74
+ port: m.nonzero,
75
+ protocol: "RTP/AVP",
76
+ },
77
+ }),
78
+ ]),
79
+ })
69
80
  }),
70
81
  },
71
82
  {
72
83
  event: 'media_update',
73
84
  call_id: oc.id,
74
85
  status: 'ok',
75
- media: [
76
- {
86
+ media: m.full_match([
87
+ m.partial_match({
77
88
  type: 'audio',
78
89
  local: {
79
90
  mode: 'sendrecv'
@@ -81,15 +92,15 @@ async function test() {
81
92
  remote: {
82
93
  mode: 'sendrecv'
83
94
  },
84
- }
85
- ],
95
+ }),
96
+ ]),
86
97
  },
87
98
  {
88
99
  event: 'media_update',
89
100
  call_id: ic.id,
90
101
  status: 'ok',
91
- media: [
92
- {
102
+ media: m.full_match([
103
+ m.partial_match({
93
104
  type: 'audio',
94
105
  local: {
95
106
  mode: 'sendrecv'
@@ -97,8 +108,8 @@ async function test() {
97
108
  remote: {
98
109
  mode: 'sendrecv'
99
110
  },
100
- }
101
- ],
111
+ }),
112
+ ]),
102
113
  },
103
114
 
104
115
  ], 1000)