sip-lab 1.16.0 → 1.17.1

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/build_deps.sh CHANGED
@@ -65,6 +65,9 @@ EOF
65
65
  sed -i -r 's/BCG729_LIBS="-lbcg729"/BCG729_LIBS=''/' aconfigure
66
66
  LIBS=`pwd`/../bcg729/src/libbcg729.a ./configure --with-bcg729=`pwd`/../bcg729
67
67
  cat > pjlib/include/pj/config_site.h <<EOF
68
+ #define PJSUA_MAX_ACC (20000)
69
+ #define PJ_IOQUEUE_MAX_HANDLES (1024)
70
+ #define PJSUA_MAX_CALLS (20000)
68
71
  EOF
69
72
  make dep && make clean && make
70
73
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-lab",
3
- "version": "1.16.0",
3
+ "version": "1.17.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -21,7 +21,7 @@
21
21
  "gypfile": true,
22
22
  "homepage": "https://github.com/MayamaTakeshi/sip-lab",
23
23
  "dependencies": {
24
- "@mayama/zeq": "^4.7.1",
24
+ "@mayama/zeq": "^4.12.0",
25
25
  "mrcp": "^1.4.0",
26
26
  "mrcp-matching": "^1.0.0",
27
27
  "node-addon-api": "^5.0.0",
Binary file
@@ -0,0 +1,152 @@
1
+ // This test creates 256 caller UDP SIP endpoints, 256 callee UDP SIP endpoines and makes one call between them, test dtmf and disconeects.
2
+
3
+ const sip = require ('../index.js')
4
+ const Zeq = require('@mayama/zeq')
5
+ const m = require('data-matching')
6
+ const sip_msg = require('sip-matching')
7
+ const _ = require('lodash')
8
+
9
+ const NUMBER_OF_CALLS = 100
10
+
11
+ var z = new Zeq()
12
+
13
+ sip.dtmf_aggregation_on(500)
14
+
15
+ z.add_event_filter({
16
+ event: 'response',
17
+ msg: sip_msg({
18
+ $rs: '100',
19
+ }),
20
+ })
21
+
22
+ async function test() {
23
+ z.trap_events(sip.event_source, 'event', (evt) => {
24
+ var e = evt.args[0]
25
+ return e
26
+ })
27
+
28
+ console.log(sip.start((data) => { console.log(data)} ))
29
+
30
+ const caller_ts = []
31
+ const callee_ts = []
32
+
33
+ const ocs = []
34
+
35
+ for(var i=0 ; i<NUMBER_OF_CALLS ; i++) {
36
+ const caller_t = sip.transport.create({address: "127.0.0.1"})
37
+ caller_ts.push(caller_t)
38
+ const callee_t = sip.transport.create({address: "127.0.0.1"})
39
+ callee_ts.push(callee_t)
40
+
41
+ // make the call
42
+ const oc = sip.call.create(caller_t.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${callee_t.address}:${callee_t.port}`})
43
+ ocs.push(oc)
44
+ }
45
+
46
+ // Here we will wait for the calls to arrive
47
+ await z.wait(_.chain(callee_ts).map(t => ({
48
+ event: "incoming_call",
49
+ call_id: m.push("ic_ids"),
50
+ transport_id: t.id,
51
+ })).value(), 20000)
52
+
53
+ // Now we answer the calls
54
+ z.store.ic_ids.forEach(ic_id => {
55
+ sip.call.respond(ic_id, {code: 200, reason: 'OK'})
56
+ })
57
+
58
+ // Then we wait for the '200 OK' at the caller side
59
+ var events = _.chain(ocs).map(oc => ({
60
+ event: 'response',
61
+ call_id: oc.id,
62
+ method: 'INVITE',
63
+ msg: sip_msg({
64
+ $rs: '200',
65
+ $rr: 'OK',
66
+ '$(hdrcnt(VIA))': 1,
67
+ $fU: 'alice',
68
+ $fd: 'test.com',
69
+ $tU: 'bob',
70
+ '$hdr(content-type)': 'application/sdp',
71
+ $rb: '!{_}a=sendrecv',
72
+ }),
73
+ })).value()
74
+
75
+ events = events.concat(_.chain(ocs).map(oc => ({
76
+ event: 'media_update',
77
+ call_id: oc.id,
78
+ status: 'ok',
79
+ })).value())
80
+
81
+ events = events.concat(_.chain(z.store.ic_ids).map(ic_id => ({
82
+ event: 'media_update',
83
+ call_id: ic_id,
84
+ status: 'ok',
85
+ })).value())
86
+
87
+ await z.wait(events, 20000)
88
+
89
+ ocs.forEach(oc => {
90
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
91
+ })
92
+
93
+ await z.wait(_.chain(z.store.ic_ids).map(ic_id => ({
94
+ event: 'dtmf',
95
+ call_id: ic_id,
96
+ digits: '1234',
97
+ mode: 0,
98
+ media_id: 0,
99
+ })).value(), 20000)
100
+
101
+ z.store.ic_ids.forEach(ic_id => {
102
+ sip.call.send_dtmf(ic_id, {digits: '4321', mode: 1})
103
+ })
104
+
105
+ await z.wait(_.chain(ocs).map(oc => ({
106
+ event: 'dtmf',
107
+ call_id: oc.id,
108
+ digits: '4321',
109
+ mode: 1,
110
+ media_id: 0,
111
+ })).value(), 20000)
112
+
113
+ // now we terminate the calls
114
+ ocs.forEach(oc => {
115
+ sip.call.terminate(oc.id)
116
+ })
117
+
118
+ // and wait for termination events
119
+ events = _.chain(ocs).map(oc => ({
120
+ event: 'response',
121
+ call_id: oc.id,
122
+ method: 'BYE',
123
+ msg: sip_msg({
124
+ $rs: '200',
125
+ $rr: 'OK',
126
+ }),
127
+ })).value()
128
+
129
+ events = events.concat(_.chain(ocs).map(oc => ({
130
+ event: 'call_ended',
131
+ call_id: oc.id,
132
+ })).value())
133
+
134
+ events = events.concat(_.chain(z.store.ic_ids).map(ic_id => ({
135
+ event: 'call_ended',
136
+ call_id: ic_id,
137
+ })).value())
138
+
139
+ await z.wait(events, 20000)
140
+
141
+ console.log("Success")
142
+
143
+ sip.stop()
144
+ }
145
+
146
+
147
+ test()
148
+ .catch(e => {
149
+ console.error(e)
150
+ process.exit(1)
151
+ })
152
+
@@ -0,0 +1,152 @@
1
+ // This test creates 256 caller UDP SIP endpoints, 256 callee UDP SIP endpoines and makes one call between them, test dtmf and disconeects.
2
+
3
+ const sip = require ('../index.js')
4
+ const Zeq = require('@mayama/zeq')
5
+ const m = require('data-matching')
6
+ const sip_msg = require('sip-matching')
7
+ const _ = require('lodash')
8
+
9
+ const NUMBER_OF_CALLS = 16
10
+
11
+ var z = new Zeq()
12
+
13
+ sip.dtmf_aggregation_on(500)
14
+
15
+ z.add_event_filter({
16
+ event: 'response',
17
+ msg: sip_msg({
18
+ $rs: '100',
19
+ }),
20
+ })
21
+
22
+ async function test() {
23
+ z.trap_events(sip.event_source, 'event', (evt) => {
24
+ var e = evt.args[0]
25
+ return e
26
+ })
27
+
28
+ console.log(sip.start((data) => { console.log(data)} ))
29
+
30
+ const caller_ts = []
31
+ const callee_ts = []
32
+
33
+ const ocs = []
34
+
35
+ for(var i=0 ; i<NUMBER_OF_CALLS ; i++) {
36
+ const caller_t = sip.transport.create({address: "127.0.0.1"})
37
+ caller_ts.push(caller_t)
38
+ const callee_t = sip.transport.create({address: "127.0.0.1"})
39
+ callee_ts.push(callee_t)
40
+
41
+ // make the call
42
+ const oc = sip.call.create(caller_t.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${callee_t.address}:${callee_t.port}`})
43
+ ocs.push(oc)
44
+ }
45
+
46
+ // Here we will wait for the calls to arrive
47
+ await z.wait(_.chain(callee_ts).map(t => ({
48
+ event: "incoming_call",
49
+ call_id: m.push("ic_ids"),
50
+ transport_id: t.id,
51
+ })).value(), 5000)
52
+
53
+ // Now we answer the calls
54
+ z.store.ic_ids.forEach(ic_id => {
55
+ sip.call.respond(ic_id, {code: 200, reason: 'OK'})
56
+ })
57
+
58
+ // Then we wait for the '200 OK' at the caller side
59
+ var events = _.chain(ocs).map(oc => ({
60
+ event: 'response',
61
+ call_id: oc.id,
62
+ method: 'INVITE',
63
+ msg: sip_msg({
64
+ $rs: '200',
65
+ $rr: 'OK',
66
+ '$(hdrcnt(VIA))': 1,
67
+ $fU: 'alice',
68
+ $fd: 'test.com',
69
+ $tU: 'bob',
70
+ '$hdr(content-type)': 'application/sdp',
71
+ $rb: '!{_}a=sendrecv',
72
+ }),
73
+ })).value()
74
+
75
+ events = events.concat(_.chain(ocs).map(oc => ({
76
+ event: 'media_update',
77
+ call_id: oc.id,
78
+ status: 'ok',
79
+ })).value())
80
+
81
+ events = events.concat(_.chain(z.store.ic_ids).map(ic_id => ({
82
+ event: 'media_update',
83
+ call_id: ic_id,
84
+ status: 'ok',
85
+ })).value())
86
+
87
+ await z.wait(events, 5000)
88
+
89
+ ocs.forEach(oc => {
90
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
91
+ })
92
+
93
+ await z.wait(_.chain(z.store.ic_ids).map(ic_id => ({
94
+ event: 'dtmf',
95
+ call_id: ic_id,
96
+ digits: '1234',
97
+ mode: 0,
98
+ media_id: 0,
99
+ })).value(), 5000)
100
+
101
+ z.store.ic_ids.forEach(ic_id => {
102
+ sip.call.send_dtmf(ic_id, {digits: '4321', mode: 1})
103
+ })
104
+
105
+ await z.wait(_.chain(ocs).map(oc => ({
106
+ event: 'dtmf',
107
+ call_id: oc.id,
108
+ digits: '4321',
109
+ mode: 1,
110
+ media_id: 0,
111
+ })).value(), 5000)
112
+
113
+ // now we terminate the calls
114
+ ocs.forEach(oc => {
115
+ sip.call.terminate(oc.id)
116
+ })
117
+
118
+ // and wait for termination events
119
+ events = _.chain(ocs).map(oc => ({
120
+ event: 'response',
121
+ call_id: oc.id,
122
+ method: 'BYE',
123
+ msg: sip_msg({
124
+ $rs: '200',
125
+ $rr: 'OK',
126
+ }),
127
+ })).value()
128
+
129
+ events = events.concat(_.chain(ocs).map(oc => ({
130
+ event: 'call_ended',
131
+ call_id: oc.id,
132
+ })).value())
133
+
134
+ events = events.concat(_.chain(z.store.ic_ids).map(ic_id => ({
135
+ event: 'call_ended',
136
+ call_id: ic_id,
137
+ })).value())
138
+
139
+ await z.wait(events, 5000)
140
+
141
+ console.log("Success")
142
+
143
+ sip.stop()
144
+ }
145
+
146
+
147
+ test()
148
+ .catch(e => {
149
+ console.error(e)
150
+ process.exit(1)
151
+ })
152
+
package/src/sip.cpp CHANGED
@@ -4757,21 +4757,29 @@ static void on_forked(pjsip_inv_session *inv, pjsip_event *e) {
4757
4757
 
4758
4758
  static pjmedia_transport *create_media_transport(const pj_str_t *addr,
4759
4759
  pj_uint16_t *allocated_port) {
4760
+ printf("create_media_transport\n");
4760
4761
  pjmedia_transport *med_transport;
4761
4762
  pj_status_t status;
4762
4763
  for (int i = 0; i < 1000; ++i) {
4763
4764
  int port = 10000 + (i * 2);
4765
+ //printf("trying port=%i\n", port);
4764
4766
  status = pjmedia_transport_udp_create3(g_med_endpt, AF, NULL, addr, port, 0,
4765
4767
  &med_transport);
4766
4768
  if (status == PJ_SUCCESS) {
4767
4769
  pjmedia_transport_info tpinfo;
4768
4770
  pjmedia_transport_info_init(&tpinfo);
4769
4771
  status = pjmedia_transport_get_info(med_transport, &tpinfo);
4770
- printf("create_media_transport created %x\n", med_transport);
4772
+ //printf("create_media_transport port=%i created %x\n", port, med_transport);
4771
4773
  *allocated_port = port;
4772
4774
  return med_transport;
4775
+ } else {
4776
+ char err[1024];
4777
+ pj_strerror(status, err, sizeof(err));
4778
+
4779
+ printf("pjmedia_transport_udp_create3 status=%i (%s)\n", status, err);
4773
4780
  }
4774
4781
  }
4782
+ printf("no port available\n");
4775
4783
  return NULL;
4776
4784
  }
4777
4785