@babblevoice/projectrtp 2.4.0 → 2.4.2

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/.dockerignore ADDED
@@ -0,0 +1,13 @@
1
+
2
+ .git
3
+ .github
4
+ .gitmodules
5
+ .vscode
6
+ .eslintrc.js
7
+ .gitignore
8
+
9
+ Dockerfile
10
+
11
+ node_modules
12
+ libilbc
13
+ out
@@ -6,13 +6,11 @@ on:
6
6
  push:
7
7
  branches:
8
8
  - 'main'
9
- - 'dev'
10
9
  tags:
11
10
  - 'v*.*.*'
12
11
  pull_request:
13
12
  branches:
14
13
  - 'main'
15
- - 'dev'
16
14
 
17
15
  #GH
18
16
  permissions:
@@ -27,17 +25,30 @@ jobs:
27
25
  uses: actions/checkout@v3
28
26
  # https://github.com/docker/setup-qemu-action
29
27
  - name: Set up QEMU
30
- uses: docker/setup-qemu-action@v1
28
+ uses: docker/setup-qemu-action@v2
31
29
  # https://github.com/docker/setup-buildx-action
32
30
  - name: Set up Docker Buildx
33
31
  id: buildx
34
- uses: docker/setup-buildx-action@v2
32
+ uses: docker/setup-buildx-action@v2
35
33
  - name: Login to Docker Hub
36
34
  if: github.event_name != 'pull_request'
37
35
  uses: docker/login-action@v2
38
36
  with:
39
37
  username: ${{ secrets.DOCKERHUB_USERNAME }}
40
38
  password: ${{ secrets.DOCKERHUB_TOKEN }}
39
+
40
+ - name: Build and export to Docker
41
+ uses: docker/build-push-action@v4
42
+ with:
43
+ context: .
44
+ load: true
45
+ tags: docker.io/tinpotnick/projectrtp:test
46
+
47
+ - name: Test
48
+ # Use --exit so we don't hang a test on exception
49
+ run: |
50
+ docker run --rm docker.io/tinpotnick/projectrtp:test /bin/sh -c 'npm update;./node_modules/mocha/bin/_mocha --recursive --check-leaks --exit'
51
+
41
52
  - name: Docker meta
42
53
  id: ourdockertags
43
54
  uses: docker/metadata-action@v3
@@ -56,7 +67,7 @@ jobs:
56
67
  type=sha
57
68
 
58
69
  - name: Build and push
59
- uses: docker/build-push-action@v2
70
+ uses: docker/build-push-action@v4
60
71
  with:
61
72
  context: .
62
73
  platforms: linux/amd64,linux/arm64
package/Dockerfile CHANGED
@@ -1,13 +1,13 @@
1
1
 
2
2
  # docker build . -t <your username>/projectrtp
3
3
  # I have tied this to version alpine 3.16 as 3.17 has an exception symbol dynamic linking issue.
4
- FROM node:18-alpine3.16 as builder
4
+ FROM alpine:3.16 as builder
5
5
 
6
6
 
7
7
  WORKDIR /usr/src/
8
8
 
9
9
  RUN apk add --no-cache \
10
- alpine-sdk cmake python3 spandsp-dev tiff-dev gnutls-dev libsrtp-dev cmake boost-dev; \
10
+ alpine-sdk cmake python3 spandsp-dev tiff-dev gnutls-dev libsrtp-dev cmake boost-dev nodejs npm; \
11
11
  npm -g install node-gyp; \
12
12
  wget https://github.com/TimothyGu/libilbc/releases/download/v3.0.4/libilbc-3.0.4.tar.gz; \
13
13
  tar xvzf libilbc-3.0.4.tar.gz; \
@@ -15,15 +15,15 @@ RUN apk add --no-cache \
15
15
  cmake . -DCMAKE_INSTALL_LIBDIR=/lib -DCMAKE_INSTALL_INCLUDEDIR=/usr/include; cmake --build .; cmake --install .;
16
16
 
17
17
  WORKDIR /usr/local/lib/node_modules/@babblevoice/projectrtp/
18
-
19
18
  COPY . .
20
- RUN npm run rebuild
21
19
 
20
+ RUN npm ci --no-optional --production;\
21
+ rm -fr src/build/Release/obj.target
22
22
 
23
- FROM node:18-alpine as app
23
+ FROM alpine:3.16 as app
24
24
 
25
25
  RUN apk add --no-cache \
26
- spandsp tiff gnutls libsrtp libc6-compat openssl ca-certificates
26
+ spandsp tiff gnutls libsrtp libc6-compat openssl ca-certificates nodejs npm
27
27
 
28
28
  COPY --from=builder /usr/local/lib/node_modules/@babblevoice/projectrtp/ /usr/local/lib/node_modules/@babblevoice/projectrtp/
29
29
  COPY --from=builder /lib/libilbc* /lib/
package/lib/node.js CHANGED
@@ -117,7 +117,7 @@ class rtpnode {
117
117
  * @returns { void }
118
118
  */
119
119
  _onsocketconnect( /* sock */ ) {
120
- console.log( "Connected to " + this.host + ":" + this.port )
120
+ //console.log( "Connected to " + this.host + ":" + this.port )
121
121
  this.send( {}, this.connection )
122
122
  this._onsocketreadypromiseresolve( this )
123
123
  this._reconnecttime = 500 /* mS */
package/lib/server.js CHANGED
@@ -267,7 +267,7 @@ class channel {
267
267
  if( "function" == typeof options ) {
268
268
  cb = options
269
269
  options = {}
270
- }
270
+ } else if ( !options ) options = {}
271
271
 
272
272
  options.channel = "open"
273
273
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/projectrtp",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "A scalable Node addon RTP server",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -33,9 +33,7 @@
33
33
  },
34
34
  "homepage": "https://github.com/tinpotnick/projectrtp#readme",
35
35
  "dependencies": {
36
- "eslint": "^8.29.0",
37
- "jsdoc": "^4.0.0",
38
- "uuid": "^8.3.2"
36
+ "uuid": "^9.0.0"
39
37
  },
40
38
  "keywords": [
41
39
  "RTP",
@@ -49,6 +47,8 @@
49
47
  "@types/mocha": "^10.0.1",
50
48
  "@types/uuid": "^9.0.0",
51
49
  "chai": "^4.3.7",
52
- "mocha": "^10.2.0"
50
+ "mocha": "^10.2.0",
51
+ "eslint": "^8.29.0",
52
+ "jsdoc": "^4.0.0"
53
53
  }
54
54
  }
@@ -656,25 +656,70 @@ describe( "dtmf", function() {
656
656
  expect( channela.mix( channelc ) ).to.be.true
657
657
 
658
658
  /* send a packet every 20mS x 50 */
659
- for( let i = 0; 13 > i; i ++ ) {
660
- sendpk( i, i*20, channela.local.port, endpointa )
661
- }
662
-
659
+ /* 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 )
673
+
674
+ /* rfc2833 - 3.6: An audio source SHOULD start transmitting event packets as soon as it
675
+ recognizes an event and every 50 ms thereafter or the packet interval
676
+ for the audio codec used for this session, if known.
677
+ This means our ts will not stay in sync with our sequence number - which increments
678
+ with every packet.
679
+ senddtmf( sn, ts, sendtime, port, socket, endofevent, event )
680
+ sendpk( sn, sendtime, port, socket, pt, ts, ssrc ) */
663
681
  senddtmf( 13, 12 * 160, 13*20, channela.local.port, endpointa, false, "4" )
664
- senddtmf( 14, 12 * 160, 14*20, channela.local.port, endpointa, false, "4" )
665
- senddtmf( 15, 12 * 160, 15*20, channela.local.port, endpointa, true, "4" )
666
-
667
- for( let i = 16; 23 > i; i ++ ) {
668
- sendpk( i, (i-3)*20, channela.local.port, endpointa )
669
- }
670
-
671
- senddtmf( 23, 22 * 160, 23*20, channela.local.port, endpointa, false, "5" )
672
- senddtmf( 24, 22 * 160, 24*20, channela.local.port, endpointa, false, "5" )
673
- senddtmf( 25, 22 * 160, 25*20, channela.local.port, endpointa, true, "5" )
674
-
675
- for( let i = 26; 50 > i; i ++ ) {
676
- sendpk( i, (i-6)*20, channela.local.port, endpointa )
677
- }
682
+ sendpk( 14, 13*20, channela.local.port, endpointa, 0, 13*160 )
683
+ senddtmf( 15, 15 * 160, 15*20, channela.local.port, endpointa, false, "4" )
684
+ sendpk( 16, 14*20, channela.local.port, endpointa, 0, 14*160 )
685
+ senddtmf( 17, 17 * 160, 17*20, channela.local.port, endpointa, true, "4" )
686
+
687
+ sendpk( 18, 15*20, channela.local.port, endpointa, 0, 15*160 )
688
+ sendpk( 19, 16*20, channela.local.port, endpointa, 0, 16*160 )
689
+ sendpk( 20, 17*20, channela.local.port, endpointa, 0, 17*160 )
690
+ sendpk( 21, 18*20, channela.local.port, endpointa, 0, 18*160 )
691
+ sendpk( 22, 19*20, channela.local.port, endpointa, 0, 19*160 )
692
+
693
+ senddtmf( 23, 20*160, 20*20, channela.local.port, endpointa, false, "5" )
694
+ sendpk( 24, 20*20, channela.local.port, endpointa, 0, 20*160 )
695
+ senddtmf( 25, 22*160, 21*20, channela.local.port, endpointa, false, "5" )
696
+ sendpk( 26, 21*20, channela.local.port, endpointa, 0, 21*160 )
697
+ senddtmf( 27, 24*160, 22*20, channela.local.port, endpointa, true, "5" )
698
+
699
+ sendpk( 27, 22*20, channela.local.port, endpointa, 0, 22*160 )
700
+ sendpk( 28, 23*20, channela.local.port, endpointa, 0, 23*160 )
701
+ sendpk( 29, 24*20, channela.local.port, endpointa, 0, 24*160 )
702
+ sendpk( 30, 25*20, channela.local.port, endpointa, 0, 25*160 )
703
+ sendpk( 31, 26*20, channela.local.port, endpointa, 0, 26*160 )
704
+ sendpk( 32, 27*20, channela.local.port, endpointa, 0, 27*160 )
705
+ sendpk( 33, 28*20, channela.local.port, endpointa, 0, 28*160 )
706
+ sendpk( 34, 29*20, channela.local.port, endpointa, 0, 29*160 )
707
+ sendpk( 35, 30*20, channela.local.port, endpointa, 0, 30*160 )
708
+ sendpk( 36, 31*20, channela.local.port, endpointa, 0, 31*160 )
709
+ sendpk( 37, 32*20, channela.local.port, endpointa, 0, 32*160 )
710
+ sendpk( 38, 33*20, channela.local.port, endpointa, 0, 33*160 )
711
+ sendpk( 39, 34*20, channela.local.port, endpointa, 0, 34*160 )
712
+ sendpk( 40, 35*20, channela.local.port, endpointa, 0, 35*160 )
713
+ sendpk( 41, 36*20, channela.local.port, endpointa, 0, 36*160 )
714
+ sendpk( 42, 37*20, channela.local.port, endpointa, 0, 37*160 )
715
+ sendpk( 43, 38*20, channela.local.port, endpointa, 0, 38*160 )
716
+ sendpk( 44, 39*20, channela.local.port, endpointa, 0, 39*160 )
717
+ sendpk( 45, 40*20, channela.local.port, endpointa, 0, 40*160 )
718
+ sendpk( 46, 41*20, channela.local.port, endpointa, 0, 41*160 )
719
+ sendpk( 47, 42*20, channela.local.port, endpointa, 0, 42*160 )
720
+ sendpk( 48, 43*20, channela.local.port, endpointa, 0, 43*160 )
721
+ sendpk( 49, 44*20, channela.local.port, endpointa, 0, 44*160 )
722
+ sendpk( 50, 45*20, channela.local.port, endpointa, 0, 45*160 )
678
723
 
679
724
  await new Promise( ( resolve ) => { setTimeout( () => resolve(), 1200 ) } )
680
725
 
@@ -694,19 +739,19 @@ describe( "dtmf", function() {
694
739
  expect( dtmfbpkcount ).to.equal( 6 )
695
740
  expect( dtmfcpkcount ).to.equal( 6 )
696
741
 
697
- const expectedmessages = [
698
- { action: "mix", event: "start" }, //b
699
- { action: "mix", event: "start" }, //c
700
- { action: "telephone-event", event: "4" },
701
- { action: "telephone-event", event: "5" },
702
- { action: "mix", event: "finished" },
703
- { action: "close" }
704
- ]
742
+ expect( receveiedmessages[ 0 ].action ).to.equal( "mix" )
743
+ expect( receveiedmessages[ 1 ].action ).to.equal( "mix" )
744
+ expect( receveiedmessages[ 2 ].action ).to.equal( "telephone-event" )
745
+ expect( receveiedmessages[ 3 ].action ).to.equal( "telephone-event" )
746
+ expect( receveiedmessages[ 4 ].action ).to.equal( "mix" )
747
+ expect( receveiedmessages[ 5 ].action ).to.equal( "close" )
748
+
749
+ expect( receveiedmessages[ 0 ].event ).to.equal( "start" )
750
+ expect( receveiedmessages[ 1 ].event ).to.equal( "start" )
751
+ expect( receveiedmessages[ 2 ].event ).to.equal( "4" )
752
+ expect( receveiedmessages[ 3 ].event ).to.equal( "5" )
753
+ expect( receveiedmessages[ 4 ].event ).to.equal( "finished" )
705
754
 
706
- for( let i = 0; i < expectedmessages.length; i++ ) {
707
- expect( expectedmessages[ i ].action ).to.equal( receveiedmessages[ i ].action )
708
- if( expectedmessages[ i ].event ) expect( receveiedmessages[ i ].event ).to.equal( receveiedmessages[ i ].event )
709
- }
710
755
  } )
711
756
 
712
757
  it( "DTMF captured not working", async function() {