sip-lab 1.29.0 → 1.30.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/build_deps.sh CHANGED
@@ -56,7 +56,8 @@ then
56
56
  #git checkout 797088ed133c98492519b7d042b75735f6f9388c # updated as part of #21
57
57
  #git checkout 651df5b50129b7c5a5feec8336dda4468d53d2b0 # updated to latest to see of crash issues improve
58
58
  #git checkout 043926a5846963a2c99378e8daa495230923eaab # updated to try to solve #49 (but issue remains)
59
- git checkout c36802585ddefb3ca477d1f6d773d179510c5412 # updated to try to solve #83 (but issue remains)
59
+ #git checkout c36802585ddefb3ca477d1f6d773d179510c5412 # updated to try to solve #83 (but issue remains)
60
+ git checkout 9543a1bcf50be721d030be99afeeb63bd8cf2013 # updated to latest commit to permit to report https://github.com/pjsip/pjproject/issues/4082
60
61
 
61
62
  cat > user.mak <<EOF
62
63
  export CFLAGS += -fPIC -g
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-lab",
3
- "version": "1.29.0",
3
+ "version": "1.30.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "engines": {
Binary file
Binary file
@@ -0,0 +1,171 @@
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
+ z.trap_events(sip.event_source, 'event', (evt) => {
15
+ var e = evt.args[0]
16
+ return e
17
+ })
18
+
19
+ //sip.set_codecs("pcmu/8000/1:128,pcma/8000/1:128,gsm/8000/1:128")
20
+ sip.set_codecs("pcma/8000/1:128")
21
+
22
+ console.log(sip.start((data) => { console.log(data)} ))
23
+
24
+ t1 = sip.transport.create({address: "127.0.0.1", type: 'udp'})
25
+ t2 = sip.transport.create({address: "127.0.0.1", type: 'udp'})
26
+
27
+ console.log("t1", t1)
28
+ console.log("t2", t2)
29
+
30
+ oc = sip.call.create(t1.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${t2.address}:${t2.port}`})
31
+
32
+ await z.wait([
33
+ {
34
+ event: "incoming_call",
35
+ call_id: m.collect("call_id"),
36
+ },
37
+ {
38
+ event: 'response',
39
+ call_id: oc.id,
40
+ method: 'INVITE',
41
+ msg: sip_msg({
42
+ $rs: '100',
43
+ $rr: 'Trying',
44
+ '$hdr(call-id)': m.collect('sip_call_id'),
45
+ }),
46
+ },
47
+ ], 1000)
48
+
49
+ ic = {
50
+ id: z.store.call_id,
51
+ sip_call_id: z.store.sip_call_id,
52
+ }
53
+
54
+ sip.call.respond(ic.id, {code: 200, reason: 'OK'})
55
+
56
+ await z.wait([
57
+ {
58
+ event: 'response',
59
+ call_id: oc.id,
60
+ method: 'INVITE',
61
+ msg: sip_msg({
62
+ $rs: '200',
63
+ $rr: 'OK',
64
+ }),
65
+ },
66
+ {
67
+ event: 'media_update',
68
+ call_id: oc.id,
69
+ status: 'ok',
70
+ media: [
71
+ {
72
+ type: 'audio',
73
+ local: {
74
+ port: 10000,
75
+ mode: 'sendrecv'
76
+ },
77
+ remote: {
78
+ port: 10002,
79
+ mode: 'sendrecv'
80
+ },
81
+ },
82
+ ],
83
+ },
84
+ {
85
+ event: 'media_update',
86
+ call_id: ic.id,
87
+ status: 'ok',
88
+ media: [
89
+ {
90
+ type: 'audio',
91
+ local: {
92
+ port: 10002,
93
+ mode: 'sendrecv'
94
+ },
95
+ remote: {
96
+ port: 10000,
97
+ mode: 'sendrecv'
98
+ },
99
+ }
100
+ ],
101
+ },
102
+ ], 1000)
103
+
104
+ sip.call.start_record_wav(oc.id, {file: 'oc.wav'})
105
+ sip.call.start_record_wav(ic.id, {file: 'ic.wav'})
106
+
107
+ await z.sleep(100)
108
+
109
+ sip.call.start_bfsk_detection(oc.id, {freq_zero: 880, freq_one: 1280})
110
+ //sip.call.start_bfsk_detection(ic.id, {freq_zero: 880, freq_one: 1280})
111
+
112
+ oc_bits = '1010'
113
+ ic_bits = '1100'
114
+
115
+ sip.call.send_bfsk(ic.id, {bits: ic_bits, freq_zero: 880, freq_one: 1280})
116
+ //sip.call.send_bfsk(oc.id, {bits: oc_bits, freq_zero: 880, freq_one: 1280})
117
+
118
+ await z.wait([
119
+ {
120
+ event: 'bfsk',
121
+ call_id: ic.id,
122
+ bits: oc_bits,
123
+ media_id: 0
124
+ },
125
+ {
126
+ event: 'bfsk',
127
+ call_id: oc.id,
128
+ bits: ic_bits,
129
+ media_id: 0
130
+ },
131
+ ], 10000)
132
+
133
+ await z.sleep(1000)
134
+
135
+ sip.call.stop_record_wav(oc.id)
136
+ sip.call.stop_record_wav(ic.id)
137
+
138
+ sip.call.terminate(oc.id)
139
+
140
+ await z.wait([
141
+ {
142
+ event: 'call_ended',
143
+ call_id: oc.id,
144
+ },
145
+ {
146
+ event: 'call_ended',
147
+ call_id: ic.id,
148
+ },
149
+ {
150
+ event: 'response',
151
+ call_id: oc.id,
152
+ method: 'BYE',
153
+ msg: sip_msg({
154
+ $rs: '200',
155
+ $rr: 'OK',
156
+ }),
157
+ },
158
+ ], 1000)
159
+
160
+ console.log("Success")
161
+
162
+ sip.stop()
163
+ }
164
+
165
+
166
+ test()
167
+ .catch(e => {
168
+ console.error(e)
169
+ process.exit(1)
170
+ })
171
+
@@ -0,0 +1,154 @@
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(6)
10
+ sip.dtmf_aggregation_on(500)
11
+
12
+ sip.set_codecs("PCMU/8000/1:128")
13
+
14
+ z.trap_events(sip.event_source, 'event', (evt) => {
15
+ var e = evt.args[0]
16
+ return e
17
+ })
18
+
19
+ console.log(sip.start((data) => { console.log(data)} ))
20
+
21
+ t1 = sip.transport.create({address: "127.0.0.1", type: 'tcp'})
22
+ t2 = sip.transport.create({address: "127.0.0.1", type: 'tcp'})
23
+
24
+ console.log("t1", t1)
25
+ console.log("t2", t2)
26
+
27
+ oc = sip.call.create(t1.id, {
28
+ from_uri: '"abc"<sip:alice@test.com>',
29
+ to_uri: `sip:bob@${t2.address}:${t2.port}`,
30
+ })
31
+
32
+ await z.wait([
33
+ {
34
+ event: "incoming_call",
35
+ call_id: m.collect("call_id"),
36
+ msg: sip_msg({
37
+ $rm: 'INVITE',
38
+ $fU: 'alice',
39
+ $fd: 'test.com',
40
+ $tU: 'bob',
41
+ }),
42
+ },
43
+ {
44
+ event: 'response',
45
+ call_id: oc.id,
46
+ method: 'INVITE',
47
+ msg: sip_msg({
48
+ $rs: '100',
49
+ $rr: 'Trying',
50
+ }),
51
+ },
52
+ ], 1000)
53
+
54
+ ic = {
55
+ id: z.store.call_id,
56
+ sip_call_id: z.store.sip_call_id,
57
+ }
58
+
59
+ sip.call.respond(ic.id, {
60
+ code: 200,
61
+ reason:'OK',
62
+ })
63
+
64
+ await z.wait([
65
+ {
66
+ event: 'media_update',
67
+ call_id: oc.id,
68
+ status: 'ok',
69
+ },
70
+ {
71
+ event: 'media_update',
72
+ call_id: ic.id,
73
+ status: 'ok',
74
+ },
75
+ {
76
+ event: 'response',
77
+ call_id: oc.id,
78
+ method: 'INVITE',
79
+ msg: sip_msg({
80
+ $rs: '200',
81
+ $rr: 'OK',
82
+ }),
83
+ },
84
+ ], 1000)
85
+
86
+ sip.call.start_record_wav(oc.id, {file: './oc.wav'})
87
+ sip.call.start_record_wav(ic.id, {file: './ic.wav'})
88
+
89
+ sip.call.start_speech_recog(oc.id, {server_url: 'ws://0.0.0.0:8080', engine: 'bfsk-sr', language: '500:2000'})
90
+ sip.call.start_speech_recog(ic.id, {server_url: 'ws://0.0.0.0:8080', engine: 'bfsk-sr', language: '500:2000'})
91
+
92
+ sip.call.start_speech_synth(oc.id, {server_url: 'ws://0.0.0.0:8080', engine: 'bfsk-ss', voice: '5', language: '500:2000', text: 'abcdefgh', times: 1})
93
+ sip.call.start_speech_synth(ic.id, {server_url: 'ws://0.0.0.0:8080', engine: 'bfsk-ss', voice: '5', language: '500:2000', text: 'hgfedcba', times: 1})
94
+
95
+ await z.wait([
96
+ {
97
+ event: 'speech_synth_complete',
98
+ call_id: ic.id,
99
+ },
100
+ {
101
+ event: 'speech_synth_complete',
102
+ call_id: oc.id,
103
+ },
104
+ {
105
+ event: 'speech',
106
+ call_id: oc.id,
107
+ transcript: 'hgfedcba'
108
+ },
109
+ {
110
+ event: 'speech',
111
+ call_id: ic.id,
112
+ transcript: 'abcdefgh'
113
+ }
114
+ ], 3000)
115
+
116
+ sip.call.stop_record_wav(oc.id)
117
+ sip.call.stop_record_wav(ic.id)
118
+
119
+ sip.call.terminate(oc.id)
120
+
121
+ await z.wait([
122
+ {
123
+ event: 'call_ended',
124
+ call_id: oc.id,
125
+ },
126
+ {
127
+ event: 'call_ended',
128
+ call_id: ic.id,
129
+ },
130
+ {
131
+ event: 'response',
132
+ call_id: oc.id,
133
+ method: 'BYE',
134
+ msg: sip_msg({
135
+ $rs: '200',
136
+ $rr: 'OK',
137
+ }),
138
+ },
139
+ ], 1000)
140
+
141
+ await z.sleep(50)
142
+
143
+ console.log("Success")
144
+
145
+ sip.stop()
146
+ }
147
+
148
+
149
+ test()
150
+ .catch(e => {
151
+ console.error(e)
152
+ process.exit(1)
153
+ })
154
+
@@ -86,11 +86,11 @@ async function test() {
86
86
  sip.call.start_record_wav(oc.id, {file: './oc.wav'})
87
87
  sip.call.start_record_wav(ic.id, {file: './ic.wav'})
88
88
 
89
- sip.call.start_speech_recog(oc.id, {server_url: 'ws://0.0.0.0:8080', engine: 'dtmf-det', language: 'dtmf'})
90
- sip.call.start_speech_recog(ic.id, {server_url: 'ws://0.0.0.0:8080', engine: 'dtmf-det', language: 'dtmf'})
89
+ sip.call.start_speech_recog(oc.id, {server_url: 'ws://0.0.0.0:8080', engine: 'dtmf-sr', language: 'dtmf'})
90
+ sip.call.start_speech_recog(ic.id, {server_url: 'ws://0.0.0.0:8080', engine: 'dtmf-sr', language: 'dtmf'})
91
91
 
92
- sip.call.start_speech_synth(oc.id, {server_url: 'ws://0.0.0.0:8080', engine: 'dtmf-gen', voice: 'dtmf', language: 'dtmf', text: 'abcd', times: 1})
93
- sip.call.start_speech_synth(ic.id, {server_url: 'ws://0.0.0.0:8080', engine: 'dtmf-gen', voice: 'dtmf', language: 'dtmf', text: 'dcba', times: 1})
92
+ sip.call.start_speech_synth(oc.id, {server_url: 'ws://0.0.0.0:8080', engine: 'dtmf-ss', voice: 'dtmf', language: 'dtmf', text: 'abcd', times: 1})
93
+ sip.call.start_speech_synth(ic.id, {server_url: 'ws://0.0.0.0:8080', engine: 'dtmf-ss', voice: 'dtmf', language: 'dtmf', text: 'dcba', times: 1})
94
94
 
95
95
  await z.wait([
96
96
  {
@@ -101,20 +101,6 @@ async function test() {
101
101
  event: 'speech_synth_complete',
102
102
  call_id: oc.id,
103
103
  },
104
- {
105
- event: 'dtmf',
106
- call_id: oc.id,
107
- digits: 'dcba',
108
- mode: 1,
109
- media_id: 0
110
- },
111
- {
112
- event: 'dtmf',
113
- call_id: ic.id,
114
- digits: 'abcd',
115
- mode: 1,
116
- media_id: 0
117
- },
118
104
  {
119
105
  event: 'speech',
120
106
  call_id: oc.id,
@@ -127,8 +113,6 @@ async function test() {
127
113
  },
128
114
  ], 3000)
129
115
 
130
- await z.sleep(1000)
131
-
132
116
  sip.call.stop_record_wav(oc.id)
133
117
  sip.call.stop_record_wav(ic.id)
134
118
 
@@ -154,7 +138,7 @@ async function test() {
154
138
  },
155
139
  ], 1000)
156
140
 
157
- await z.sleep(100)
141
+ await z.sleep(50)
158
142
 
159
143
  console.log("Success")
160
144
 
@@ -83,16 +83,16 @@ async function test() {
83
83
  },
84
84
  ], 1000)
85
85
 
86
- await z.sleep(200)
87
-
88
86
  sip.call.start_record_wav(oc.id, {file: './oc.wav'})
89
87
  sip.call.start_record_wav(ic.id, {file: './ic.wav'})
90
88
 
91
- sip.call.start_speech_recog(oc.id, {server_url: 'ws://0.0.0.0:8080', engine: 'gsr', language: 'en-US'})
92
- sip.call.start_speech_recog(ic.id, {server_url: 'ws://0.0.0.0:8080', engine: 'gsr', language: 'en-US'})
89
+ sip.call.start_speech_recog(oc.id, {server_url: 'ws://0.0.0.0:8080', engine: 'google-sr', language: 'en-US'})
90
+ sip.call.start_speech_recog(ic.id, {server_url: 'ws://0.0.0.0:8080', engine: 'google-sr', language: 'en-US'})
91
+
92
+ await z.sleep(100)
93
93
 
94
- sip.call.start_speech_synth(oc.id, {server_url: 'ws://0.0.0.0:8080', engine: 'gss', voice: 'en-US-Standard-E', language: 'en-US', text: 'hello world', times: 1})
95
- sip.call.start_speech_synth(ic.id, {server_url: 'ws://0.0.0.0:8080', engine: 'gss', voice: 'en-US-Standard-F', language: 'en-US', text: '<speak>Good morning<break time="2s"/>Good Afternoon</speak>', times: 1})
94
+ sip.call.start_speech_synth(oc.id, {server_url: 'ws://0.0.0.0:8080', engine: 'google-ss', voice: 'en-US-Standard-E', language: 'en-US', text: 'hello world', times: 1})
95
+ sip.call.start_speech_synth(ic.id, {server_url: 'ws://0.0.0.0:8080', engine: 'google-ss', voice: 'en-US-Standard-F', language: 'en-US', text: '<speak>Good morning<break time="2s"/>Good Afternoon</speak>', times: 1})
96
96
 
97
97
  await z.wait([
98
98
  {
@@ -113,7 +113,7 @@ async function test() {
113
113
  call_id: ic.id,
114
114
  transcript: 'hello world',
115
115
  },
116
- ], 4000)
116
+ ], 8000)
117
117
 
118
118
  await z.wait([
119
119
  {
@@ -123,8 +123,6 @@ async function test() {
123
123
  },
124
124
  ], 4000)
125
125
 
126
- await z.sleep(1000)
127
-
128
126
  sip.call.stop_record_wav(oc.id)
129
127
  sip.call.stop_record_wav(ic.id)
130
128
 
@@ -150,7 +148,7 @@ async function test() {
150
148
  },
151
149
  ], 1000)
152
150
 
153
- await z.sleep(100)
151
+ await z.sleep(50)
154
152
 
155
153
  console.log("Success")
156
154
 
@@ -0,0 +1,156 @@
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
+ function stringToBinary(str) {
9
+ return str.split('').map(char => {
10
+ return char.charCodeAt(0).toString(2).padStart(8, '0');
11
+ }).join('');
12
+ }
13
+
14
+ async function test() {
15
+ //sip.set_log_level(6)
16
+ sip.dtmf_aggregation_on(500)
17
+
18
+ sip.set_codecs("PCMU/8000/1:128")
19
+
20
+ z.trap_events(sip.event_source, 'event', (evt) => {
21
+ var e = evt.args[0]
22
+ return e
23
+ })
24
+
25
+ console.log(sip.start((data) => { console.log(data)} ))
26
+
27
+ t1 = sip.transport.create({address: "127.0.0.1", type: 'tcp'})
28
+ t2 = sip.transport.create({address: "127.0.0.1", type: 'tcp'})
29
+
30
+ console.log("t1", t1)
31
+ console.log("t2", t2)
32
+
33
+ oc = sip.call.create(t1.id, {
34
+ from_uri: '"abc"<sip:alice@test.com>',
35
+ to_uri: `sip:bob@${t2.address}:${t2.port}`,
36
+ })
37
+
38
+ await z.wait([
39
+ {
40
+ event: "incoming_call",
41
+ call_id: m.collect("call_id"),
42
+ msg: sip_msg({
43
+ $rm: 'INVITE',
44
+ $fU: 'alice',
45
+ $fd: 'test.com',
46
+ $tU: 'bob',
47
+ }),
48
+ },
49
+ {
50
+ event: 'response',
51
+ call_id: oc.id,
52
+ method: 'INVITE',
53
+ msg: sip_msg({
54
+ $rs: '100',
55
+ $rr: 'Trying',
56
+ }),
57
+ },
58
+ ], 1000)
59
+
60
+ ic = {
61
+ id: z.store.call_id,
62
+ sip_call_id: z.store.sip_call_id,
63
+ }
64
+
65
+ sip.call.respond(ic.id, {
66
+ code: 200,
67
+ reason:'OK',
68
+ })
69
+
70
+ await z.wait([
71
+ {
72
+ event: 'media_update',
73
+ call_id: oc.id,
74
+ status: 'ok',
75
+ },
76
+ {
77
+ event: 'media_update',
78
+ call_id: ic.id,
79
+ status: 'ok',
80
+ },
81
+ {
82
+ event: 'response',
83
+ call_id: oc.id,
84
+ method: 'INVITE',
85
+ msg: sip_msg({
86
+ $rs: '200',
87
+ $rr: 'OK',
88
+ }),
89
+ },
90
+ ], 1000)
91
+
92
+ sip.call.start_record_wav(oc.id, {file: './oc.wav'})
93
+ sip.call.start_record_wav(ic.id, {file: './ic.wav'})
94
+
95
+ sip.call.start_speech_recog(oc.id, {server_url: 'ws://0.0.0.0:8080', engine: 'bfsk-sr', language: '500:2000'})
96
+ sip.call.start_speech_recog(ic.id, {server_url: 'ws://0.0.0.0:8080', engine: 'bfsk-sr', language: '500:2000'})
97
+
98
+ await z.sleep(100)
99
+
100
+ sip.call.send_bfsk(oc.id, {bits: stringToBinary('abcd'), freq_zero: 500, freq_one: 2000})
101
+ sip.call.send_bfsk(ic.id, {bits: stringToBinary('dcba'), freq_zero: 500, freq_one: 2000})
102
+
103
+ await z.wait([
104
+ {
105
+ event: 'speech',
106
+ call_id: oc.id,
107
+ transcript: 'dcba'
108
+ },
109
+ {
110
+ event: 'speech',
111
+ call_id: ic.id,
112
+ transcript: 'abcd'
113
+ },
114
+ ], 2000)
115
+
116
+ await z.sleep(1000)
117
+
118
+ sip.call.stop_record_wav(oc.id)
119
+ sip.call.stop_record_wav(ic.id)
120
+
121
+ sip.call.terminate(oc.id)
122
+
123
+ await z.wait([
124
+ {
125
+ event: 'call_ended',
126
+ call_id: oc.id,
127
+ },
128
+ {
129
+ event: 'call_ended',
130
+ call_id: ic.id,
131
+ },
132
+ {
133
+ event: 'response',
134
+ call_id: oc.id,
135
+ method: 'BYE',
136
+ msg: sip_msg({
137
+ $rs: '200',
138
+ $rr: 'OK',
139
+ }),
140
+ },
141
+ ], 1000)
142
+
143
+ await z.sleep(100)
144
+
145
+ console.log("Success")
146
+
147
+ sip.stop()
148
+ }
149
+
150
+
151
+ test()
152
+ .catch(e => {
153
+ console.error(e)
154
+ process.exit(1)
155
+ })
156
+