sip-lab 1.12.12 → 1.12.16
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/DEV.md +35 -0
- package/README.md +9 -2
- package/devjournal +7 -0
- package/install.sh +2 -4
- package/package.json +3 -2
- package/samples/g729.js +3 -3
- package/samples/register_subscribe.js +12 -6
- package/samples/sip_cancel.js +5 -0
- package/samples/tcp_and_extra_headers.js +3 -3
- package/src/event_templates.cpp +5 -2
package/DEV.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
### For devs
|
|
2
|
+
|
|
3
|
+
We build and statically link to libs pjproject, spandsp, bgc729 and rapidjson.
|
|
4
|
+
|
|
5
|
+
Basic tasks for development:
|
|
6
|
+
|
|
7
|
+
#### To build
|
|
8
|
+
```
|
|
9
|
+
npm install
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
#### To clean up (for a clean rebuild)
|
|
13
|
+
```
|
|
14
|
+
npx node-gyp clean
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
#### To update pjproject, spandsp, bcg729 or rapidjson
|
|
18
|
+
Just delete the corresponding library subfolder in subfolder 3drParty.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Then temporarily change install.sh to not checkout a specific version (or checkout a desired commit)
|
|
22
|
+
|
|
23
|
+
Then run
|
|
24
|
+
```
|
|
25
|
+
npm install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then perform code changes and tests. When you are satisfied with them, update install.sh with the new commit id.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
#### Running tests
|
|
32
|
+
```
|
|
33
|
+
npm test
|
|
34
|
+
```
|
|
35
|
+
|
package/README.md
CHANGED
|
@@ -25,12 +25,17 @@ apt install build-essential automake autoconf libtool libspeex-dev libopus-dev l
|
|
|
25
25
|
|
|
26
26
|
Then install sip-lab by doing:
|
|
27
27
|
```
|
|
28
|
-
|
|
28
|
+
npm install sip-lab
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
Be patient because we will need to download pjproject and build it.
|
|
32
32
|
|
|
33
|
-
We will also download rapidjson.
|
|
33
|
+
We will also download and build spandsp, bcg729 and rapidjson.
|
|
34
|
+
|
|
35
|
+
However since it takes several minutes to build this module, you can install it globally:
|
|
36
|
+
```
|
|
37
|
+
npm install -g sip-lab
|
|
38
|
+
```
|
|
34
39
|
|
|
35
40
|
To test from within this repo just build and install by doing:
|
|
36
41
|
```
|
|
@@ -49,9 +54,11 @@ It was originally developed with node v.10 and tested with v.12 and v16.13.1 and
|
|
|
49
54
|
(it is known to not work with node v.8)
|
|
50
55
|
|
|
51
56
|
|
|
57
|
+
|
|
52
58
|
### About the code
|
|
53
59
|
|
|
54
60
|
Although the code in written in *.cpp/*.hpp named files, this is not actually a C++ project.
|
|
55
61
|
|
|
56
62
|
It is mostly written in C using some C++ facilities.
|
|
57
63
|
|
|
64
|
+
|
package/devjournal
CHANGED
|
@@ -438,5 +438,12 @@ When rebuilding the addon, this should be enough (it should be fast):
|
|
|
438
438
|
```
|
|
439
439
|
npm install --unsafe-perm
|
|
440
440
|
```
|
|
441
|
+
------------------------------------------------------------
|
|
442
|
+
2022/09/11 takeshi:
|
|
443
|
+
|
|
444
|
+
To try to solve #21, we upraded pjproject to commit 797088ed133c98492519b7d042b75735f6f9388c.
|
|
445
|
+
However, after doing it we verified sending CANCEL doesn't cause the other side to send '497 Request Terminated' by itself anymore (see samples/sip_cancel.js)
|
|
446
|
+
|
|
447
|
+
|
|
441
448
|
|
|
442
449
|
|
package/install.sh
CHANGED
|
@@ -52,10 +52,8 @@ then
|
|
|
52
52
|
git clone https://github.com/pjsip/pjproject
|
|
53
53
|
cd pjproject
|
|
54
54
|
#git checkout de3d744c2e1188b59bb907b6ee32ef83740ebc64
|
|
55
|
-
git checkout 33a3c9e0a5eb84426edef05a9aa98af17d8011c3 # required for bcg729
|
|
56
|
-
|
|
57
|
-
#echo "Patching sip_transaction.c to avoid problems with CANCEL"
|
|
58
|
-
sed -i -r 's|event->body.tx_msg.tdata == tsx->last_tx,|\t\t\t1, /* \0 */|' pjsip/src/pjsip/sip_transaction.c
|
|
55
|
+
#git checkout 33a3c9e0a5eb84426edef05a9aa98af17d8011c3 # required for bcg729
|
|
56
|
+
git checkout 797088ed133c98492519b7d042b75735f6f9388c # updated as part of #21
|
|
59
57
|
|
|
60
58
|
cat > user.mak <<EOF
|
|
61
59
|
export CFLAGS += -fPIC -g
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sip-lab",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=10.22"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"install": "./install.sh"
|
|
10
|
+
"install": "./install.sh",
|
|
11
|
+
"test": "./runtests"
|
|
11
12
|
},
|
|
12
13
|
"repository": {
|
|
13
14
|
"type": "git",
|
package/samples/g729.js
CHANGED
|
@@ -42,11 +42,11 @@ async function test() {
|
|
|
42
42
|
$rs: '100',
|
|
43
43
|
$rr: 'Trying',
|
|
44
44
|
'$(hdrcnt(via))': 1,
|
|
45
|
-
'
|
|
45
|
+
'hdr_call_id': m.collect('sip_call_id'),
|
|
46
46
|
$fU: 'alice',
|
|
47
47
|
$fd: 'test.com',
|
|
48
48
|
$tU: 'bob',
|
|
49
|
-
'
|
|
49
|
+
'hdr_l': '0',
|
|
50
50
|
}),
|
|
51
51
|
},
|
|
52
52
|
], 1000)
|
|
@@ -84,7 +84,7 @@ async function test() {
|
|
|
84
84
|
$fU: 'alice',
|
|
85
85
|
$fd: 'test.com',
|
|
86
86
|
$tU: 'bob',
|
|
87
|
-
'
|
|
87
|
+
'hdr_content_type': 'application/sdp',
|
|
88
88
|
$rb: '!{_}a=sendrecv',
|
|
89
89
|
}),
|
|
90
90
|
},
|
|
@@ -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 assert = require('assert')
|
|
6
7
|
|
|
7
8
|
async function test() {
|
|
8
9
|
//sip.set_log_level(6)
|
|
@@ -47,7 +48,7 @@ async function test() {
|
|
|
47
48
|
$tU: 'user1',
|
|
48
49
|
$td: domain,
|
|
49
50
|
'$hdr(X-MyHeader1)': 'aaa',
|
|
50
|
-
'
|
|
51
|
+
'hdr_x_myheader2': 'bbb',
|
|
51
52
|
}),
|
|
52
53
|
},
|
|
53
54
|
], 1000)
|
|
@@ -78,7 +79,9 @@ async function test() {
|
|
|
78
79
|
},
|
|
79
80
|
})
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
const sub_expires = 120
|
|
83
|
+
|
|
84
|
+
sip.subscription.subscribe(s1, {expires: sub_expires})
|
|
82
85
|
|
|
83
86
|
await z.wait([
|
|
84
87
|
{
|
|
@@ -90,8 +93,8 @@ async function test() {
|
|
|
90
93
|
$fU: 'user1',
|
|
91
94
|
$fd: domain,
|
|
92
95
|
'$hdr(Event)': 'dialog',
|
|
93
|
-
'
|
|
94
|
-
'
|
|
96
|
+
'hdr_accept': 'application/dialog-info+xml',
|
|
97
|
+
'hdr_allow_events': 'refer, dialog',
|
|
95
98
|
})
|
|
96
99
|
},
|
|
97
100
|
], 1000)
|
|
@@ -115,13 +118,16 @@ async function test() {
|
|
|
115
118
|
subscription_id: s1,
|
|
116
119
|
msg: sip_msg({
|
|
117
120
|
$rm: 'NOTIFY',
|
|
118
|
-
'
|
|
119
|
-
'$hdr(Subscription-State)': 'active;expires
|
|
121
|
+
'hdr_event': 'dialog',
|
|
122
|
+
'$hdr(Subscription-State)': 'active;expires=!{sub_expires:num}',
|
|
120
123
|
'$hdr(Allow-Events)': 'refer, dialog',
|
|
121
124
|
}),
|
|
122
125
|
},
|
|
123
126
|
], 1000)
|
|
124
127
|
|
|
128
|
+
// Subscription-State expires will be computed by pjsip. It might not be the exact value of sub_expires due to latence so we give 2 seconds of tolerance
|
|
129
|
+
assert(z.store.sub_expires > (sub_expires - 2))
|
|
130
|
+
|
|
125
131
|
sip.account.unregister(a1)
|
|
126
132
|
|
|
127
133
|
await z.wait([
|
package/samples/sip_cancel.js
CHANGED
|
@@ -40,7 +40,7 @@ async function test() {
|
|
|
40
40
|
$fd: 'test.com',
|
|
41
41
|
$tU: 'bob',
|
|
42
42
|
'$hdr(X-MyHeader1)': 'abc',
|
|
43
|
-
'
|
|
43
|
+
'hdr_x_myheader2': 'def',
|
|
44
44
|
}),
|
|
45
45
|
},
|
|
46
46
|
{
|
|
@@ -51,7 +51,7 @@ async function test() {
|
|
|
51
51
|
$rs: '100',
|
|
52
52
|
$rr: 'Trying',
|
|
53
53
|
'$(hdrcnt(via))': 1,
|
|
54
|
-
'
|
|
54
|
+
'hdr_call_id': m.collect('sip_call_id'),
|
|
55
55
|
$fU: 'alice',
|
|
56
56
|
$fd: 'test.com',
|
|
57
57
|
$tU: 'bob',
|
|
@@ -96,7 +96,7 @@ async function test() {
|
|
|
96
96
|
msg: sip_msg({
|
|
97
97
|
$rs: '200',
|
|
98
98
|
$rr: 'OK',
|
|
99
|
-
'$(hdrcnt(
|
|
99
|
+
'$(hdrcnt(v))': 1,
|
|
100
100
|
$fU: 'alice',
|
|
101
101
|
$fd: 'test.com',
|
|
102
102
|
$tU: 'bob',
|
package/src/event_templates.cpp
CHANGED
|
@@ -26,8 +26,11 @@ int make_evt_dtmf(char *dest, int size, long call_id, int digits_len, const char
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
int make_evt_call_ended(char *dest, int size, long call_id, int sip_msg_len, const char *sip_msg) {
|
|
29
|
-
printf("sip_msg_len=%i sip_msg=%
|
|
30
|
-
|
|
29
|
+
printf("sip_msg_len=%i sip_msg=%x\n", sip_msg_len, sip_msg);
|
|
30
|
+
if(!sip_msg || sip_msg == (char*)0xc000000000000) {
|
|
31
|
+
// received invalid pointer to sip_msg so do not add the message to the event
|
|
32
|
+
return snprintf(dest, size, "{\"event\": \"call_ended\", \"call_id\": %ld}", call_id);
|
|
33
|
+
} else if(sip_msg_len > 500 && sip_msg_len < 2000 && sip_msg) {
|
|
31
34
|
/* sip_msg_len sometimes show up as a large value like sip_msg_len=11560297 which seems to be a bug in pjsip */
|
|
32
35
|
return snprintf(dest, size, "{\"event\": \"call_ended\", \"call_id\": %ld}\n%.*s", call_id, sip_msg_len, sip_msg);
|
|
33
36
|
} else {
|