@babblevoice/projectrtp 2.4.2 → 2.4.5
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/.github/workflows/buildimage.yaml +1 -1
- package/README.md +3 -34
- package/package.json +6 -5
- package/src/projectrtpchannel.cpp +5 -25
- package/src/projectrtpchannel.h +9 -3
- package/src/projectrtpnodemain.cpp +1 -1
- package/test/basictests.js +45 -0
- package/test/interface/projectrtpchannel.js +1 -1
- package/test/interface/projectrtpdtls.js +1 -1
- package/test/interface/projectrtpdtmf.js +241 -174
- package/test/interface/projectrtprecord.js +6 -14
|
@@ -47,7 +47,7 @@ jobs:
|
|
|
47
47
|
- name: Test
|
|
48
48
|
# Use --exit so we don't hang a test on exception
|
|
49
49
|
run: |
|
|
50
|
-
docker run --rm docker.io/tinpotnick/projectrtp:test /bin/sh -c 'npm
|
|
50
|
+
docker run --rm docker.io/tinpotnick/projectrtp:test /bin/sh -c 'npm run github:check'
|
|
51
51
|
|
|
52
52
|
- name: Docker meta
|
|
53
53
|
id: ourdockertags
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# ProjectRTP
|
|
2
2
|
|
|
3
|
+
[](https://github.com/babblevoice/projectrtp/actions/workflows/buildimage.yaml)
|
|
4
|
+
|
|
3
5
|
An RTP node addon which offers functionality to process RTP data streams and mix it. All performance tasks are implemented in C++ and use boost::asio for IO completion ports for high concurrency.
|
|
4
6
|
|
|
5
7
|
ProjectRTP is designed to scale to multiple servers serving other signalling servers. RTP and signalling should be kept separate, and this architecture allows that. It is provided with a proxy server and client to allow for remote nodes.
|
|
@@ -30,21 +32,9 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
|
|
|
30
32
|
|
|
31
33
|
As part of this, we maintain jsdoc documentation to document our public interface to this programme.
|
|
32
34
|
|
|
33
|
-
Only when we release version 1.0.0 will the public API be settled.
|
|
34
|
-
|
|
35
35
|
## Release process
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
2. Update Dockerfile with the new version number
|
|
39
|
-
3. npm test && stress testing
|
|
40
|
-
4. git commit && push
|
|
41
|
-
5. npm publish
|
|
42
|
-
6. docker buildx prune
|
|
43
|
-
7. docker buildx build --platform linux/amd64,linux/arm64 -t tinpotnick/projectrtp:<version> . --push
|
|
44
|
-
8. Git release
|
|
45
|
-
9. Github tag <version>
|
|
46
|
-
|
|
47
|
-
<version> should simply the semantic version number. For late stage test builds this could be <version>betax.
|
|
37
|
+
Releases are managed on GitHub actions. It builds and tests any version.
|
|
48
38
|
|
|
49
39
|
## Docker
|
|
50
40
|
|
|
@@ -102,27 +92,6 @@ has a submodule so (although this is handled inteh Dockerfile if you are buildin
|
|
|
102
92
|
git submodule update --init --recursive
|
|
103
93
|
```
|
|
104
94
|
|
|
105
|
-
### Fedora
|
|
106
|
-
|
|
107
|
-
After installing standard build tools - including g++.
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
dnf install ilbc-devel spandsp-devel boost gnutls libsrtp libsrtp-devel g++
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Ubuntu
|
|
114
|
-
|
|
115
|
-
Build ilbc from the sub module plus install other dependancies.
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
|
|
119
|
-
apt install libboost-dev libboost-system-dev libspandsp-dev gnutls-dev libsrtp2-dev cmake ccache
|
|
120
|
-
|
|
121
|
-
cd libilbc
|
|
122
|
-
cmake . -DCMAKE_INSTALL_LIBDIR=/lib -DCMAKE_INSTALL_INCLUDEDIR=/usr/include; cmake --build .; cmake --install .
|
|
123
|
-
cd ..
|
|
124
|
-
```
|
|
125
|
-
|
|
126
95
|
## Docker/Podman
|
|
127
96
|
|
|
128
97
|
Podman has some shortfalls. Remove and install docker.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babblevoice/projectrtp",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.5",
|
|
4
4
|
"description": "A scalable Node addon RTP server",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"test": "test"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"test": "./node_modules/mocha/bin/_mocha
|
|
12
|
+
"test": "./node_modules/mocha/bin/_mocha test/**/*.js --check-leaks",
|
|
13
|
+
"github:check": "node test/basictests.js; npm update; ./node_modules/mocha/bin/_mocha test/**/*.js --check-leaks --exit",
|
|
13
14
|
"check": "tsc --checkJs --noEmit --target es6 --module commonjs --skipLibCheck *.js test/**/*.js; ./node_modules/eslint/bin/eslint.js ./",
|
|
14
15
|
"docs": "jsdoc -c jsdoc.conf.json ./README.md",
|
|
15
16
|
"stress": "node stress/index.js",
|
|
@@ -24,14 +25,14 @@
|
|
|
24
25
|
},
|
|
25
26
|
"repository": {
|
|
26
27
|
"type": "git",
|
|
27
|
-
"url": "git+https://github.com/
|
|
28
|
+
"url": "git+https://github.com/babblevoice/projectrtp.git"
|
|
28
29
|
},
|
|
29
30
|
"author": "Nick Knight",
|
|
30
31
|
"license": "MIT",
|
|
31
32
|
"bugs": {
|
|
32
|
-
"url": "https://github.com/
|
|
33
|
+
"url": "https://github.com/babblevoice/projectrtp/issues"
|
|
33
34
|
},
|
|
34
|
-
"homepage": "https://github.com/
|
|
35
|
+
"homepage": "https://github.com/babblevoice/projectrtp#readme",
|
|
35
36
|
"dependencies": {
|
|
36
37
|
"uuid": "^9.0.0"
|
|
37
38
|
},
|
|
@@ -652,40 +652,20 @@ bool projectrtpchannel::checkfordtmf( rtppacket *src ) {
|
|
|
652
652
|
uint8_t event = pl[ 0 ] & 0x7f;
|
|
653
653
|
|
|
654
654
|
if( event <= 16 ) {
|
|
655
|
-
bool sendteleevent = false;
|
|
656
|
-
bool start = false;
|
|
657
|
-
|
|
658
655
|
/* Test for start */
|
|
659
|
-
if( 0 == endbit
|
|
660
|
-
0 == this->lasttelephoneeventsn ) {
|
|
661
|
-
start = true;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
if( 0 == endbit &&
|
|
665
|
-
0 != this->lasttelephoneeventsn &&
|
|
666
|
-
event != this->lasttelephoneevent
|
|
667
|
-
) {
|
|
668
|
-
/* Did we lose the last end of event */
|
|
669
|
-
this->lasttelephoneeventsn = 0;
|
|
670
|
-
sendteleevent = true;
|
|
671
|
-
} else if( 1 == endbit &&
|
|
672
|
-
0 != this->lasttelephoneeventsn ) {
|
|
673
|
-
sendteleevent = true;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
if( sendteleevent ) this->sendtelevent();
|
|
677
|
-
|
|
678
|
-
if( start ) {
|
|
656
|
+
if( 0 == endbit ) {
|
|
679
657
|
this->lasttelephoneeventsn = sn;
|
|
680
658
|
this->lasttelephoneevent = event;
|
|
681
|
-
} else if( 1 == endbit
|
|
659
|
+
} else if( 1 == endbit &&
|
|
660
|
+
0 != this->lasttelephoneeventsn ) {
|
|
682
661
|
this->lasttelephoneeventsn = 0;
|
|
662
|
+
this->sendtelevent();
|
|
683
663
|
}
|
|
684
664
|
}
|
|
685
665
|
}
|
|
686
666
|
return true;
|
|
687
667
|
} else if( 0 != this->lasttelephoneeventsn &&
|
|
688
|
-
abs( static_cast< long long int >( sn - this->lasttelephoneeventsn ) ) > MAXDTMFSNDIFFERENCE ) {
|
|
668
|
+
abs( static_cast< long long int > ( sn - this->lasttelephoneeventsn ) ) > MAXDTMFSNDIFFERENCE ) {
|
|
689
669
|
/* timeout on waiting for end packet */
|
|
690
670
|
this->sendtelevent();
|
|
691
671
|
this->lasttelephoneeventsn = 0;
|
package/src/projectrtpchannel.h
CHANGED
|
@@ -40,10 +40,16 @@ class projectchannelmux;
|
|
|
40
40
|
#define OUTBUFFERPACKETCOUNT 16
|
|
41
41
|
|
|
42
42
|
/*
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
The SN difference between receiving the first DTMF EV and when we consider we have lost all end events.
|
|
44
|
+
Delay = MAXDTMFSNDIFFERENCE * 20mS
|
|
45
|
+
|
|
46
|
+
rfc2833 - 3.6: An audio source SHOULD start transmitting event packets as soon as it
|
|
47
|
+
recognizes an event and every 50 ms thereafter or the packet interval
|
|
48
|
+
for the audio codec used for this session, if known.
|
|
49
|
+
This means our ts will not stay in sync with our sequence number - which increments
|
|
50
|
+
with every packet.
|
|
45
51
|
*/
|
|
46
|
-
#define MAXDTMFSNDIFFERENCE
|
|
52
|
+
#define MAXDTMFSNDIFFERENCE 6
|
|
47
53
|
|
|
48
54
|
|
|
49
55
|
/*
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
const prtp = require( "../index.js" )
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Very basic test - to run in release workflow before we install
|
|
7
|
+
* dev dependancies - i.e. check we can run without dev dependancies.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Test open a channel.
|
|
12
|
+
*/
|
|
13
|
+
async function testopen() {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const chan = await prtp.projectrtp.openchannel()
|
|
17
|
+
|
|
18
|
+
try{
|
|
19
|
+
if( !chan ) throw new Error( "Bad channel" )
|
|
20
|
+
if( "number" !== typeof chan.local.port ) throw new Error( "Port doesn't look correct" )
|
|
21
|
+
} finally {
|
|
22
|
+
chan.close()
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let retval = 0
|
|
27
|
+
console.log( "Running project RTP" )
|
|
28
|
+
prtp.projectrtp.run()
|
|
29
|
+
|
|
30
|
+
console.log( "Test open channel" )
|
|
31
|
+
|
|
32
|
+
try{
|
|
33
|
+
testopen()
|
|
34
|
+
} catch( e ) {
|
|
35
|
+
console.log( e )
|
|
36
|
+
retval = 1
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log( "Shutting down projectrtp" )
|
|
40
|
+
prtp.projectrtp.shutdown()
|
|
41
|
+
console.log( "Shutdown - good to proceed" )
|
|
42
|
+
|
|
43
|
+
process.exit( retval )
|
|
44
|
+
|
|
45
|
+
|
|
@@ -437,7 +437,7 @@ describe( "rtpchannel", function() {
|
|
|
437
437
|
expect( closedstats.stats.in.count ).to.equal( 300 )
|
|
438
438
|
expect( closedstats.stats.out.count ).to.be.within( 180, 190 )
|
|
439
439
|
expect( totalsndiff ).to.equal( 0 ) // received should be reordered
|
|
440
|
-
expect( totaltsdiff ).to.
|
|
440
|
+
expect( totaltsdiff ).to.be.within( 18240, 18400 ) // Allow some loss in test
|
|
441
441
|
expect( lastsn - firstsn ).to.be.within( 180, 192 )
|
|
442
442
|
} )
|
|
443
443
|
|
|
@@ -432,7 +432,7 @@ describe( "dtls", function() {
|
|
|
432
432
|
await finished
|
|
433
433
|
|
|
434
434
|
expect( clientcclose.stats.in.count ).to.be.above( 10 )
|
|
435
|
-
expect( clientcclose.stats.in.skip ).to.
|
|
435
|
+
expect( clientcclose.stats.in.skip ).to.be.below( 2 ) // allow a little loss in test
|
|
436
436
|
|
|
437
437
|
} )
|
|
438
438
|
} )
|
|
@@ -24,7 +24,7 @@ function sendpayload( sendtime, pk, dstport, server ) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/* helper functions */
|
|
27
|
-
function sendpk( sn, sendtime, dstport, server, pt = 0,
|
|
27
|
+
function sendpk( sn, ts, sendtime, dstport, server, pt = 0, ssrc ) {
|
|
28
28
|
|
|
29
29
|
if( !ssrc ) ssrc = 25
|
|
30
30
|
const pklength = 172
|
|
@@ -34,8 +34,6 @@ function sendpk( sn, sendtime, dstport, server, pt = 0, ts, ssrc ) {
|
|
|
34
34
|
const payload = Buffer.alloc( pklength - 12 ).fill( projectrtp.codecx.linear162pcmu( sn ) & 0xff )
|
|
35
35
|
const subheader = Buffer.alloc( 10 )
|
|
36
36
|
|
|
37
|
-
if( !ts ) ts = sn * 160
|
|
38
|
-
|
|
39
37
|
subheader.writeUInt8( pt, 1 ) // payload type
|
|
40
38
|
subheader.writeUInt16BE( ( sn ) % ( 2**16 ) )
|
|
41
39
|
subheader.writeUInt32BE( ts, 2 )
|
|
@@ -121,15 +119,15 @@ describe( "dtmf", function() {
|
|
|
121
119
|
|
|
122
120
|
/* send a packet every 20mS x 50 */
|
|
123
121
|
for( let i = 0; 23 > i; i ++ ) {
|
|
124
|
-
sendpk( i, i*20, channel.local.port, server )
|
|
122
|
+
sendpk( i, i*160, i*20, channel.local.port, server )
|
|
125
123
|
}
|
|
126
124
|
|
|
127
|
-
senddtmf( 23, 22
|
|
128
|
-
senddtmf( 24, 22
|
|
129
|
-
senddtmf( 25, 22
|
|
125
|
+
senddtmf( 23, 22*160, 23*20, channel.local.port, server, false, "4" )
|
|
126
|
+
senddtmf( 24, 22*160, 24*20, channel.local.port, server, false, "4" )
|
|
127
|
+
senddtmf( 25, 22*160, 25*20, channel.local.port, server, true, "4" )
|
|
130
128
|
|
|
131
129
|
for( let i = 26; 40 > i; i ++ ) {
|
|
132
|
-
sendpk( i, (i-3)*20, channel.local.port, server )
|
|
130
|
+
sendpk( i, i*160, (i-3)*20, channel.local.port, server )
|
|
133
131
|
}
|
|
134
132
|
|
|
135
133
|
setTimeout( () => channel.close(), 1000 )
|
|
@@ -180,7 +178,7 @@ describe( "dtmf", function() {
|
|
|
180
178
|
|
|
181
179
|
/* send a packet every 20mS x 50 */
|
|
182
180
|
for( let i = 0; 50 > i; i ++ ) {
|
|
183
|
-
sendpk( i, i*20, channel.local.port, server )
|
|
181
|
+
sendpk( i, i*160, i*20, channel.local.port, server )
|
|
184
182
|
}
|
|
185
183
|
|
|
186
184
|
setTimeout( () => channel.dtmf( "#1" ), 400 )
|
|
@@ -239,7 +237,7 @@ describe( "dtmf", function() {
|
|
|
239
237
|
|
|
240
238
|
/* send a packet every 20mS x 70 */
|
|
241
239
|
for( let i = 0; 50 > i; i ++ ) {
|
|
242
|
-
sendpk( i, i*20, channela.local.port, clienta )
|
|
240
|
+
sendpk( i, i*160, i*20, channela.local.port, clienta )
|
|
243
241
|
}
|
|
244
242
|
|
|
245
243
|
await new Promise( ( resolve ) => { setTimeout( () => resolve(), 400 ) } )
|
|
@@ -322,7 +320,7 @@ describe( "dtmf", function() {
|
|
|
322
320
|
|
|
323
321
|
/* send a packet every 20mS x 50 */
|
|
324
322
|
for( let i = 0; 50 > i; i ++ ) {
|
|
325
|
-
sendpk( i, i*20, channela.local.port, clienta )
|
|
323
|
+
sendpk( i, i*160, i*20, channela.local.port, clienta )
|
|
326
324
|
}
|
|
327
325
|
|
|
328
326
|
await new Promise( ( resolve ) => { setTimeout( () => resolve(), 100 ) } )
|
|
@@ -340,7 +338,7 @@ describe( "dtmf", function() {
|
|
|
340
338
|
} )
|
|
341
339
|
|
|
342
340
|
|
|
343
|
-
it( "Send multiple 2833 DTMF and check event", function(
|
|
341
|
+
it( "Send multiple 2833 DTMF and check event", async function() {
|
|
344
342
|
|
|
345
343
|
/* create our RTP/UDP endpoint */
|
|
346
344
|
const server = dgram.createSocket( "udp4" )
|
|
@@ -350,53 +348,58 @@ describe( "dtmf", function() {
|
|
|
350
348
|
this.slow( 2500 )
|
|
351
349
|
|
|
352
350
|
server.bind()
|
|
353
|
-
server.on( "listening",
|
|
351
|
+
await new Promise( ( resolve ) => { server.on( "listening", () => resolve() ) } )
|
|
354
352
|
|
|
355
|
-
|
|
353
|
+
const ourport = server.address().port
|
|
356
354
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
355
|
+
const receivedmessages = []
|
|
356
|
+
const channel = await projectrtp.openchannel( { "remote": { "address": "localhost", "port": ourport, "codec": 0 } }, function( d ) {
|
|
357
|
+
receivedmessages.push( d )
|
|
358
|
+
if( "close" === d.action ) {
|
|
359
|
+
server.close()
|
|
360
|
+
}
|
|
361
|
+
} )
|
|
363
362
|
|
|
364
|
-
|
|
365
|
-
expect( d ).to.deep.include( expectedmessages[ expectedmessagecount ] )
|
|
366
|
-
expectedmessagecount++
|
|
363
|
+
expect( channel.echo() ).to.be.true
|
|
367
364
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
} )
|
|
365
|
+
/* send a packet every 20mS x 50 */
|
|
366
|
+
for( let i = 0; 13 > i; i ++ ) {
|
|
367
|
+
sendpk( i, i*160, i*20, channel.local.port, server )
|
|
368
|
+
}
|
|
373
369
|
|
|
374
|
-
|
|
370
|
+
/* DTMF every 50mS */
|
|
371
|
+
senddtmf( 13, 12*160, 13*20, channel.local.port, server, false, "4" )
|
|
372
|
+
sendpk( 14, 13*160, 13*20, channel.local.port, server )
|
|
373
|
+
sendpk( 15, 14*160, 14*20, channel.local.port, server )
|
|
374
|
+
senddtmf( 16, 14*160, (13*20)+50, channel.local.port, server, false, "4" )
|
|
375
|
+
// Packet loss
|
|
376
|
+
// senddtmf( 15, 12 * 160, 15*20, channel.port, server, true, "4" )
|
|
375
377
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
378
|
+
for( let i = 17; 30 > i; i ++ ) {
|
|
379
|
+
sendpk( i, (i-2)*160, (i-2)*20, channel.local.port, server )
|
|
380
|
+
}
|
|
380
381
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
382
|
+
senddtmf( 31, 29*160, 29*20, channel.local.port, server, false, "5" )
|
|
383
|
+
sendpk( 32, 29*160, 29*20, channel.local.port, server )
|
|
384
|
+
sendpk( 33, 30*160, 30*20, channel.local.port, server )
|
|
385
|
+
senddtmf( 34, 30*160, (29*20)+50, channel.local.port, server, false, "5" )
|
|
386
|
+
sendpk( 35, 31*160, 31*20, channel.local.port, server )
|
|
387
|
+
sendpk( 36, 32*160, 32*20, channel.local.port, server )
|
|
388
|
+
senddtmf( 37, 32*160, (29*20)+100, channel.local.port, server, true, "5" )
|
|
385
389
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
390
|
+
for( let i = 37; 45 > i; i ++ ) {
|
|
391
|
+
sendpk( i, i*160, (i-6)*20, channel.local.port, server )
|
|
392
|
+
}
|
|
389
393
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
senddtmf( 25, 22 * 160, 25*20, channel.local.port, server, true, "5" )
|
|
394
|
+
setTimeout( () => channel.close(), 1100 )
|
|
395
|
+
await new Promise( resolve => { server.on( "close", resolve ) } )
|
|
393
396
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
+
expect( receivedmessages[ 0 ].action ).to.equal( "telephone-event" )
|
|
398
|
+
expect( receivedmessages[ 0 ].event ).to.equal( "4" )
|
|
399
|
+
expect( receivedmessages[ 1 ].action ).to.equal( "telephone-event" )
|
|
400
|
+
expect( receivedmessages[ 1 ].event ).to.equal( "5" )
|
|
401
|
+
expect( receivedmessages[ 2 ].action ).to.equal( "close" )
|
|
397
402
|
|
|
398
|
-
setTimeout( () => channel.close(), 1000 )
|
|
399
|
-
} )
|
|
400
403
|
} )
|
|
401
404
|
|
|
402
405
|
it( "Lose end packet", async function() {
|
|
@@ -432,20 +435,43 @@ describe( "dtmf", function() {
|
|
|
432
435
|
expect( channel.echo() ).to.be.true
|
|
433
436
|
|
|
434
437
|
/* send a packet every 20mS x 50 */
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
438
|
+
sendpk( 0, 160, 0, channel.local.port, server )
|
|
439
|
+
sendpk( 1, 1*160, 1*20, channel.local.port, server )
|
|
440
|
+
sendpk( 2, 2*160, 2*20, channel.local.port, server )
|
|
441
|
+
sendpk( 3, 3*160, 3*20, channel.local.port, server )
|
|
442
|
+
sendpk( 4, 4*160, 4*20, channel.local.port, server )
|
|
443
|
+
sendpk( 5, 5*160, 5*20, channel.local.port, server )
|
|
444
|
+
sendpk( 6, 6*160, 6*20, channel.local.port, server )
|
|
445
|
+
sendpk( 7, 7*160, 7*20, channel.local.port, server )
|
|
446
|
+
sendpk( 8, 8*160, 8*20, channel.local.port, server )
|
|
447
|
+
sendpk( 9, 9*160, 9*20, channel.local.port, server )
|
|
448
|
+
sendpk( 10, 10*160, 10*20, channel.local.port, server )
|
|
449
|
+
sendpk( 11, 11*160, 11*20, channel.local.port, server )
|
|
450
|
+
sendpk( 12, 12*160, 12*20, channel.local.port, server )
|
|
451
|
+
|
|
452
|
+
senddtmf( 13, 13*160, 13*20, channel.local.port, server, false, "4" )
|
|
453
|
+
sendpk( 14, 13*160, 13*20, channel.local.port, server, 0 )
|
|
454
|
+
sendpk( 15, 14*160, 14*20, channel.local.port, server, 0 )
|
|
455
|
+
|
|
456
|
+
senddtmf( 16, (15*160)+10, (15*20)+10, channel.local.port, server, false, "4" )
|
|
457
|
+
sendpk( 17, 15*160, 15*20, channel.local.port, server, 0 )
|
|
458
|
+
sendpk( 18, 16*160, 16*20, channel.local.port, server, 0 )
|
|
441
459
|
// Packet loss
|
|
442
|
-
// senddtmf(
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
460
|
+
// senddtmf( 19, (16*160)+20, (16*20)+20, channel.local.port, server, true, "4" )
|
|
461
|
+
|
|
462
|
+
sendpk( 20, 17*160, 17*20, channel.local.port, server, 0 )
|
|
463
|
+
sendpk( 21, 18*160, 18*20, channel.local.port, server, 0 )
|
|
464
|
+
sendpk( 22, 19*160, 19*20, channel.local.port, server, 0 )
|
|
465
|
+
sendpk( 23, 20*160, 20*20, channel.local.port, server, 0 )
|
|
466
|
+
sendpk( 24, 21*160, 21*20, channel.local.port, server, 0 )
|
|
467
|
+
sendpk( 25, 22*160, 22*20, channel.local.port, server, 0 )
|
|
468
|
+
sendpk( 26, 23*160, 23*20, channel.local.port, server, 0 )
|
|
469
|
+
sendpk( 27, 24*160, 24*20, channel.local.port, server, 0 )
|
|
470
|
+
sendpk( 28, 25*160, 25*20, channel.local.port, server, 0 )
|
|
471
|
+
sendpk( 29, 26*160, 26*20, channel.local.port, server, 0 )
|
|
472
|
+
sendpk( 30, 27*160, 27*20, channel.local.port, server, 0 )
|
|
447
473
|
|
|
448
|
-
setTimeout( () => channel.close(),
|
|
474
|
+
setTimeout( () => channel.close(), 1000 )
|
|
449
475
|
|
|
450
476
|
} )
|
|
451
477
|
|
|
@@ -456,7 +482,7 @@ describe( "dtmf", function() {
|
|
|
456
482
|
{ action: "close" }
|
|
457
483
|
]
|
|
458
484
|
|
|
459
|
-
expect( receviedpkcount ).to.be.above(
|
|
485
|
+
expect( receviedpkcount ).to.be.above( 15 )
|
|
460
486
|
expect( receivedmessages.length ).to.equal( 2 )
|
|
461
487
|
expect( receivedmessages[ 0 ] ).to.deep.include( expectedmessages[ 0 ] )
|
|
462
488
|
expect( receivedmessages[ 1 ] ).to.deep.include( expectedmessages[ 1 ] )
|
|
@@ -521,27 +547,62 @@ describe( "dtmf", function() {
|
|
|
521
547
|
expect( channela.mix( channelb ) ).to.be.true
|
|
522
548
|
|
|
523
549
|
/* send a packet every 20mS x 50 */
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
senddtmf(
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
550
|
+
sendpk( 0, 0, 0, channela.local.port, endpointa )
|
|
551
|
+
sendpk( 1, 1*160, 1*20, channela.local.port, endpointa )
|
|
552
|
+
sendpk( 2, 2*160, 2*20, channela.local.port, endpointa )
|
|
553
|
+
sendpk( 3, 3*160, 3*20, channela.local.port, endpointa )
|
|
554
|
+
sendpk( 4, 4*160, 4*20, channela.local.port, endpointa )
|
|
555
|
+
sendpk( 5, 5*160, 5*20, channela.local.port, endpointa )
|
|
556
|
+
sendpk( 6, 6*160, 6*20, channela.local.port, endpointa )
|
|
557
|
+
sendpk( 7, 7*160, 7*20, channela.local.port, endpointa )
|
|
558
|
+
sendpk( 8, 8*160, 8*20, channela.local.port, endpointa )
|
|
559
|
+
sendpk( 9, 9*160, 9*20, channela.local.port, endpointa )
|
|
560
|
+
sendpk( 10, 10*160, 10*20, channela.local.port, endpointa )
|
|
561
|
+
sendpk( 11, 11*160, 11*20, channela.local.port, endpointa )
|
|
562
|
+
sendpk( 12, 12*160, 12*20, channela.local.port, endpointa )
|
|
563
|
+
|
|
564
|
+
senddtmf( 13, 13*160, 13*20, channela.local.port, endpointa, false, "4" )
|
|
565
|
+
sendpk( 14, 13*160, 13*20, channela.local.port, endpointa, 0 )
|
|
566
|
+
sendpk( 15, 14*160, 14*20, channela.local.port, endpointa, 0 )
|
|
567
|
+
senddtmf( 16, (15*160)+10, (15*20)+10, channela.local.port, endpointa, false, "4" )
|
|
568
|
+
sendpk( 17, 15*160, 15*20, channela.local.port, endpointa, 0 )
|
|
569
|
+
sendpk( 18, 16*160, 16*20, channela.local.port, endpointa, 0 )
|
|
570
|
+
senddtmf( 19, (17*160)+20, (17*20)+20, channela.local.port, endpointa, true, "4" )
|
|
571
|
+
sendpk( 20, 17*160, 17*20, channela.local.port, endpointa, 0 )
|
|
572
|
+
sendpk( 21, 18*160, 18*20, channela.local.port, endpointa, 0 )
|
|
573
|
+
senddtmf( 22, (18*160)+30, (18*20)+30, channela.local.port, endpointa, true, "4" )
|
|
574
|
+
sendpk( 23, 19*160, 19*20, channela.local.port, endpointa, 0 )
|
|
575
|
+
sendpk( 24, 20*160, 20*20, channela.local.port, endpointa, 0 )
|
|
576
|
+
sendpk( 25, 21*160, 21*20, channela.local.port, endpointa, 0 )
|
|
577
|
+
sendpk( 26, 22*160, 22*20, channela.local.port, endpointa, 0 )
|
|
578
|
+
sendpk( 27, 23*160, 23*20, channela.local.port, endpointa, 0 )
|
|
579
|
+
sendpk( 28, 24*160, 24*20, channela.local.port, endpointa, 0 )
|
|
580
|
+
sendpk( 29, 25*160, 25*20, channela.local.port, endpointa, 0 )
|
|
581
|
+
|
|
582
|
+
senddtmf( 30, 26*160, 26*20, channela.local.port, endpointa, false, "5" )
|
|
583
|
+
sendpk( 31, 26*160, 26*20, channela.local.port, endpointa, 0 )
|
|
584
|
+
sendpk( 32, 27*160, 27*20, channela.local.port, endpointa, 0 )
|
|
585
|
+
senddtmf( 33, (27*160)+10, (27*20)+10, channela.local.port, endpointa, false, "5" )
|
|
586
|
+
sendpk( 34, 28*160, 28*20, channela.local.port, endpointa, 0 )
|
|
587
|
+
sendpk( 35, 29*160, 28*20, channela.local.port, endpointa, 0 )
|
|
588
|
+
senddtmf( 36, (28*160)+20, (28*20)+20, channela.local.port, endpointa, true, "5" )
|
|
589
|
+
sendpk( 37, 30*160, 29*20, channela.local.port, endpointa, 0 )
|
|
590
|
+
sendpk( 38, 31*160, 30*20, channela.local.port, endpointa, 0 )
|
|
591
|
+
|
|
592
|
+
senddtmf( 39, (38*160)+30, (30*20)+30, channela.local.port, endpointa, true, "5" )
|
|
593
|
+
sendpk( 40, 32*160, 31*20, channela.local.port, endpointa, 0 )
|
|
594
|
+
sendpk( 41, 33*160, 32*20, channela.local.port, endpointa, 0 )
|
|
595
|
+
|
|
596
|
+
sendpk( 42, 34*160, 33*20, channela.local.port, endpointa, 0 )
|
|
597
|
+
sendpk( 43, 35*160, 34*20, channela.local.port, endpointa, 0 )
|
|
598
|
+
sendpk( 44, 36*160, 35*20, channela.local.port, endpointa, 0 )
|
|
599
|
+
sendpk( 45, 37*160, 36*20, channela.local.port, endpointa, 0 )
|
|
600
|
+
sendpk( 46, 38*160, 37*20, channela.local.port, endpointa, 0 )
|
|
601
|
+
sendpk( 47, 39*160, 38*20, channela.local.port, endpointa, 0 )
|
|
602
|
+
sendpk( 48, 40*160, 39*20, channela.local.port, endpointa, 0 )
|
|
603
|
+
sendpk( 49, 51*160, 40*20, channela.local.port, endpointa, 0 )
|
|
604
|
+
|
|
605
|
+
await new Promise( ( r ) => { setTimeout( () => r(), 1400 ) } )
|
|
545
606
|
|
|
546
607
|
channela.close()
|
|
547
608
|
endpointa.close()
|
|
@@ -551,22 +612,20 @@ describe( "dtmf", function() {
|
|
|
551
612
|
|
|
552
613
|
expect( endpointapkcount ).to.be.within( 30, 51 )
|
|
553
614
|
expect( endpointbpkcount ).to.be.within( 30, 51 )
|
|
554
|
-
expect( dtmfpkcount ).to.
|
|
555
|
-
|
|
556
|
-
const expectedmessages = [
|
|
557
|
-
{ action: "mix", event: "start" },
|
|
558
|
-
{ action: "telephone-event", event: "4" },
|
|
559
|
-
{ action: "telephone-event", event: "5" },
|
|
560
|
-
{ action: "mix", event: "finished" },
|
|
561
|
-
{ action: "close" }
|
|
562
|
-
]
|
|
615
|
+
expect( dtmfpkcount ).to.be.within( 4, 8 )
|
|
563
616
|
|
|
564
617
|
expect( receivedmessages.length ).to.equal( 5 )
|
|
565
|
-
|
|
566
|
-
expect( receivedmessages[
|
|
567
|
-
expect( receivedmessages[
|
|
568
|
-
expect( receivedmessages[
|
|
569
|
-
expect( receivedmessages[
|
|
618
|
+
|
|
619
|
+
expect( receivedmessages[ 0 ].action ).to.equal( "mix" )
|
|
620
|
+
expect( receivedmessages[ 1 ].action ).to.equal( "telephone-event" )
|
|
621
|
+
expect( receivedmessages[ 2 ].action ).to.equal( "telephone-event" )
|
|
622
|
+
expect( receivedmessages[ 3 ].action ).to.equal( "mix" )
|
|
623
|
+
expect( receivedmessages[ 4 ].action ).to.equal( "close" )
|
|
624
|
+
|
|
625
|
+
expect( receivedmessages[ 0 ].event ).to.equal( "start" )
|
|
626
|
+
expect( receivedmessages[ 1 ].event ).to.equal( "4" )
|
|
627
|
+
expect( receivedmessages[ 2 ].event ).to.equal( "5" )
|
|
628
|
+
expect( receivedmessages[ 3 ].event ).to.equal( "finished" )
|
|
570
629
|
|
|
571
630
|
} )
|
|
572
631
|
|
|
@@ -632,9 +691,6 @@ describe( "dtmf", function() {
|
|
|
632
691
|
|
|
633
692
|
const receveiedmessages = []
|
|
634
693
|
|
|
635
|
-
let done
|
|
636
|
-
const finished = new Promise( ( r ) => { done = r } )
|
|
637
|
-
|
|
638
694
|
const channela = await projectrtp.openchannel( { "remote": { "address": "localhost", "port": endpointa.address().port, "codec": 0 } }, function( d ) {
|
|
639
695
|
receveiedmessages.push( d )
|
|
640
696
|
|
|
@@ -648,7 +704,11 @@ describe( "dtmf", function() {
|
|
|
648
704
|
|
|
649
705
|
const channelc = await projectrtp.openchannel( { "remote": { "address": "localhost", "port": endpointc.address().port, "codec": 97 } }, function( d ) {
|
|
650
706
|
expect( d.action).to.not.equal( "telephone-event" )
|
|
651
|
-
if( "close" === d.action )
|
|
707
|
+
if( "close" === d.action ) {
|
|
708
|
+
endpointa.close()
|
|
709
|
+
endpointb.close()
|
|
710
|
+
endpointc.close()
|
|
711
|
+
}
|
|
652
712
|
} )
|
|
653
713
|
|
|
654
714
|
/* mix */
|
|
@@ -657,19 +717,19 @@ describe( "dtmf", function() {
|
|
|
657
717
|
|
|
658
718
|
/* send a packet every 20mS x 50 */
|
|
659
719
|
/* NO FOR LOOPS for explicit readablity of the test */
|
|
660
|
-
sendpk( 0, 0, channela.local.port, endpointa )
|
|
661
|
-
sendpk( 1, 20, channela.local.port, endpointa )
|
|
662
|
-
sendpk( 2, 2*20, channela.local.port, endpointa )
|
|
663
|
-
sendpk( 3, 3*20, channela.local.port, endpointa )
|
|
664
|
-
sendpk( 4, 4*20, channela.local.port, endpointa )
|
|
665
|
-
sendpk( 5, 5*20, channela.local.port, endpointa )
|
|
666
|
-
sendpk( 6, 6*20, channela.local.port, endpointa )
|
|
667
|
-
sendpk( 7, 7*20, channela.local.port, endpointa )
|
|
668
|
-
sendpk( 8, 8*20, channela.local.port, endpointa )
|
|
669
|
-
sendpk( 9, 9*20, channela.local.port, endpointa )
|
|
670
|
-
sendpk( 10, 10*20, channela.local.port, endpointa )
|
|
671
|
-
sendpk( 11, 11*20, channela.local.port, endpointa )
|
|
672
|
-
sendpk( 12, 12*20, channela.local.port, endpointa )
|
|
720
|
+
sendpk( 0, 0, 0, channela.local.port, endpointa )
|
|
721
|
+
sendpk( 1, 1*160, 20, channela.local.port, endpointa )
|
|
722
|
+
sendpk( 2, 2*160, 2*20, channela.local.port, endpointa )
|
|
723
|
+
sendpk( 3, 3*160, 3*20, channela.local.port, endpointa )
|
|
724
|
+
sendpk( 4, 4*160, 4*20, channela.local.port, endpointa )
|
|
725
|
+
sendpk( 5, 5*160, 5*20, channela.local.port, endpointa )
|
|
726
|
+
sendpk( 6, 6*160, 6*20, channela.local.port, endpointa )
|
|
727
|
+
sendpk( 7, 7*160, 7*20, channela.local.port, endpointa )
|
|
728
|
+
sendpk( 8, 8*160, 8*20, channela.local.port, endpointa )
|
|
729
|
+
sendpk( 9, 9*160, 9*20, channela.local.port, endpointa )
|
|
730
|
+
sendpk( 10, 10*160, 10*20, channela.local.port, endpointa )
|
|
731
|
+
sendpk( 11, 11*160, 11*20, channela.local.port, endpointa )
|
|
732
|
+
sendpk( 12, 12*160, 12*20, channela.local.port, endpointa )
|
|
673
733
|
|
|
674
734
|
/* rfc2833 - 3.6: An audio source SHOULD start transmitting event packets as soon as it
|
|
675
735
|
recognizes an event and every 50 ms thereafter or the packet interval
|
|
@@ -678,57 +738,64 @@ describe( "dtmf", function() {
|
|
|
678
738
|
with every packet.
|
|
679
739
|
senddtmf( sn, ts, sendtime, port, socket, endofevent, event )
|
|
680
740
|
sendpk( sn, sendtime, port, socket, pt, ts, ssrc ) */
|
|
681
|
-
senddtmf( 13,
|
|
682
|
-
sendpk( 14, 13*20, channela.local.port, endpointa, 0
|
|
683
|
-
|
|
684
|
-
sendpk( 16,
|
|
685
|
-
senddtmf( 17,
|
|
686
|
-
|
|
687
|
-
sendpk(
|
|
688
|
-
|
|
689
|
-
sendpk(
|
|
690
|
-
sendpk(
|
|
691
|
-
sendpk(
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
sendpk(
|
|
695
|
-
|
|
696
|
-
sendpk(
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
sendpk(
|
|
701
|
-
sendpk(
|
|
702
|
-
|
|
703
|
-
sendpk(
|
|
704
|
-
sendpk(
|
|
705
|
-
|
|
706
|
-
sendpk(
|
|
707
|
-
sendpk(
|
|
708
|
-
sendpk(
|
|
709
|
-
|
|
710
|
-
sendpk(
|
|
711
|
-
sendpk(
|
|
712
|
-
sendpk(
|
|
713
|
-
sendpk(
|
|
714
|
-
sendpk(
|
|
715
|
-
sendpk(
|
|
716
|
-
sendpk(
|
|
717
|
-
sendpk(
|
|
718
|
-
sendpk(
|
|
719
|
-
sendpk(
|
|
720
|
-
sendpk(
|
|
721
|
-
sendpk(
|
|
722
|
-
sendpk(
|
|
741
|
+
senddtmf( 13, 13*160, 13*20, channela.local.port, endpointa, false, "4" )
|
|
742
|
+
sendpk( 14, 13*160, 13*20, channela.local.port, endpointa, 0 )
|
|
743
|
+
sendpk( 15, 14*160, 14*20, channela.local.port, endpointa, 0 )
|
|
744
|
+
sendpk( 16, 15*160, 15*20, channela.local.port, endpointa, 0 )
|
|
745
|
+
senddtmf( 17, (15*160), (13*20)+50, channela.local.port, endpointa, false, "4" )
|
|
746
|
+
sendpk( 18, 16*160, 16*20, channela.local.port, endpointa, 0 )
|
|
747
|
+
sendpk( 19, 17*160, 17*20, channela.local.port, endpointa, 0 )
|
|
748
|
+
senddtmf( 20, (17*160), (13*20)+100, channela.local.port, endpointa, true, "4" )
|
|
749
|
+
sendpk( 21, 18*160, 18*20, channela.local.port, endpointa, 0 )
|
|
750
|
+
sendpk( 22, 19*160, 19*20, channela.local.port, endpointa, 0 )
|
|
751
|
+
sendpk( 23, 20*160, 20*20, channela.local.port, endpointa, 0 )
|
|
752
|
+
senddtmf( 24, (20*160), (13*20)+150, channela.local.port, endpointa, true, "4" )
|
|
753
|
+
sendpk( 25, 21*160, 21*20, channela.local.port, endpointa, 0 )
|
|
754
|
+
sendpk( 26, 22*160, 22*20, channela.local.port, endpointa, 0 )
|
|
755
|
+
sendpk( 27, 23*160, 23*20, channela.local.port, endpointa, 0 )
|
|
756
|
+
sendpk( 28, 24*160, 24*20, channela.local.port, endpointa, 0 )
|
|
757
|
+
sendpk( 29, 25*160, 25*20, channela.local.port, endpointa, 0 )
|
|
758
|
+
|
|
759
|
+
senddtmf( 30, 25*160, 25*20, channela.local.port, endpointa, false, "5" )
|
|
760
|
+
sendpk( 31, 26*160, 26*20, channela.local.port, endpointa, 0 )
|
|
761
|
+
sendpk( 32, 27*160, 27*20, channela.local.port, endpointa, 0 )
|
|
762
|
+
senddtmf( 33, (27*160), (25*20)+50, channela.local.port, endpointa, false, "5" )
|
|
763
|
+
sendpk( 34, 28*160, 28*20, channela.local.port, endpointa, 0 )
|
|
764
|
+
sendpk( 35, 29*160, 29*20, channela.local.port, endpointa, 0 )
|
|
765
|
+
senddtmf( 36, (29*160), (25*20)+100, channela.local.port, endpointa, true, "5" )
|
|
766
|
+
sendpk( 37, 30*160, 30*20, channela.local.port, endpointa, 0 )
|
|
767
|
+
sendpk( 38, 31*160, 31*20, channela.local.port, endpointa, 0 )
|
|
768
|
+
sendpk( 39, 32*160, 32*20, channela.local.port, endpointa, 0 )
|
|
769
|
+
senddtmf( 40, (32*160), (25*20)+150, channela.local.port, endpointa, true, "5" )
|
|
770
|
+
sendpk( 41, 33*160, 33*20, channela.local.port, endpointa, 0 )
|
|
771
|
+
sendpk( 42, 34*160, 34*20, channela.local.port, endpointa, 0 )
|
|
772
|
+
sendpk( 43, 35*160, 35*20, channela.local.port, endpointa, 0 )
|
|
773
|
+
sendpk( 44, 36*160, 36*20, channela.local.port, endpointa, 0 )
|
|
774
|
+
sendpk( 45, 37*160, 37*20, channela.local.port, endpointa, 0 )
|
|
775
|
+
sendpk( 46, 38*160, 38*20, channela.local.port, endpointa, 0 )
|
|
776
|
+
sendpk( 47, 39*160, 39*20, channela.local.port, endpointa, 0 )
|
|
777
|
+
sendpk( 48, 40*160, 40*20, channela.local.port, endpointa, 0 )
|
|
778
|
+
sendpk( 49, 41*160, 41*20, channela.local.port, endpointa, 0 )
|
|
779
|
+
sendpk( 50, 42*160, 42*20, channela.local.port, endpointa, 0 )
|
|
780
|
+
sendpk( 51, 43*160, 43*20, channela.local.port, endpointa, 0 )
|
|
781
|
+
sendpk( 52, 44*160, 44*20, channela.local.port, endpointa, 0 )
|
|
782
|
+
sendpk( 53, 45*160, 45*20, channela.local.port, endpointa, 0 )
|
|
783
|
+
sendpk( 54, 46*160, 46*20, channela.local.port, endpointa, 0 )
|
|
784
|
+
sendpk( 55, 47*160, 47*20, channela.local.port, endpointa, 0 )
|
|
785
|
+
sendpk( 56, 48*160, 48*20, channela.local.port, endpointa, 0 )
|
|
786
|
+
sendpk( 57, 49*160, 49*20, channela.local.port, endpointa, 0 )
|
|
787
|
+
sendpk( 58, 50*160, 50*20, channela.local.port, endpointa, 0 )
|
|
788
|
+
sendpk( 59, 52*160, 51*20, channela.local.port, endpointa, 0 )
|
|
723
789
|
|
|
724
790
|
await new Promise( ( resolve ) => { setTimeout( () => resolve(), 1200 ) } )
|
|
725
791
|
|
|
726
792
|
channela.close()
|
|
727
|
-
endpointa.close()
|
|
728
|
-
endpointb.close()
|
|
729
|
-
endpointc.close()
|
|
730
793
|
|
|
731
|
-
await
|
|
794
|
+
await Promise.all( [
|
|
795
|
+
new Promise( resolve => { endpointa.on( "close", resolve ) } ),
|
|
796
|
+
new Promise( resolve => { endpointb.on( "close", resolve ) } ),
|
|
797
|
+
new Promise( resolve => { endpointc.on( "close", resolve ) } )
|
|
798
|
+
] )
|
|
732
799
|
|
|
733
800
|
expect( endpointapkcount ).to.be.within( 59, 70 )
|
|
734
801
|
expect( endpointbpkcount ).to.be.within( 59, 70 )
|
|
@@ -736,8 +803,8 @@ describe( "dtmf", function() {
|
|
|
736
803
|
|
|
737
804
|
// 3 after we return to the event loop and enter the callback with close event.
|
|
738
805
|
expect( dtmfapkcount ).to.equal( 0 )
|
|
739
|
-
expect( dtmfbpkcount ).to.
|
|
740
|
-
expect( dtmfcpkcount ).to.
|
|
806
|
+
expect( dtmfbpkcount ).to.be.within( 4, 8 )
|
|
807
|
+
expect( dtmfcpkcount ).to.be.within( 4, 8 )
|
|
741
808
|
|
|
742
809
|
expect( receveiedmessages[ 0 ].action ).to.equal( "mix" )
|
|
743
810
|
expect( receveiedmessages[ 1 ].action ).to.equal( "mix" )
|
|
@@ -792,29 +859,29 @@ describe( "dtmf", function() {
|
|
|
792
859
|
|
|
793
860
|
// Event "3"
|
|
794
861
|
const dstport = channel.local.port
|
|
795
|
-
sendpk( 948, 0, dstport, server, 0,
|
|
862
|
+
sendpk( 948, 148480, 0, dstport, server, 0, 518218235 )
|
|
796
863
|
sendpayload( 20, fromstr( "80 e5 03 b5 00 02 44 a0 1e e3 61 fb 03 0a 00 a0 4c d1" ), dstport, server )
|
|
797
|
-
sendpk( 950, 40, dstport, server, 0,
|
|
864
|
+
sendpk( 950, 148800, 40, dstport, server, 0, 518218235 )
|
|
798
865
|
sendpayload( 60, fromstr( "80 65 03 b7 00 02 44 a0 1e e3 61 fb 03 0a 01 40 25 b8" ), dstport, server )
|
|
799
|
-
sendpk( 952, 80, dstport, server, 0,
|
|
866
|
+
sendpk( 952, 149120, 80, dstport, server, 0, 518218235 )
|
|
800
867
|
sendpayload( 100, fromstr( "80 65 03 b9 00 02 44 a0 1e e3 61 fb 03 0a 01 e0 e8 81" ), dstport, server )
|
|
801
|
-
sendpk( 954, 120, dstport, server, 0,
|
|
868
|
+
sendpk( 954, 149440,120, dstport, server, 0, 518218235 )
|
|
802
869
|
sendpayload( 140, fromstr( "80 65 03 bb 00 02 44 a0 1e e3 61 fb 03 0a 02 80 e2 74" ), dstport, server )
|
|
803
|
-
sendpk( 956, 160, dstport, server, 0,
|
|
870
|
+
sendpk( 956, 149760, 160, dstport, server, 0, 518218235 )
|
|
804
871
|
sendpayload( 180, fromstr( "80 65 03 bd 00 02 44 a0 1e e3 61 fb 03 0a 03 20 1f bb" ), dstport, server )
|
|
805
|
-
sendpk( 958, 200, dstport, server, 0,
|
|
872
|
+
sendpk( 958, 150080, 200, dstport, server, 0, 518218235 )
|
|
806
873
|
sendpayload( 220, fromstr( "80 65 03 bf 00 02 44 a0 1e e3 61 fb 03 0a 03 c0 13 0c" ), dstport, server )
|
|
807
|
-
sendpk( 960, 240, dstport, server, 0,
|
|
874
|
+
sendpk( 960, 150400,240, dstport, server, 0, 518218235 )
|
|
808
875
|
sendpayload( 260, fromstr( "80 65 03 c1 00 02 44 a0 1e e3 61 fb 03 0a 04 60 2e bf" ), dstport, server )
|
|
809
|
-
sendpk( 962, 280, dstport, server, 0,
|
|
876
|
+
sendpk( 962, 150720, 280, dstport, server, 0, 518218235 )
|
|
810
877
|
sendpayload( 300, fromstr( "80 65 03 c3 00 02 44 a0 1e e3 61 fb 03 8a 04 60 05 c1" ), dstport, server )
|
|
811
878
|
sendpayload( 320 ,fromstr( "80 65 03 c4 00 02 44 a0 1e e3 61 fb 03 8a 04 60 bb 69" ), dstport, server )
|
|
812
|
-
sendpk( 965, 340, dstport, server, 0,
|
|
879
|
+
sendpk( 965, 151200, 340, dstport, server, 0, 518218235 )
|
|
813
880
|
sendpayload( 360, fromstr( "80 65 03 c6 00 02 44 a0 1e e3 61 fb 03 8a 04 60 1e 27" ), dstport, server )
|
|
814
|
-
sendpk( 967, 380, dstport, server, 0,
|
|
815
|
-
sendpk( 968, 400, dstport, server, 0,
|
|
816
|
-
sendpk( 969, 420, dstport, server, 0,
|
|
817
|
-
sendpk( 970, 440, dstport, server, 0,
|
|
881
|
+
sendpk( 967, 151520, 380, dstport, server, 0, 518218235 )
|
|
882
|
+
sendpk( 968, 151680, 400, dstport, server, 0, 518218235 )
|
|
883
|
+
sendpk( 969, 151840, 420, dstport, server, 0, 518218235 )
|
|
884
|
+
sendpk( 970, 152000, 440, dstport, server, 0, 518218235 )
|
|
818
885
|
|
|
819
886
|
setTimeout( () => channel.close(), 25*20 )
|
|
820
887
|
} )
|
|
@@ -90,6 +90,7 @@ describe( "record", function() {
|
|
|
90
90
|
|
|
91
91
|
await new Promise( ( resolve ) => { setTimeout( () => resolve(), 1300 ) } )
|
|
92
92
|
channel.close()
|
|
93
|
+
await new Promise( resolve => { server.on( "close", resolve ) } )
|
|
93
94
|
|
|
94
95
|
/* Now test the file */
|
|
95
96
|
const wavinfo = prtp.projectrtp.soundfile.info( "/tmp/ourrecording.wav" )
|
|
@@ -135,9 +136,6 @@ describe( "record", function() {
|
|
|
135
136
|
|
|
136
137
|
server.bind()
|
|
137
138
|
|
|
138
|
-
let done
|
|
139
|
-
const finished = new Promise( ( r ) => { done = r } )
|
|
140
|
-
|
|
141
139
|
let expectedmessagecount = 0
|
|
142
140
|
const expectedmessages = [
|
|
143
141
|
{ action: "record", file: "/tmp/ourstoppedrecording.wav", event: "recording" },
|
|
@@ -151,7 +149,6 @@ describe( "record", function() {
|
|
|
151
149
|
expect( d ).to.deep.include( expectedmessages[ expectedmessagecount ] )
|
|
152
150
|
expectedmessagecount++
|
|
153
151
|
if( "close" === d.action ) {
|
|
154
|
-
done()
|
|
155
152
|
server.close()
|
|
156
153
|
}
|
|
157
154
|
} )
|
|
@@ -175,7 +172,7 @@ describe( "record", function() {
|
|
|
175
172
|
|
|
176
173
|
await new Promise( ( resolve ) => { setTimeout( () => resolve(), 1300 ) } )
|
|
177
174
|
channel.close()
|
|
178
|
-
await
|
|
175
|
+
await new Promise( resolve => { server.on( "close", resolve ) } )
|
|
179
176
|
|
|
180
177
|
/* Now test the file */
|
|
181
178
|
const wavinfo = prtp.projectrtp.soundfile.info( "/tmp/ourstoppedrecording.wav" )
|
|
@@ -203,16 +200,12 @@ describe( "record", function() {
|
|
|
203
200
|
this.timeout( 1500 )
|
|
204
201
|
this.slow( 1200 )
|
|
205
202
|
|
|
206
|
-
let done
|
|
207
|
-
const finished = new Promise( ( r ) => { done = r } )
|
|
208
|
-
|
|
209
203
|
server.bind()
|
|
210
204
|
server.on( "listening", async function() {
|
|
211
205
|
|
|
212
206
|
channel = await prtp.projectrtp.openchannel( { "remote": { "address": "localhost", "port": server.address().port, "codec": 0 } }, function( d ) {
|
|
213
207
|
if( "close" === d.action ) {
|
|
214
208
|
server.close()
|
|
215
|
-
done()
|
|
216
209
|
}
|
|
217
210
|
} )
|
|
218
211
|
|
|
@@ -238,8 +231,7 @@ describe( "record", function() {
|
|
|
238
231
|
|
|
239
232
|
await new Promise( ( r ) => { setTimeout( () => r(), 1300 ) } )
|
|
240
233
|
channel.close()
|
|
241
|
-
|
|
242
|
-
await finished
|
|
234
|
+
await new Promise( resolve => { server.on( "close", resolve ) } )
|
|
243
235
|
|
|
244
236
|
/* Now test the file */
|
|
245
237
|
const wavinfo = prtp.projectrtp.soundfile.info( "/tmp/ourpausedrecording.wav" )
|
|
@@ -248,12 +240,12 @@ describe( "record", function() {
|
|
|
248
240
|
expect( wavinfo.samplerate ).to.equal( 8000 )
|
|
249
241
|
expect( wavinfo.byterate ).to.equal( 32000 )
|
|
250
242
|
expect( wavinfo.bitdepth ).to.equal( 16 )
|
|
251
|
-
expect( wavinfo.chunksize ).to.be.within(
|
|
243
|
+
expect( wavinfo.chunksize ).to.be.within( 2500, 7000 ) /* 200mS of audio */
|
|
252
244
|
expect( wavinfo.fmtchunksize ).to.equal( 16 )
|
|
253
|
-
expect( wavinfo.subchunksize ).to.be.within(
|
|
245
|
+
expect( wavinfo.subchunksize ).to.be.within( 2500, 7000 )
|
|
254
246
|
|
|
255
247
|
const stats = fs.statSync( "/tmp/ourpausedrecording.wav" )
|
|
256
|
-
expect( stats.size ).to.be.within(
|
|
248
|
+
expect( stats.size ).to.be.within( 2500, 7000 )
|
|
257
249
|
|
|
258
250
|
} )
|
|
259
251
|
|