sip-lab 1.12.3 → 1.12.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/README.md +1 -23
- package/binding.gyp +18 -16
- package/include/siplab_constants.h +6 -0
- package/install.sh +43 -8
- package/package.json +3 -3
- package/samples/artifacts/yosemitesam.wav +0 -0
- package/samples/delayed_media.js +2 -2
- package/samples/g729.js +2 -2
- package/samples/register_subscribe.js +2 -2
- package/samples/reinvite_and_dtmf.js +2 -2
- package/samples/send_and_receive_fax.js +5 -4
- package/samples/simple.js +5 -5
- package/samples/sip_cancel.js +2 -2
- package/samples/tcp_and_extra_headers.js +4 -4
- package/src/Makefile +1 -1
- package/src/pjmedia/include/chainlink/chainlink_fax.h +1 -0
- package/src/pjmedia/src/chainlink/chainlink_fax.c +20 -11
- package/src/sip.cpp +34 -3
- package/install_bcg729.sh +0 -18
package/README.md
CHANGED
|
@@ -20,14 +20,7 @@ TODO:
|
|
|
20
20
|
|
|
21
21
|
This will require you to have some libraries installed. So do:
|
|
22
22
|
```
|
|
23
|
-
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 libopus-dev libsdl2-dev libopencore-amrnb-dev libopencore-amrwb-dev libvo-amrwbenc-dev libboost-dev
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
We will also support G729 codec by installing bcg729.
|
|
27
|
-
|
|
28
|
-
There is a helper script that you can use:
|
|
29
|
-
```
|
|
30
|
-
./install_bcg729.sh
|
|
23
|
+
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 libopus-dev libsdl2-dev libopencore-amrnb-dev libopencore-amrwb-dev libvo-amrwbenc-dev libboost-dev libtiff-dev libpcap-dev libssl-dev uuid-dev
|
|
31
24
|
```
|
|
32
25
|
|
|
33
26
|
Then install sip-lab by doing:
|
|
@@ -56,21 +49,6 @@ It was originally developed with node v.10 and tested with v.12 and v16.13.1 and
|
|
|
56
49
|
(it is known to not work with node v.8)
|
|
57
50
|
|
|
58
51
|
|
|
59
|
-
Since running
|
|
60
|
-
```
|
|
61
|
-
npm install sip-lab
|
|
62
|
-
```
|
|
63
|
-
takes some time to fetch and build pjproject and the node addon for it, you could install sip-lab globally:
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
npm install -g sip-lab
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
But if you do so, you will need to set NODE_PATH for node to find it by doing:
|
|
70
|
-
```
|
|
71
|
-
export NODE_PATH=$(npm root --quiet -g)
|
|
72
|
-
```
|
|
73
|
-
|
|
74
52
|
### About the code
|
|
75
53
|
|
|
76
54
|
Although the code in written in *.cpp/*.hpp named files, this is not actually a C++ project.
|
package/binding.gyp
CHANGED
|
@@ -17,16 +17,18 @@
|
|
|
17
17
|
'src/pjmedia/src/chainlink/chainlink_fax.c',
|
|
18
18
|
],
|
|
19
19
|
'include_dirs': [
|
|
20
|
-
"pjproject/pjsip/include",
|
|
21
|
-
"pjproject/pjlib/include",
|
|
22
|
-
"pjproject/pjlib-util/include",
|
|
23
|
-
"pjproject/pjnath/include",
|
|
24
|
-
"pjproject/pjmedia/include",
|
|
20
|
+
"3rdParty/pjproject/pjsip/include",
|
|
21
|
+
"3rdParty/pjproject/pjlib/include",
|
|
22
|
+
"3rdParty/pjproject/pjlib-util/include",
|
|
23
|
+
"3rdParty/pjproject/pjnath/include",
|
|
24
|
+
"3rdParty/pjproject/pjmedia/include",
|
|
25
|
+
"include",
|
|
25
26
|
"src",
|
|
26
27
|
"src/pjmedia/include",
|
|
27
28
|
"src/pjmedia/include/pjmedia",
|
|
28
29
|
"src/pjmedia/include/chainlink",
|
|
29
|
-
"rapidjson/include",
|
|
30
|
+
"3rdParty/rapidjson/include",
|
|
31
|
+
"3rdParty/spandsp/src",
|
|
30
32
|
"<!@(node -p \"require('node-addon-api').include\")",
|
|
31
33
|
],
|
|
32
34
|
"dependencies": [
|
|
@@ -48,14 +50,13 @@
|
|
|
48
50
|
],
|
|
49
51
|
'link_settings': {
|
|
50
52
|
'libraries': [
|
|
51
|
-
'-L ../pjproject/pjnath/lib',
|
|
52
|
-
'-L ../pjproject/pjlib/lib',
|
|
53
|
-
'-L ../pjproject/pjlib-util/lib',
|
|
54
|
-
'-L ../pjproject/third_party/lib',
|
|
55
|
-
'-L ../pjproject/pjmedia/lib',
|
|
56
|
-
'-L ../pjproject/pjsip/lib',
|
|
57
|
-
'-L ../pjproject/third_party/lib',
|
|
58
|
-
'-L ../bcg729/src',
|
|
53
|
+
'-L ../3rdParty/pjproject/pjnath/lib',
|
|
54
|
+
'-L ../3rdParty/pjproject/pjlib/lib',
|
|
55
|
+
'-L ../3rdParty/pjproject/pjlib-util/lib',
|
|
56
|
+
'-L ../3rdParty/pjproject/third_party/lib',
|
|
57
|
+
'-L ../3rdParty/pjproject/pjmedia/lib',
|
|
58
|
+
'-L ../3rdParty/pjproject/pjsip/lib',
|
|
59
|
+
'-L ../3rdParty/pjproject/third_party/lib',
|
|
59
60
|
'-l pjnath-x86_64-unknown-linux-gnu',
|
|
60
61
|
'-l ilbccodec-x86_64-unknown-linux-gnu',
|
|
61
62
|
'-l srtp-x86_64-unknown-linux-gnu',
|
|
@@ -77,6 +78,8 @@
|
|
|
77
78
|
'-l pjsua-x86_64-unknown-linux-gnu',
|
|
78
79
|
'-l pj-x86_64-unknown-linux-gnu',
|
|
79
80
|
'-l pjlib-util-x86_64-unknown-linux-gnu',
|
|
81
|
+
'../3rdParty/spandsp/src/.libs/libspandsp.a',
|
|
82
|
+
'../3rdParty/bcg729/src/libbcg729.a',
|
|
80
83
|
'-lstdc++',
|
|
81
84
|
'-lopus',
|
|
82
85
|
'-lssl',
|
|
@@ -84,7 +87,7 @@
|
|
|
84
87
|
'-luuid',
|
|
85
88
|
'-lm',
|
|
86
89
|
'-ldl',
|
|
87
|
-
'-
|
|
90
|
+
'-ltiff',
|
|
88
91
|
'-lpcap',
|
|
89
92
|
'-lrt',
|
|
90
93
|
'-lpthread',
|
|
@@ -100,7 +103,6 @@
|
|
|
100
103
|
'-lopencore-amrwb',
|
|
101
104
|
'-lvo-amrwbenc',
|
|
102
105
|
'-lspeex',
|
|
103
|
-
'-lbcg729',
|
|
104
106
|
],
|
|
105
107
|
},
|
|
106
108
|
},
|
package/install.sh
CHANGED
|
@@ -4,8 +4,49 @@ set -o errexit
|
|
|
4
4
|
set -o nounset
|
|
5
5
|
set -o pipefail
|
|
6
6
|
|
|
7
|
+
|
|
7
8
|
START_DIR=`pwd`
|
|
8
9
|
|
|
10
|
+
|
|
11
|
+
mkdir -p 3rdParty
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
cd $START_DIR/3rdParty
|
|
15
|
+
if [[ ! -d spandsp ]]
|
|
16
|
+
then
|
|
17
|
+
commit=e59ca8fb8b1591e626e6a12fdc60a2ebe83435ed
|
|
18
|
+
git clone https://github.com/freeswitch/spandsp
|
|
19
|
+
cd spandsp
|
|
20
|
+
git checkout $commit
|
|
21
|
+
./bootstrap.sh
|
|
22
|
+
CFLAGS='-O -fPIC' ./configure --enable-shared
|
|
23
|
+
make
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
cd $START_DIR/3rdParty
|
|
28
|
+
if [[ ! -d rapidjson ]]
|
|
29
|
+
then
|
|
30
|
+
git clone https://github.com/Tencent/rapidjson
|
|
31
|
+
cd rapidjson
|
|
32
|
+
git checkout 27c3a8dc0e2c9218fe94986d249a12b5ed838f1d
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
cd $START_DIR/3rdParty
|
|
37
|
+
if [[ ! -d bcg729 ]]
|
|
38
|
+
then
|
|
39
|
+
git clone https://github.com/MayamaTakeshi/bcg729
|
|
40
|
+
cd bcg729
|
|
41
|
+
git checkout faaa895862165acde6df8add722ba4f85a25007d
|
|
42
|
+
cmake .
|
|
43
|
+
make
|
|
44
|
+
mkdir -p lib
|
|
45
|
+
cp -f src/libbcg729.a lib
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
cd $START_DIR/3rdParty
|
|
9
50
|
if [[ ! -d pjproject ]]
|
|
10
51
|
then
|
|
11
52
|
git clone https://github.com/pjsip/pjproject
|
|
@@ -21,21 +62,15 @@ then
|
|
|
21
62
|
export LDFLAGS +=
|
|
22
63
|
EOF
|
|
23
64
|
|
|
24
|
-
|
|
65
|
+
sed -i -r 's/BCG729_LIBS="-lbcg729"/BCG729_LIBS=''/' aconfigure
|
|
66
|
+
LIBS=`pwd`/../bcg729/src/libbcg729.a ./configure --with-bcg729=`pwd`/../bcg729
|
|
25
67
|
cat > pjlib/include/pj/config_site.h <<EOF
|
|
26
68
|
#define PJMEDIA_HAS_SRTP 0
|
|
27
69
|
EOF
|
|
28
70
|
make dep && make clean && make
|
|
29
71
|
fi
|
|
30
72
|
|
|
31
|
-
cd $START_DIR
|
|
32
73
|
|
|
33
|
-
if [[ ! -d rapidjson ]]
|
|
34
|
-
then
|
|
35
|
-
git clone https://github.com/Tencent/rapidjson
|
|
36
|
-
cd rapidjson
|
|
37
|
-
git checkout 27c3a8dc0e2c9218fe94986d249a12b5ed838f1d
|
|
38
|
-
fi
|
|
39
74
|
|
|
40
75
|
cd $START_DIR
|
|
41
76
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sip-lab",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"node-gyp": "^8.4.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
+
"@mayama/zeq": "^4.1.14",
|
|
26
27
|
"data-matching": "^1.23.8",
|
|
27
28
|
"sip-matching": "^1.3.13",
|
|
28
|
-
"string-matching": "^1.11.9"
|
|
29
|
-
"zester": "^4.1.1"
|
|
29
|
+
"string-matching": "^1.11.9"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
Binary file
|
package/samples/delayed_media.js
CHANGED
package/samples/g729.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var sip = require ('../index.js')
|
|
2
|
-
var
|
|
3
|
-
var z = new
|
|
2
|
+
var Zeq = require('@mayama/zeq')
|
|
3
|
+
var z = new Zeq()
|
|
4
4
|
var m = require('data-matching')
|
|
5
5
|
var sip_msg = require('sip-matching')
|
|
6
6
|
|
|
@@ -89,8 +89,9 @@ async function test() {
|
|
|
89
89
|
var in_file = 'samples/artifacts/this-is-never-ok.tiff'
|
|
90
90
|
var out_file = "received.tiff"
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
sip.call.start_fax(
|
|
92
|
+
// transmit_on_idle: true/true: OK, true/false: OK, false/true: OK, false/false: NG
|
|
93
|
+
sip.call.start_fax(oc.id, {is_sender: true, file: in_file, transmit_on_idle: false})
|
|
94
|
+
sip.call.start_fax(ic.id, {is_sender: false, file: out_file, transmit_on_idle: true})
|
|
94
95
|
|
|
95
96
|
await z.wait([
|
|
96
97
|
{
|
package/samples/simple.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// This test creates 2 UDP SIP endpoints, makes a call between them and disconeects.
|
|
2
2
|
|
|
3
3
|
const sip = require ('../index.js')
|
|
4
|
-
const
|
|
4
|
+
const Zeq = require('@mayama/zeq')
|
|
5
5
|
const m = require('data-matching')
|
|
6
6
|
const sip_msg = require('sip-matching')
|
|
7
7
|
|
|
8
|
-
// here we create our
|
|
9
|
-
var z = new
|
|
8
|
+
// here we create our Zeq instance
|
|
9
|
+
var z = new Zeq()
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
async function test() {
|
|
13
|
-
// here we set our
|
|
13
|
+
// here we set our Zeq instance to trap events generated by sip-lab event_source
|
|
14
14
|
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
15
15
|
var e = evt.args[0]
|
|
16
16
|
return e
|
|
@@ -57,7 +57,7 @@ async function test() {
|
|
|
57
57
|
}),
|
|
58
58
|
},
|
|
59
59
|
], 1000)
|
|
60
|
-
// Details about
|
|
60
|
+
// Details about zeq wait(list_of_events_to_wait_for, timeout_in_ms):
|
|
61
61
|
// The order of events in the list is irrelevant.
|
|
62
62
|
// What matters is that all events arrive within the specified timeout.
|
|
63
63
|
// When specifying events, you can be as detailed or succinct as you need.
|
package/samples/sip_cancel.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var sip = require ('../index.js')
|
|
2
|
-
var
|
|
3
|
-
var z = new
|
|
2
|
+
var Zeq = require('@mayama/zeq')
|
|
3
|
+
var z = new Zeq()
|
|
4
4
|
var m = require('data-matching')
|
|
5
5
|
var sip_msg = require('sip-matching')
|
|
6
6
|
|
|
@@ -280,8 +280,8 @@ async function test() {
|
|
|
280
280
|
},
|
|
281
281
|
], 2000)
|
|
282
282
|
|
|
283
|
-
sip.call.start_playing(oc.id, {file: '/
|
|
284
|
-
sip.call.start_playing(ic.id, {file: '/
|
|
283
|
+
sip.call.start_playing(oc.id, {file: 'samples/artifacts/yosemitesam.wav'})
|
|
284
|
+
sip.call.start_playing(ic.id, {file: 'samples/artifacts/yosemitesam.wav'})
|
|
285
285
|
|
|
286
286
|
await z.sleep(2000)
|
|
287
287
|
|
package/src/Makefile
CHANGED
|
@@ -34,7 +34,7 @@ sip.o: sip.cpp sip.hpp
|
|
|
34
34
|
$(CC) -fPIC -c -o sip.o sip.cpp $(CPPFLAGS)
|
|
35
35
|
|
|
36
36
|
sip.so: sip.o idmanager.o packetdumper.o event_templates.o chainlink
|
|
37
|
-
$(CC) -fPIC -shared -o sip.so sip.o idmanager.o packetdumper.o event_templates.o pjmedia/libchainlink.a -Wl,-E -lm -ldl -
|
|
37
|
+
$(CC) -fPIC -shared -o sip.so sip.o idmanager.o packetdumper.o event_templates.o pjmedia/libchainlink.a 3rdParty/spandsp/src/.libs/libspandsp.a -Wl,-E -lm -ldl -ltiff -lpcap $(CPPFLAGS) $(LDFLAGS) $(LDLIBS)
|
|
38
38
|
|
|
39
39
|
clean:
|
|
40
40
|
rm -f *.o *.so
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
#include <pj/pool.h>
|
|
9
9
|
#include <pj/string.h>
|
|
10
10
|
|
|
11
|
+
#include "siplab_constants.h"
|
|
12
|
+
|
|
11
13
|
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
|
12
14
|
#include <spandsp.h>
|
|
13
15
|
|
|
@@ -23,7 +25,6 @@
|
|
|
23
25
|
#define FAX_DATA_CHUNK 320
|
|
24
26
|
#define T38_DATA_CHUNK 160
|
|
25
27
|
|
|
26
|
-
|
|
27
28
|
enum
|
|
28
29
|
{
|
|
29
30
|
/*! No compression */
|
|
@@ -48,7 +49,6 @@ enum
|
|
|
48
49
|
T30_SUPPORT_T88_COMPRESSION = 0x200
|
|
49
50
|
};
|
|
50
51
|
|
|
51
|
-
|
|
52
52
|
static pj_status_t fax_get_frame(pjmedia_port *this_port,
|
|
53
53
|
pjmedia_frame *frame);
|
|
54
54
|
static pj_status_t fax_put_frame(pjmedia_port *this_port,
|
|
@@ -62,23 +62,24 @@ struct fax_device
|
|
|
62
62
|
void (*fax_cb)(pjmedia_port*, void*, int);
|
|
63
63
|
void *fax_cb_user_data;
|
|
64
64
|
int is_sender;
|
|
65
|
+
bool result_sent;
|
|
65
66
|
|
|
66
67
|
pj_lock_t *lock;
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
static int phase_b_handler(
|
|
70
|
+
static int phase_b_handler(void* user_data, int result)
|
|
70
71
|
{
|
|
71
72
|
printf("fax phase_b_handler user_data=%p result=%i\n", user_data, result);
|
|
72
73
|
return T30_ERR_OK;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
static int phase_d_handler(
|
|
76
|
+
static int phase_d_handler(void* user_data, int result)
|
|
76
77
|
{
|
|
77
78
|
printf("fax phase_b_handler user_data=%p result=%i\n", user_data, result);
|
|
78
79
|
return T30_ERR_OK;
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
static void phase_e_handler(
|
|
82
|
+
static void phase_e_handler(void* user_data, int result)
|
|
82
83
|
{
|
|
83
84
|
printf("fax phase_e_handler user_data=%p result=%i\n", user_data, result);
|
|
84
85
|
|
|
@@ -93,11 +94,13 @@ static void phase_e_handler(t30_state_t* s, void* user_data, int result)
|
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
if(!fd->result_sent) {
|
|
98
|
+
fd->fax_cb((pjmedia_port*)fd, fd->fax_cb_user_data, result);
|
|
99
|
+
fd->result_sent = true;
|
|
100
|
+
}
|
|
98
101
|
}
|
|
99
102
|
|
|
100
|
-
static int document_handler(
|
|
103
|
+
static int document_handler(void* user_data, int result)
|
|
101
104
|
{
|
|
102
105
|
printf("fax document_handler user_data=%p result=%i\n", user_data, result);
|
|
103
106
|
|
|
@@ -106,7 +109,10 @@ static int document_handler(t30_state_t* s, void* user_data, int result)
|
|
|
106
109
|
struct fax_device *fd = (struct fax_device*)user_data;
|
|
107
110
|
if(!fd->fax_cb) return 0;
|
|
108
111
|
|
|
109
|
-
|
|
112
|
+
if(!fd->result_sent) {
|
|
113
|
+
fd->fax_cb((pjmedia_port*)fd, fd->fax_cb_user_data, result);
|
|
114
|
+
fd->result_sent = true;
|
|
115
|
+
}
|
|
110
116
|
|
|
111
117
|
return 0;
|
|
112
118
|
}
|
|
@@ -122,6 +128,7 @@ PJ_DEF(pj_status_t) chainlink_fax_port_create( pj_pool_t *pool,
|
|
|
122
128
|
void *user_data,
|
|
123
129
|
int is_sender,
|
|
124
130
|
const char *file,
|
|
131
|
+
unsigned flags,
|
|
125
132
|
pjmedia_port **p_port)
|
|
126
133
|
{
|
|
127
134
|
struct fax_device *fd;
|
|
@@ -144,7 +151,6 @@ PJ_DEF(pj_status_t) chainlink_fax_port_create( pj_pool_t *pool,
|
|
|
144
151
|
fd->link.port.on_destroy = &fax_on_destroy;
|
|
145
152
|
|
|
146
153
|
fax_init(&fd->fax, is_sender);
|
|
147
|
-
//fax_set_transmit_on_idle(&fd->fax,1);
|
|
148
154
|
|
|
149
155
|
t30_state_t *t30 = fax_get_t30_state(&fd->fax);
|
|
150
156
|
|
|
@@ -161,6 +167,7 @@ PJ_DEF(pj_status_t) chainlink_fax_port_create( pj_pool_t *pool,
|
|
|
161
167
|
t30_set_document_handler(t30, &document_handler, (void*)fd);
|
|
162
168
|
|
|
163
169
|
fd->is_sender = is_sender;
|
|
170
|
+
fd->result_sent = false;
|
|
164
171
|
|
|
165
172
|
pj_status_t status = pj_lock_create_simple_mutex(pool, "fax", &fd->lock);
|
|
166
173
|
|
|
@@ -178,7 +185,9 @@ PJ_DEF(pj_status_t) chainlink_fax_port_create( pj_pool_t *pool,
|
|
|
178
185
|
t30_set_supported_compressions(t30,T30_SUPPORT_T4_1D_COMPRESSION |
|
|
179
186
|
T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
|
|
180
187
|
|
|
181
|
-
|
|
188
|
+
if(flags & FAX_FLAG_TRANSMIT_ON_IDLE) {
|
|
189
|
+
fax_set_transmit_on_idle(&fd->fax, 1);
|
|
190
|
+
}
|
|
182
191
|
|
|
183
192
|
fd->fax_cb = cb;
|
|
184
193
|
fd->fax_cb_user_data = user_data;
|
package/src/sip.cpp
CHANGED
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
|
|
37
37
|
#include "rapidjson/document.h"
|
|
38
38
|
|
|
39
|
+
#include "siplab_constants.h"
|
|
40
|
+
|
|
39
41
|
using namespace rapidjson;
|
|
40
42
|
using namespace std;
|
|
41
43
|
|
|
@@ -159,6 +161,23 @@ bool json_get_int_param(Document &document, const char *param, bool optional, in
|
|
|
159
161
|
return true;
|
|
160
162
|
}
|
|
161
163
|
|
|
164
|
+
bool json_get_uint_param(Document &document, const char *param, bool optional, unsigned *dest) {
|
|
165
|
+
if(!document.HasMember(param)) {
|
|
166
|
+
if(optional) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
set_error("Parameter %s is required", param);
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if(!document[param].IsUint()) {
|
|
174
|
+
set_error("Parameter %s must be an unsigned integer", param);
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
*dest = document[param].GetUint();
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
|
|
162
181
|
bool json_get_bool_param(Document &document, const char *param, bool optional, bool *dest) {
|
|
163
182
|
if(!document.HasMember(param)) {
|
|
164
183
|
if(optional) {
|
|
@@ -478,7 +497,7 @@ bool prepare_tonegen(Call *c);
|
|
|
478
497
|
bool prepare_wav_player(Call *c, const char *file);
|
|
479
498
|
bool prepare_wav_writer(Call *c, const char *file);
|
|
480
499
|
|
|
481
|
-
bool prepare_fax(Call *c, bool is_sender, const char *file);
|
|
500
|
+
bool prepare_fax(Call *c, bool is_sender, const char *file, unsigned flags);
|
|
482
501
|
|
|
483
502
|
void prepare_error_event(ostringstream *oss, char *scope, char *details);
|
|
484
503
|
//void prepare_pjsipcall_error_event(ostringstream *oss, char *scope, char *function, pj_status_t s);
|
|
@@ -2689,6 +2708,8 @@ int pjw_call_start_fax(long call_id, const char *json)
|
|
|
2689
2708
|
|
|
2690
2709
|
bool is_sender;
|
|
2691
2710
|
char *file;
|
|
2711
|
+
unsigned flags = 0;
|
|
2712
|
+
bool flag;
|
|
2692
2713
|
|
|
2693
2714
|
char buffer[MAX_JSON_INPUT];
|
|
2694
2715
|
|
|
@@ -2723,6 +2744,15 @@ int pjw_call_start_fax(long call_id, const char *json)
|
|
|
2723
2744
|
goto out;
|
|
2724
2745
|
}
|
|
2725
2746
|
|
|
2747
|
+
|
|
2748
|
+
flag = false;
|
|
2749
|
+
if(!json_get_bool_param(document, "transmit_on_idle", true, &flag)) {
|
|
2750
|
+
goto out;
|
|
2751
|
+
} else {
|
|
2752
|
+
if(flag) flags |= FAX_FLAG_TRANSMIT_ON_IDLE;
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
|
|
2726
2756
|
status = pjmedia_stream_get_port(call->med_stream,
|
|
2727
2757
|
&stream_port);
|
|
2728
2758
|
if(status != PJ_SUCCESS)
|
|
@@ -2731,7 +2761,7 @@ int pjw_call_start_fax(long call_id, const char *json)
|
|
|
2731
2761
|
goto out;
|
|
2732
2762
|
}
|
|
2733
2763
|
|
|
2734
|
-
if(!prepare_fax(call, is_sender, file)){
|
|
2764
|
+
if(!prepare_fax(call, is_sender, file, flags)){
|
|
2735
2765
|
set_error("prepare_fax failed");
|
|
2736
2766
|
goto out;
|
|
2737
2767
|
}
|
|
@@ -4326,7 +4356,7 @@ bool prepare_wav_writer(Call *c, const char *file) {
|
|
|
4326
4356
|
}
|
|
4327
4357
|
|
|
4328
4358
|
|
|
4329
|
-
bool prepare_fax(Call *c, bool is_sender, const char *file) {
|
|
4359
|
+
bool prepare_fax(Call *c, bool is_sender, const char *file, unsigned flags) {
|
|
4330
4360
|
pj_status_t status;
|
|
4331
4361
|
|
|
4332
4362
|
chainlink *link = (chainlink*)c->fax;
|
|
@@ -4348,6 +4378,7 @@ bool prepare_fax(Call *c, bool is_sender, const char *file) {
|
|
|
4348
4378
|
c,
|
|
4349
4379
|
is_sender,
|
|
4350
4380
|
file,
|
|
4381
|
+
flags,
|
|
4351
4382
|
(pjmedia_port**)&c->fax);
|
|
4352
4383
|
if(status != PJ_SUCCESS) return false;
|
|
4353
4384
|
|
package/install_bcg729.sh
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -o errexit
|
|
4
|
-
set -o nounset
|
|
5
|
-
set -o pipefail
|
|
6
|
-
|
|
7
|
-
if [[ ! -d bcg729 ]]
|
|
8
|
-
then
|
|
9
|
-
git clone https://github.com/MayamaTakeshi/bcg729
|
|
10
|
-
cd bcg729
|
|
11
|
-
git checkout faaa895862165acde6df8add722ba4f85a25007d
|
|
12
|
-
cmake .
|
|
13
|
-
make
|
|
14
|
-
sudo make install
|
|
15
|
-
sudo ldconfig
|
|
16
|
-
fi
|
|
17
|
-
|
|
18
|
-
echo success
|