ringcentral-softphone 0.4.8 → 0.5.1
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/.ackrc +1 -0
- package/.eslintrc.json +3 -0
- package/.prettierrc.js +3 -0
- package/.vscode/settings.json +10 -0
- package/README.md +1 -7
- package/demos/browser/index.ts +35 -0
- package/demos/node/answer-and-save.ts +42 -0
- package/demos/node/answer-and-talk.js +3 -3
- package/demos/node/{text-to-speech.js → call-and-save.js} +20 -11
- package/demos/node/caller-cancel.js +3 -3
- package/demos/node/high-concurrency.js +3 -3
- package/demos/node/ignore.js +3 -3
- package/demos/node/outbound-call.ts +47 -0
- package/demos/node/send-audio.ts +40 -0
- package/demos/node/text-to-speech.ts +47 -0
- package/demos/node/to-voicemail.js +3 -3
- package/dist/demos/browser/index.d.ts +1 -0
- package/dist/demos/browser/index.js +37 -0
- package/dist/demos/browser/index.js.map +1 -0
- package/dist/demos/node/answer-and-save.d.ts +1 -0
- package/dist/demos/node/answer-and-save.js +45 -0
- package/dist/demos/node/answer-and-save.js.map +1 -0
- package/dist/demos/node/outbound-call.d.ts +1 -0
- package/dist/demos/node/outbound-call.js +49 -0
- package/dist/demos/node/outbound-call.js.map +1 -0
- package/dist/demos/node/send-audio.d.ts +1 -0
- package/dist/demos/node/send-audio.js +36 -0
- package/dist/demos/node/send-audio.js.map +1 -0
- package/dist/demos/node/text-to-speech.d.ts +1 -0
- package/dist/demos/node/text-to-speech.js +41 -0
- package/dist/demos/node/text-to-speech.js.map +1 -0
- package/dist/package.json +55 -0
- package/dist/src/index.d.ts +29 -0
- package/dist/src/index.js +255 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/rc-message/call-control-commands.d.ts +21 -0
- package/dist/src/rc-message/call-control-commands.js +36 -0
- package/dist/src/rc-message/call-control-commands.js.map +1 -0
- package/dist/src/rc-message/rc-message.d.ts +15 -0
- package/dist/src/rc-message/rc-message.js +36 -0
- package/dist/src/rc-message/rc-message.js.map +1 -0
- package/dist/src/rc-message/rc-requests.d.ts +52 -0
- package/dist/src/rc-message/rc-requests.js +18 -0
- package/dist/src/rc-message/rc-requests.js.map +1 -0
- package/dist/src/sip-message/inbound/inbound-sip-message.d.ts +5 -0
- package/dist/src/sip-message/inbound/inbound-sip-message.js +19 -0
- package/dist/src/sip-message/inbound/inbound-sip-message.js.map +1 -0
- package/{src/sip-message/index.js → dist/src/sip-message/index.d.ts} +3 -3
- package/dist/src/sip-message/index.js +13 -0
- package/dist/src/sip-message/index.js.map +1 -0
- package/dist/src/sip-message/outbound/outbound-sip-message.d.ts +5 -0
- package/dist/src/sip-message/outbound/outbound-sip-message.js +16 -0
- package/dist/src/sip-message/outbound/outbound-sip-message.js.map +1 -0
- package/dist/src/sip-message/outbound/request-sip-message.d.ts +8 -0
- package/dist/src/sip-message/outbound/request-sip-message.js +31 -0
- package/dist/src/sip-message/outbound/request-sip-message.js.map +1 -0
- package/dist/src/sip-message/outbound/response-sip-message.d.ts +6 -0
- package/dist/src/sip-message/outbound/response-sip-message.js +23 -0
- package/dist/src/sip-message/outbound/response-sip-message.js.map +1 -0
- package/dist/src/sip-message/response-codes.d.ts +5 -0
- package/dist/src/sip-message/response-codes.js +79 -0
- package/dist/src/sip-message/response-codes.js.map +1 -0
- package/dist/src/sip-message/sip-message.d.ts +11 -0
- package/dist/src/sip-message/sip-message.js +19 -0
- package/dist/src/sip-message/sip-message.js.map +1 -0
- package/dist/src/utils.d.ts +13 -0
- package/dist/src/utils.js +69 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +37 -34
- package/src/index.ts +338 -0
- package/src/rc-message/{call-control-commands.js → call-control-commands.ts} +5 -5
- package/src/rc-message/rc-message.ts +53 -0
- package/src/rc-message/rc-requests.ts +16 -0
- package/src/sip-message/inbound/inbound-sip-message.ts +17 -0
- package/src/sip-message/index.ts +3 -0
- package/src/sip-message/outbound/outbound-sip-message.ts +12 -0
- package/src/sip-message/outbound/request-sip-message.ts +38 -0
- package/src/sip-message/outbound/response-sip-message.ts +27 -0
- package/src/sip-message/{response-codes.js → response-codes.ts} +8 -4
- package/src/sip-message/sip-message.ts +26 -0
- package/src/types/node-webrtc-media-devices/index.d.ts +4 -0
- package/src/types/wrtc/index.d.ts +4 -0
- package/src/types/ws/index.d.ts +4 -0
- package/src/utils.ts +115 -0
- package/test/{rc-message.js → rc-message.spec.js} +1 -1
- package/tsconfig.json +19 -0
- package/webpack.config.babel.ts +29 -0
- package/.babelrc +0 -14
- package/demos/browser/index.js +0 -32
- package/demos/node/answer-and-save.js +0 -41
- package/demos/node/outbound-call.js +0 -38
- package/demos/node/send-audio.js +0 -33
- package/dist/index.js +0 -295
- package/dist/index.js.map +0 -1
- package/dist/rc-message/call-control-commands.js +0 -33
- package/dist/rc-message/call-control-commands.js.map +0 -1
- package/dist/rc-message/rc-message.js +0 -48
- package/dist/rc-message/rc-message.js.map +0 -1
- package/dist/rc-message/rc-requests.js +0 -60
- package/dist/rc-message/rc-requests.js.map +0 -1
- package/dist/sip-message/inbound/inbound-sip-message.js +0 -31
- package/dist/sip-message/inbound/inbound-sip-message.js.map +0 -1
- package/dist/sip-message/index.js +0 -32
- package/dist/sip-message/index.js.map +0 -1
- package/dist/sip-message/outbound/outbound-sip-message.js +0 -25
- package/dist/sip-message/outbound/outbound-sip-message.js.map +0 -1
- package/dist/sip-message/outbound/request-sip-message.js +0 -54
- package/dist/sip-message/outbound/request-sip-message.js.map +0 -1
- package/dist/sip-message/outbound/response-sip-message.js +0 -44
- package/dist/sip-message/outbound/response-sip-message.js.map +0 -1
- package/dist/sip-message/response-codes.js +0 -85
- package/dist/sip-message/response-codes.js.map +0 -1
- package/dist/sip-message/sip-message.js +0 -25
- package/dist/sip-message/sip-message.js.map +0 -1
- package/dist/utils.js +0 -94
- package/dist/utils.js.map +0 -1
- package/src/index.js +0 -233
- package/src/rc-message/rc-message.js +0 -32
- package/src/rc-message/rc-requests.js +0 -16
- package/src/sip-message/inbound/inbound-sip-message.js +0 -15
- package/src/sip-message/outbound/outbound-sip-message.js +0 -12
- package/src/sip-message/outbound/request-sip-message.js +0 -31
- package/src/sip-message/outbound/response-sip-message.js +0 -21
- package/src/sip-message/sip-message.js +0 -13
- package/src/utils.js +0 -63
- package/webpack.config.babel.js +0 -28
package/.ackrc
CHANGED
package/.eslintrc.json
ADDED
package/.prettierrc.js
ADDED
package/README.md
CHANGED
|
@@ -17,12 +17,6 @@ This project was originally designed for server and desktop. It doesn't require
|
|
|
17
17
|
- Ignore inbound call
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
## Known issues
|
|
21
|
-
|
|
22
|
-
- It doesn't work with Node.js 12. I only tested it against node 10.
|
|
23
|
-
- Update: today I tested with Node.js 13.7, it worked like a charm!
|
|
24
|
-
|
|
25
|
-
|
|
26
20
|
## Demos
|
|
27
21
|
|
|
28
22
|
- [browser demo](./demos/browser)
|
|
@@ -38,7 +32,7 @@ This project was originally designed for server and desktop. It doesn't require
|
|
|
38
32
|
## Install
|
|
39
33
|
|
|
40
34
|
```
|
|
41
|
-
yarn add ringcentral-softphone @
|
|
35
|
+
yarn add ringcentral-softphone @rc-ex/core
|
|
42
36
|
```
|
|
43
37
|
|
|
44
38
|
For node.js you also need to:
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import RingCentral from '@rc-ex/core';
|
|
2
|
+
|
|
3
|
+
import Softphone from '../../src/index';
|
|
4
|
+
|
|
5
|
+
const rc = new RingCentral({
|
|
6
|
+
server: process.env.RINGCENTRAL_SERVER_URL,
|
|
7
|
+
clientId: process.env.RINGCENTRAL_CLIENT_ID,
|
|
8
|
+
clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
(async () => {
|
|
12
|
+
await rc.authorize({
|
|
13
|
+
username: process.env.RINGCENTRAL_USERNAME!,
|
|
14
|
+
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
15
|
+
password: process.env.RINGCENTRAL_PASSWORD!,
|
|
16
|
+
});
|
|
17
|
+
const softphone = new Softphone(rc);
|
|
18
|
+
await softphone.register();
|
|
19
|
+
await rc.revoke(); // rc is no longer needed
|
|
20
|
+
|
|
21
|
+
const audioElement = document.getElementById('audio') as HTMLAudioElement;
|
|
22
|
+
softphone.on('INVITE', async sipMessage => {
|
|
23
|
+
const inputAudioStream = await navigator.mediaDevices.getUserMedia({
|
|
24
|
+
audio: true,
|
|
25
|
+
video: false,
|
|
26
|
+
});
|
|
27
|
+
softphone.answer(sipMessage, inputAudioStream);
|
|
28
|
+
softphone.once('track', e => {
|
|
29
|
+
audioElement.srcObject = e.streams[0];
|
|
30
|
+
softphone.once('BYE', () => {
|
|
31
|
+
audioElement.srcObject = null;
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
})();
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import RingCentral from '@rc-ex/core';
|
|
2
|
+
// eslint-disable-next-line node/no-unpublished-import
|
|
3
|
+
import wrtc from 'wrtc';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
|
|
6
|
+
import Softphone from '../../src/index';
|
|
7
|
+
|
|
8
|
+
const rc = new RingCentral({
|
|
9
|
+
server: process.env.RINGCENTRAL_SERVER_URL,
|
|
10
|
+
clientId: process.env.RINGCENTRAL_CLIENT_ID,
|
|
11
|
+
clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
(async () => {
|
|
15
|
+
await rc.authorize({
|
|
16
|
+
username: process.env.RINGCENTRAL_USERNAME!,
|
|
17
|
+
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
18
|
+
password: process.env.RINGCENTRAL_PASSWORD!,
|
|
19
|
+
});
|
|
20
|
+
const softphone = new Softphone(rc);
|
|
21
|
+
await softphone.register();
|
|
22
|
+
await rc.revoke(); // rc is no longer needed
|
|
23
|
+
softphone.on('INVITE', async sipMessage => {
|
|
24
|
+
softphone.answer(sipMessage);
|
|
25
|
+
softphone.once('track', e => {
|
|
26
|
+
const audioFilePath = 'audio.raw';
|
|
27
|
+
if (fs.existsSync(audioFilePath)) {
|
|
28
|
+
fs.unlinkSync(audioFilePath);
|
|
29
|
+
}
|
|
30
|
+
const writeStream = fs.createWriteStream(audioFilePath, {flags: 'a'});
|
|
31
|
+
const audioSink = new wrtc.nonstandard.RTCAudioSink(e.track);
|
|
32
|
+
audioSink.ondata = (data: any) => {
|
|
33
|
+
writeStream.write(Buffer.from(data.samples.buffer));
|
|
34
|
+
};
|
|
35
|
+
softphone.once('BYE', () => {
|
|
36
|
+
audioSink.stop();
|
|
37
|
+
writeStream.end();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
})();
|
|
42
|
+
// You can play the saved audio by: play -b 16 -e signed -c 1 -r 48000 audio.raw
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RingCentral from '@
|
|
1
|
+
import RingCentral from '@rc-ex/core'
|
|
2
2
|
import { nonstandard } from 'wrtc'
|
|
3
3
|
import mediaDevices from 'node-webrtc-media-devices'
|
|
4
4
|
import Speaker from 'speaker'
|
|
@@ -12,14 +12,14 @@ const rc = new RingCentral({
|
|
|
12
12
|
})
|
|
13
13
|
|
|
14
14
|
;(async () => {
|
|
15
|
-
await rc.
|
|
15
|
+
await rc.authorize({
|
|
16
16
|
username: process.env.RINGCENTRAL_USERNAME,
|
|
17
17
|
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
18
18
|
password: process.env.RINGCENTRAL_PASSWORD
|
|
19
19
|
})
|
|
20
20
|
const softphone = new Softphone(rc)
|
|
21
21
|
await softphone.register()
|
|
22
|
-
await rc.
|
|
22
|
+
await rc.revoke() // rc is no longer needed
|
|
23
23
|
softphone.on('INVITE', async sipMessage => {
|
|
24
24
|
const inputAudioStream = await mediaDevices.getUserMedia({ audio: true, video: false })
|
|
25
25
|
softphone.answer(sipMessage, inputAudioStream)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import RingCentral from '@
|
|
2
|
-
import { MediaStream } from 'wrtc'
|
|
3
|
-
import RTCAudioStreamSource from 'node-webrtc-audio-stream-source'
|
|
1
|
+
import RingCentral from '@rc-ex/core'
|
|
2
|
+
import { nonstandard, MediaStream } from 'wrtc'
|
|
4
3
|
import fs from 'fs'
|
|
5
|
-
import
|
|
4
|
+
import RTCAudioStreamSource from 'node-webrtc-audio-stream-source'
|
|
6
5
|
|
|
7
6
|
import Softphone from '../../src/index'
|
|
8
7
|
|
|
@@ -13,25 +12,35 @@ const rc = new RingCentral({
|
|
|
13
12
|
})
|
|
14
13
|
|
|
15
14
|
;(async () => {
|
|
16
|
-
await rc.
|
|
15
|
+
await rc.authorize({
|
|
17
16
|
username: process.env.RINGCENTRAL_USERNAME,
|
|
18
17
|
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
19
18
|
password: process.env.RINGCENTRAL_PASSWORD
|
|
20
19
|
})
|
|
21
20
|
const softphone = new Softphone(rc)
|
|
22
21
|
await softphone.register()
|
|
23
|
-
await rc.
|
|
22
|
+
await rc.revoke() // rc is no longer needed
|
|
24
23
|
|
|
25
24
|
const rtcAudioStreamSource = new RTCAudioStreamSource()
|
|
26
25
|
const track = rtcAudioStreamSource.createTrack()
|
|
27
26
|
const inputAudioStream = new MediaStream()
|
|
28
27
|
inputAudioStream.addTrack(track)
|
|
29
28
|
softphone.invite(process.env.CALLEE_FOR_TESTING, inputAudioStream)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
|
|
30
|
+
softphone.once('track', e => {
|
|
31
|
+
const audioFilePath = 'audio.raw'
|
|
32
|
+
if (fs.existsSync(audioFilePath)) {
|
|
33
|
+
fs.unlinkSync(audioFilePath)
|
|
34
|
+
}
|
|
35
|
+
const writeStream = fs.createWriteStream(audioFilePath, { flags: 'a' })
|
|
36
|
+
const audioSink = new nonstandard.RTCAudioSink(e.track)
|
|
37
|
+
audioSink.ondata = data => {
|
|
38
|
+
writeStream.write(Buffer.from(data.samples.buffer))
|
|
39
|
+
}
|
|
40
|
+
softphone.once('BYE', () => {
|
|
41
|
+
audioSink.stop()
|
|
42
|
+
writeStream.end()
|
|
35
43
|
})
|
|
36
44
|
})
|
|
37
45
|
})()
|
|
46
|
+
// You can play the saved audio by: play -b 16 -e signed -c 1 -r 48000 audio.raw
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RingCentral from '@
|
|
1
|
+
import RingCentral from '@rc-ex/core'
|
|
2
2
|
|
|
3
3
|
import Softphone from '../../src/index'
|
|
4
4
|
|
|
@@ -9,13 +9,13 @@ const rc = new RingCentral({
|
|
|
9
9
|
})
|
|
10
10
|
|
|
11
11
|
;(async () => {
|
|
12
|
-
await rc.
|
|
12
|
+
await rc.authorize({
|
|
13
13
|
username: process.env.RINGCENTRAL_USERNAME,
|
|
14
14
|
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
15
15
|
password: process.env.RINGCENTRAL_PASSWORD
|
|
16
16
|
})
|
|
17
17
|
const softphone = new Softphone(rc)
|
|
18
18
|
await softphone.register()
|
|
19
|
-
await rc.
|
|
19
|
+
await rc.revoke() // rc is no longer needed
|
|
20
20
|
// do nothing, caller should cancel the call
|
|
21
21
|
})()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RingCentral from '@
|
|
1
|
+
import RingCentral from '@rc-ex/core'
|
|
2
2
|
import { nonstandard } from 'wrtc'
|
|
3
3
|
import fs from 'fs'
|
|
4
4
|
|
|
@@ -14,14 +14,14 @@ const rc = new RingCentral({
|
|
|
14
14
|
})
|
|
15
15
|
|
|
16
16
|
;(async () => {
|
|
17
|
-
await rc.
|
|
17
|
+
await rc.authorize({
|
|
18
18
|
username: process.env.RINGCENTRAL_USERNAME,
|
|
19
19
|
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
20
20
|
password: process.env.RINGCENTRAL_PASSWORD
|
|
21
21
|
})
|
|
22
22
|
const softphone = new Softphone(rc)
|
|
23
23
|
await softphone.register()
|
|
24
|
-
await rc.
|
|
24
|
+
await rc.revoke() // rc is no longer needed
|
|
25
25
|
softphone.on('INVITE', async sipMessage => {
|
|
26
26
|
console.log(sipMessage.headers)
|
|
27
27
|
softphone.answer(sipMessage)
|
package/demos/node/ignore.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RingCentral from '@
|
|
1
|
+
import RingCentral from '@rc-ex/core'
|
|
2
2
|
|
|
3
3
|
import Softphone from '../../src/index'
|
|
4
4
|
|
|
@@ -9,14 +9,14 @@ const rc = new RingCentral({
|
|
|
9
9
|
})
|
|
10
10
|
|
|
11
11
|
;(async () => {
|
|
12
|
-
await rc.
|
|
12
|
+
await rc.authorize({
|
|
13
13
|
username: process.env.RINGCENTRAL_USERNAME,
|
|
14
14
|
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
15
15
|
password: process.env.RINGCENTRAL_PASSWORD
|
|
16
16
|
})
|
|
17
17
|
const softphone = new Softphone(rc)
|
|
18
18
|
await softphone.register()
|
|
19
|
-
await rc.
|
|
19
|
+
await rc.revoke() // rc is no longer needed
|
|
20
20
|
softphone.on('INVITE', async sipMessage => {
|
|
21
21
|
softphone.ignore(sipMessage)
|
|
22
22
|
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* eslint-disable node/no-unpublished-import */
|
|
2
|
+
import RingCentral from '@rc-ex/core';
|
|
3
|
+
import mediaDevices from 'node-webrtc-media-devices';
|
|
4
|
+
import Speaker from 'speaker';
|
|
5
|
+
import wrtc from 'wrtc';
|
|
6
|
+
|
|
7
|
+
import Softphone from '../../src/index';
|
|
8
|
+
|
|
9
|
+
const {RTCAudioSink} = wrtc.nonstandard;
|
|
10
|
+
|
|
11
|
+
const rc = new RingCentral({
|
|
12
|
+
server: process.env.RINGCENTRAL_SERVER_URL,
|
|
13
|
+
clientId: process.env.RINGCENTRAL_CLIENT_ID,
|
|
14
|
+
clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
(async () => {
|
|
18
|
+
await rc.authorize({
|
|
19
|
+
username: process.env.RINGCENTRAL_USERNAME!,
|
|
20
|
+
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
21
|
+
password: process.env.RINGCENTRAL_PASSWORD!,
|
|
22
|
+
});
|
|
23
|
+
const softphone = new Softphone(rc);
|
|
24
|
+
await softphone.register();
|
|
25
|
+
await rc.revoke(); // rc is no longer needed
|
|
26
|
+
softphone.on('track', e => {
|
|
27
|
+
const speaker = new Speaker({
|
|
28
|
+
channels: 1,
|
|
29
|
+
bitDepth: 16,
|
|
30
|
+
sampleRate: 48000,
|
|
31
|
+
// signed: true,
|
|
32
|
+
});
|
|
33
|
+
const audioSink = new RTCAudioSink(e.track);
|
|
34
|
+
audioSink.ondata = (data: any) => {
|
|
35
|
+
speaker.write(Buffer.from(data.samples.buffer));
|
|
36
|
+
};
|
|
37
|
+
softphone.once('BYE', () => {
|
|
38
|
+
audioSink.stop();
|
|
39
|
+
speaker.close(true);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
const inputAudioStream = await mediaDevices.getUserMedia({
|
|
43
|
+
audio: true,
|
|
44
|
+
video: false,
|
|
45
|
+
});
|
|
46
|
+
softphone.invite(process.env.CALLEE_FOR_TESTING!, inputAudioStream);
|
|
47
|
+
})();
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import RingCentral from '@rc-ex/core';
|
|
2
|
+
// eslint-disable-next-line node/no-unpublished-import
|
|
3
|
+
import wrtc from 'wrtc';
|
|
4
|
+
// eslint-disable-next-line node/no-unpublished-import
|
|
5
|
+
import RTCAudioStreamSource from 'node-webrtc-audio-stream-source';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
|
|
8
|
+
import Softphone from '../../src/index';
|
|
9
|
+
|
|
10
|
+
const rc = new RingCentral({
|
|
11
|
+
server: process.env.RINGCENTRAL_SERVER_URL,
|
|
12
|
+
clientId: process.env.RINGCENTRAL_CLIENT_ID,
|
|
13
|
+
clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
(async () => {
|
|
17
|
+
await rc.authorize({
|
|
18
|
+
username: process.env.RINGCENTRAL_USERNAME!,
|
|
19
|
+
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
20
|
+
password: process.env.RINGCENTRAL_PASSWORD!,
|
|
21
|
+
});
|
|
22
|
+
const softphone = new Softphone(rc);
|
|
23
|
+
await softphone.register();
|
|
24
|
+
await rc.revoke(); // rc is no longer needed
|
|
25
|
+
|
|
26
|
+
const rtcAudioStreamSource = new RTCAudioStreamSource();
|
|
27
|
+
const track = rtcAudioStreamSource.createTrack();
|
|
28
|
+
const inputAudioStream = new wrtc.MediaStream();
|
|
29
|
+
inputAudioStream.addTrack(track);
|
|
30
|
+
softphone.invite(process.env.CALLEE_FOR_TESTING!, inputAudioStream);
|
|
31
|
+
|
|
32
|
+
softphone.once('track', (e: any) => {
|
|
33
|
+
rtcAudioStreamSource.addStream(
|
|
34
|
+
fs.createReadStream('test.wav'),
|
|
35
|
+
16,
|
|
36
|
+
48000,
|
|
37
|
+
1
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
})();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import RingCentral from '@rc-ex/core';
|
|
2
|
+
// eslint-disable-next-line node/no-unpublished-import
|
|
3
|
+
import wrtc from 'wrtc';
|
|
4
|
+
// eslint-disable-next-line node/no-unpublished-import
|
|
5
|
+
import RTCAudioStreamSource from 'node-webrtc-audio-stream-source';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import {exec} from 'child_process';
|
|
8
|
+
|
|
9
|
+
import Softphone from '../../src/index';
|
|
10
|
+
|
|
11
|
+
const rc = new RingCentral({
|
|
12
|
+
server: process.env.RINGCENTRAL_SERVER_URL,
|
|
13
|
+
clientId: process.env.RINGCENTRAL_CLIENT_ID,
|
|
14
|
+
clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
(async () => {
|
|
18
|
+
await rc.authorize({
|
|
19
|
+
username: process.env.RINGCENTRAL_USERNAME!,
|
|
20
|
+
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
21
|
+
password: process.env.RINGCENTRAL_PASSWORD!,
|
|
22
|
+
});
|
|
23
|
+
const softphone = new Softphone(rc);
|
|
24
|
+
await softphone.register();
|
|
25
|
+
await rc.revoke(); // rc is no longer needed
|
|
26
|
+
|
|
27
|
+
const rtcAudioStreamSource = new RTCAudioStreamSource();
|
|
28
|
+
const track = rtcAudioStreamSource.createTrack();
|
|
29
|
+
const inputAudioStream = new wrtc.MediaStream();
|
|
30
|
+
inputAudioStream.addTrack(track);
|
|
31
|
+
softphone.invite(process.env.CALLEE_FOR_TESTING!, inputAudioStream);
|
|
32
|
+
softphone.on('track', e => {
|
|
33
|
+
const text =
|
|
34
|
+
"Hello Tyler, you need to give a talk to the AI RTC conference today at 3PM, don't forget!";
|
|
35
|
+
const process = exec(
|
|
36
|
+
`say -o temp.wav --data-format=LEI16@48000 "${text + ' ' + text}"`
|
|
37
|
+
);
|
|
38
|
+
process.on('exit', () => {
|
|
39
|
+
rtcAudioStreamSource.addStream(
|
|
40
|
+
fs.createReadStream('temp.wav'),
|
|
41
|
+
16,
|
|
42
|
+
48000,
|
|
43
|
+
1
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
})();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RingCentral from '@
|
|
1
|
+
import RingCentral from '@rc-ex/core'
|
|
2
2
|
|
|
3
3
|
import Softphone from '../../src/index'
|
|
4
4
|
|
|
@@ -9,14 +9,14 @@ const rc = new RingCentral({
|
|
|
9
9
|
})
|
|
10
10
|
|
|
11
11
|
;(async () => {
|
|
12
|
-
await rc.
|
|
12
|
+
await rc.authorize({
|
|
13
13
|
username: process.env.RINGCENTRAL_USERNAME,
|
|
14
14
|
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
15
15
|
password: process.env.RINGCENTRAL_PASSWORD
|
|
16
16
|
})
|
|
17
17
|
const softphone = new Softphone(rc)
|
|
18
18
|
await softphone.register()
|
|
19
|
-
await rc.
|
|
19
|
+
await rc.revoke() // rc is no longer needed
|
|
20
20
|
softphone.on('INVITE', async sipMessage => {
|
|
21
21
|
softphone.toVoicemail(sipMessage)
|
|
22
22
|
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const core_1 = __importDefault(require("@rc-ex/core"));
|
|
7
|
+
const index_1 = __importDefault(require("../../src/index"));
|
|
8
|
+
const rc = new core_1.default({
|
|
9
|
+
server: process.env.RINGCENTRAL_SERVER_URL,
|
|
10
|
+
clientId: process.env.RINGCENTRAL_CLIENT_ID,
|
|
11
|
+
clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET,
|
|
12
|
+
});
|
|
13
|
+
(async () => {
|
|
14
|
+
await rc.authorize({
|
|
15
|
+
username: process.env.RINGCENTRAL_USERNAME,
|
|
16
|
+
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
17
|
+
password: process.env.RINGCENTRAL_PASSWORD,
|
|
18
|
+
});
|
|
19
|
+
const softphone = new index_1.default(rc);
|
|
20
|
+
await softphone.register();
|
|
21
|
+
await rc.revoke(); // rc is no longer needed
|
|
22
|
+
const audioElement = document.getElementById('audio');
|
|
23
|
+
softphone.on('INVITE', async (sipMessage) => {
|
|
24
|
+
const inputAudioStream = await navigator.mediaDevices.getUserMedia({
|
|
25
|
+
audio: true,
|
|
26
|
+
video: false,
|
|
27
|
+
});
|
|
28
|
+
softphone.answer(sipMessage, inputAudioStream);
|
|
29
|
+
softphone.once('track', e => {
|
|
30
|
+
audioElement.srcObject = e.streams[0];
|
|
31
|
+
softphone.once('BYE', () => {
|
|
32
|
+
audioElement.srcObject = null;
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
})();
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../demos/browser/index.ts"],"names":[],"mappings":";;;;;AAAA,uDAAsC;AAEtC,4DAAwC;AAExC,MAAM,EAAE,GAAG,IAAI,cAAW,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;IAC1C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;IAC3C,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;CACpD,CAAC,CAAC;AAEH,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,EAAE,CAAC,SAAS,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAqB;QAC3C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;QAC5C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAqB;KAC5C,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,IAAI,eAAS,CAAC,EAAE,CAAC,CAAC;IACpC,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC3B,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,yBAAyB;IAE5C,MAAM,YAAY,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAqB,CAAC;IAC1E,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAC,UAAU,EAAC,EAAE;QACxC,MAAM,gBAAgB,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC;YACjE,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;QACH,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;QAC/C,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;YAC1B,YAAY,CAAC,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACtC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE;gBACzB,YAAY,CAAC,SAAS,GAAG,IAAI,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const core_1 = __importDefault(require("@rc-ex/core"));
|
|
7
|
+
// eslint-disable-next-line node/no-unpublished-import
|
|
8
|
+
const wrtc_1 = __importDefault(require("wrtc"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const index_1 = __importDefault(require("../../src/index"));
|
|
11
|
+
const rc = new core_1.default({
|
|
12
|
+
server: process.env.RINGCENTRAL_SERVER_URL,
|
|
13
|
+
clientId: process.env.RINGCENTRAL_CLIENT_ID,
|
|
14
|
+
clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET,
|
|
15
|
+
});
|
|
16
|
+
(async () => {
|
|
17
|
+
await rc.authorize({
|
|
18
|
+
username: process.env.RINGCENTRAL_USERNAME,
|
|
19
|
+
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
20
|
+
password: process.env.RINGCENTRAL_PASSWORD,
|
|
21
|
+
});
|
|
22
|
+
const softphone = new index_1.default(rc);
|
|
23
|
+
await softphone.register();
|
|
24
|
+
await rc.revoke(); // rc is no longer needed
|
|
25
|
+
softphone.on('INVITE', async (sipMessage) => {
|
|
26
|
+
softphone.answer(sipMessage);
|
|
27
|
+
softphone.once('track', e => {
|
|
28
|
+
const audioFilePath = 'audio.raw';
|
|
29
|
+
if (fs_1.default.existsSync(audioFilePath)) {
|
|
30
|
+
fs_1.default.unlinkSync(audioFilePath);
|
|
31
|
+
}
|
|
32
|
+
const writeStream = fs_1.default.createWriteStream(audioFilePath, { flags: 'a' });
|
|
33
|
+
const audioSink = new wrtc_1.default.nonstandard.RTCAudioSink(e.track);
|
|
34
|
+
audioSink.ondata = (data) => {
|
|
35
|
+
writeStream.write(Buffer.from(data.samples.buffer));
|
|
36
|
+
};
|
|
37
|
+
softphone.once('BYE', () => {
|
|
38
|
+
audioSink.stop();
|
|
39
|
+
writeStream.end();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
})();
|
|
44
|
+
// You can play the saved audio by: play -b 16 -e signed -c 1 -r 48000 audio.raw
|
|
45
|
+
//# sourceMappingURL=answer-and-save.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answer-and-save.js","sourceRoot":"","sources":["../../../demos/node/answer-and-save.ts"],"names":[],"mappings":";;;;;AAAA,uDAAsC;AACtC,sDAAsD;AACtD,gDAAwB;AACxB,4CAAoB;AAEpB,4DAAwC;AAExC,MAAM,EAAE,GAAG,IAAI,cAAW,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;IAC1C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;IAC3C,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;CACpD,CAAC,CAAC;AAEH,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,EAAE,CAAC,SAAS,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAqB;QAC3C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;QAC5C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAqB;KAC5C,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,IAAI,eAAS,CAAC,EAAE,CAAC,CAAC;IACpC,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC3B,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,yBAAyB;IAC5C,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAC,UAAU,EAAC,EAAE;QACxC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC7B,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;YAC1B,MAAM,aAAa,GAAG,WAAW,CAAC;YAClC,IAAI,YAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;gBAChC,YAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;aAC9B;YACD,MAAM,WAAW,GAAG,YAAE,CAAC,iBAAiB,CAAC,aAAa,EAAE,EAAC,KAAK,EAAE,GAAG,EAAC,CAAC,CAAC;YACtE,MAAM,SAAS,GAAG,IAAI,cAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAC7D,SAAS,CAAC,MAAM,GAAG,CAAC,IAAS,EAAE,EAAE;gBAC/B,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YACtD,CAAC,CAAC;YACF,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE;gBACzB,SAAS,CAAC,IAAI,EAAE,CAAC;gBACjB,WAAW,CAAC,GAAG,EAAE,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,EAAE,CAAC;AACL,gFAAgF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/* eslint-disable node/no-unpublished-import */
|
|
7
|
+
const core_1 = __importDefault(require("@rc-ex/core"));
|
|
8
|
+
const node_webrtc_media_devices_1 = __importDefault(require("node-webrtc-media-devices"));
|
|
9
|
+
const speaker_1 = __importDefault(require("speaker"));
|
|
10
|
+
const wrtc_1 = __importDefault(require("wrtc"));
|
|
11
|
+
const index_1 = __importDefault(require("../../src/index"));
|
|
12
|
+
const { RTCAudioSink } = wrtc_1.default.nonstandard;
|
|
13
|
+
const rc = new core_1.default({
|
|
14
|
+
server: process.env.RINGCENTRAL_SERVER_URL,
|
|
15
|
+
clientId: process.env.RINGCENTRAL_CLIENT_ID,
|
|
16
|
+
clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET,
|
|
17
|
+
});
|
|
18
|
+
(async () => {
|
|
19
|
+
await rc.authorize({
|
|
20
|
+
username: process.env.RINGCENTRAL_USERNAME,
|
|
21
|
+
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
22
|
+
password: process.env.RINGCENTRAL_PASSWORD,
|
|
23
|
+
});
|
|
24
|
+
const softphone = new index_1.default(rc);
|
|
25
|
+
await softphone.register();
|
|
26
|
+
await rc.revoke(); // rc is no longer needed
|
|
27
|
+
softphone.on('track', e => {
|
|
28
|
+
const speaker = new speaker_1.default({
|
|
29
|
+
channels: 1,
|
|
30
|
+
bitDepth: 16,
|
|
31
|
+
sampleRate: 48000,
|
|
32
|
+
// signed: true,
|
|
33
|
+
});
|
|
34
|
+
const audioSink = new RTCAudioSink(e.track);
|
|
35
|
+
audioSink.ondata = (data) => {
|
|
36
|
+
speaker.write(Buffer.from(data.samples.buffer));
|
|
37
|
+
};
|
|
38
|
+
softphone.once('BYE', () => {
|
|
39
|
+
audioSink.stop();
|
|
40
|
+
speaker.close(true);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
const inputAudioStream = await node_webrtc_media_devices_1.default.getUserMedia({
|
|
44
|
+
audio: true,
|
|
45
|
+
video: false,
|
|
46
|
+
});
|
|
47
|
+
softphone.invite(process.env.CALLEE_FOR_TESTING, inputAudioStream);
|
|
48
|
+
})();
|
|
49
|
+
//# sourceMappingURL=outbound-call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbound-call.js","sourceRoot":"","sources":["../../../demos/node/outbound-call.ts"],"names":[],"mappings":";;;;;AAAA,+CAA+C;AAC/C,uDAAsC;AACtC,0FAAqD;AACrD,sDAA8B;AAC9B,gDAAwB;AAExB,4DAAwC;AAExC,MAAM,EAAC,YAAY,EAAC,GAAG,cAAI,CAAC,WAAW,CAAC;AAExC,MAAM,EAAE,GAAG,IAAI,cAAW,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;IAC1C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;IAC3C,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;CACpD,CAAC,CAAC;AAEH,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,EAAE,CAAC,SAAS,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAqB;QAC3C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;QAC5C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAqB;KAC5C,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,IAAI,eAAS,CAAC,EAAE,CAAC,CAAC;IACpC,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC3B,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,yBAAyB;IAC5C,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;QACxB,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC;YAC1B,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,KAAK;YACjB,gBAAgB;SACjB,CAAC,CAAC;QACH,MAAM,SAAS,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC5C,SAAS,CAAC,MAAM,GAAG,CAAC,IAAS,EAAE,EAAE;YAC/B,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC;QACF,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE;YACzB,SAAS,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,gBAAgB,GAAG,MAAM,mCAAY,CAAC,YAAY,CAAC;QACvD,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;IACH,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAmB,EAAE,gBAAgB,CAAC,CAAC;AACtE,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const core_1 = __importDefault(require("@rc-ex/core"));
|
|
7
|
+
// eslint-disable-next-line node/no-unpublished-import
|
|
8
|
+
const wrtc_1 = __importDefault(require("wrtc"));
|
|
9
|
+
// eslint-disable-next-line node/no-unpublished-import
|
|
10
|
+
const node_webrtc_audio_stream_source_1 = __importDefault(require("node-webrtc-audio-stream-source"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const index_1 = __importDefault(require("../../src/index"));
|
|
13
|
+
const rc = new core_1.default({
|
|
14
|
+
server: process.env.RINGCENTRAL_SERVER_URL,
|
|
15
|
+
clientId: process.env.RINGCENTRAL_CLIENT_ID,
|
|
16
|
+
clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET,
|
|
17
|
+
});
|
|
18
|
+
(async () => {
|
|
19
|
+
await rc.authorize({
|
|
20
|
+
username: process.env.RINGCENTRAL_USERNAME,
|
|
21
|
+
extension: process.env.RINGCENTRAL_EXTENSION,
|
|
22
|
+
password: process.env.RINGCENTRAL_PASSWORD,
|
|
23
|
+
});
|
|
24
|
+
const softphone = new index_1.default(rc);
|
|
25
|
+
await softphone.register();
|
|
26
|
+
await rc.revoke(); // rc is no longer needed
|
|
27
|
+
const rtcAudioStreamSource = new node_webrtc_audio_stream_source_1.default();
|
|
28
|
+
const track = rtcAudioStreamSource.createTrack();
|
|
29
|
+
const inputAudioStream = new wrtc_1.default.MediaStream();
|
|
30
|
+
inputAudioStream.addTrack(track);
|
|
31
|
+
softphone.invite(process.env.CALLEE_FOR_TESTING, inputAudioStream);
|
|
32
|
+
softphone.once('track', (e) => {
|
|
33
|
+
rtcAudioStreamSource.addStream(fs_1.default.createReadStream('test.wav'), 16, 48000, 1);
|
|
34
|
+
});
|
|
35
|
+
})();
|
|
36
|
+
//# sourceMappingURL=send-audio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-audio.js","sourceRoot":"","sources":["../../../demos/node/send-audio.ts"],"names":[],"mappings":";;;;;AAAA,uDAAsC;AACtC,sDAAsD;AACtD,gDAAwB;AACxB,sDAAsD;AACtD,sGAAmE;AACnE,4CAAoB;AAEpB,4DAAwC;AAExC,MAAM,EAAE,GAAG,IAAI,cAAW,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;IAC1C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;IAC3C,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;CACpD,CAAC,CAAC;AAEH,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,EAAE,CAAC,SAAS,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAqB;QAC3C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;QAC5C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAqB;KAC5C,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,IAAI,eAAS,CAAC,EAAE,CAAC,CAAC;IACpC,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC3B,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,yBAAyB;IAE5C,MAAM,oBAAoB,GAAG,IAAI,yCAAoB,EAAE,CAAC;IACxD,MAAM,KAAK,GAAG,oBAAoB,CAAC,WAAW,EAAE,CAAC;IACjD,MAAM,gBAAgB,GAAG,IAAI,cAAI,CAAC,WAAW,EAAE,CAAC;IAChD,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAmB,EAAE,gBAAgB,CAAC,CAAC;IAEpE,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAM,EAAE,EAAE;QACjC,oBAAoB,CAAC,SAAS,CAC5B,YAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAC/B,EAAE,EACF,KAAK,EACL,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|