@94ai/softphone 6.0.5 → 6.0.7

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.
Files changed (49) hide show
  1. package/lib/index.d.ts +60 -10
  2. package/lib/softphone.cjs.min.cjs +1 -1
  3. package/lib/softphone.esm-bundler.min.mjs +1 -1
  4. package/lib/softphone.umd.min.js +2 -2
  5. package/package.json +3 -1
  6. package/.yarnrc.yml +0 -19
  7. package/html-softphone-demo/CryptoJS.js +0 -3
  8. package/html-softphone-demo/README.md +0 -10
  9. package/html-softphone-demo/RootCA.pem +0 -20
  10. package/html-softphone-demo/WebrtcDiver.js +0 -320
  11. package/html-softphone-demo/antique_phone.mp3 +0 -0
  12. package/html-softphone-demo/cert.pem +0 -21
  13. package/html-softphone-demo/embed-ui/index.html +0 -123
  14. package/html-softphone-demo/embed-ui/softphone.js +0 -533
  15. package/html-softphone-demo/embed-ui/util.js +0 -123
  16. package/html-softphone-demo/fp.umd.min.js +0 -9
  17. package/html-softphone-demo/gg.xccjh.top.key +0 -27
  18. package/html-softphone-demo/gg.xccjh.top.pem +0 -61
  19. package/html-softphone-demo/index-channel.html +0 -904
  20. package/html-softphone-demo/index-local.html +0 -586
  21. package/html-softphone-demo/index-open.html +0 -617
  22. package/html-softphone-demo/index-switch-pcm.html +0 -613
  23. package/html-softphone-demo/index-test.html +0 -593
  24. package/html-softphone-demo/index-voice.html +0 -720
  25. package/html-softphone-demo/index.html +0 -1090
  26. package/html-softphone-demo/localhost.crt +0 -21
  27. package/html-softphone-demo/localhost.key +0 -28
  28. package/html-softphone-demo/micro-call-ui/CryptoJS.js +0 -3
  29. package/html-softphone-demo/micro-call-ui/draggable.html +0 -168
  30. package/html-softphone-demo/micro-call-ui/draggable.js +0 -1
  31. package/html-softphone-demo/micro-call-ui/index.html +0 -153
  32. package/html-softphone-demo/micro-call-ui/microphone.js +0 -824
  33. package/html-softphone-demo/micro-call-ui/qiankun.js +0 -2
  34. package/html-softphone-demo/micro-call-ui/util.js +0 -33
  35. package/html-softphone-demo/micro-call-ui/wujie.js +0 -3
  36. package/html-softphone-demo/pcm-player.js +0 -131
  37. package/html-softphone-demo/pcm-server/16bit-44100.pcm +0 -0
  38. package/html-softphone-demo/pcm-server/index.html +0 -110
  39. package/html-softphone-demo/pcm-server/server.js +0 -54
  40. package/html-softphone-demo/private.key +0 -28
  41. package/html-softphone-demo/softphone.umd.min.js +0 -2
  42. package/html-softphone-demo/tapd_35238004_base64_1695010473_859.gif +0 -0
  43. package/html-softphone-demo/test.html +0 -190
  44. package/html-softphone-demo/vue-esm-ui/common-ui.es.browser.js +0 -56545
  45. package/html-softphone-demo/vue-esm-ui/vue-esm.html +0 -2043
  46. package/html-softphone-demo/vue-sfc-ui/CryptoJS.js +0 -3
  47. package/html-softphone-demo/vue-sfc-ui/vue-sfc.html +0 -1858
  48. package/html-softphone-demo/vue-umd-ui/common-ui.umd.browser.js +0 -338
  49. package/html-softphone-demo/vue-umd-ui/vue-umd.html +0 -1978
@@ -1,131 +0,0 @@
1
- function PCMPlayer(option) {
2
- this.init(option);
3
- }
4
-
5
- PCMPlayer.prototype.init = function(option) {
6
- var defaults = {
7
- encoding: '16bitInt',
8
- channels: 1,
9
- sampleRate: 8000,
10
- flushingTime: 1000
11
- };
12
- this.option = Object.assign({}, defaults, option);
13
- this.samples = new Float32Array();
14
- this.flush = this.flush.bind(this);
15
- this.interval = setInterval(this.flush, this.option.flushingTime);
16
- this.maxValue = this.getMaxValue();
17
- this.typedArray = this.getTypedArray();
18
- this.createContext();
19
- };
20
-
21
- PCMPlayer.prototype.getMaxValue = function () {
22
- var encodings = {
23
- '8bitInt': 128,
24
- '16bitInt': 32768,
25
- '32bitInt': 2147483648,
26
- '32bitFloat': 1
27
- }
28
-
29
- return encodings[this.option.encoding] ? encodings[this.option.encoding] : encodings['16bitInt'];
30
- };
31
-
32
- PCMPlayer.prototype.getTypedArray = function () {
33
- var typedArrays = {
34
- '8bitInt': Int8Array,
35
- '16bitInt': Int16Array,
36
- '32bitInt': Int32Array,
37
- '32bitFloat': Float32Array
38
- }
39
-
40
- return typedArrays[this.option.encoding] ? typedArrays[this.option.encoding] : typedArrays['16bitInt'];
41
- };
42
-
43
- PCMPlayer.prototype.createContext = function() {
44
- this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
45
-
46
- // context needs to be resumed on iOS and Safari (or it will stay in "suspended" state)
47
- this.audioCtx.resume();
48
- this.audioCtx.onstatechange = () => console.log(this.audioCtx.state); // if you want to see "Running" state in console and be happy about it
49
-
50
- this.gainNode = this.audioCtx.createGain();
51
- this.gainNode.gain.value = 1;
52
- this.gainNode.connect(this.audioCtx.destination);
53
- this.startTime = this.audioCtx.currentTime;
54
- };
55
-
56
- PCMPlayer.prototype.isTypedArray = function(data) {
57
- return (data.byteLength && data.buffer && data.buffer.constructor == ArrayBuffer);
58
- };
59
-
60
- PCMPlayer.prototype.feed = function(data) {
61
- if (!this.isTypedArray(data)) return;
62
- data = this.getFormatedValue(data);
63
- var tmp = new Float32Array(this.samples.length + data.length);
64
- tmp.set(this.samples, 0);
65
- tmp.set(data, this.samples.length);
66
- this.samples = tmp;
67
- };
68
-
69
- PCMPlayer.prototype.getFormatedValue = function(data) {
70
- var data = new this.typedArray(data.buffer),
71
- float32 = new Float32Array(data.length),
72
- i;
73
-
74
- for (i = 0; i < data.length; i++) {
75
- float32[i] = data[i] / this.maxValue;
76
- }
77
- return float32;
78
- };
79
-
80
- PCMPlayer.prototype.volume = function(volume) {
81
- this.gainNode.gain.value = volume;
82
- };
83
-
84
- PCMPlayer.prototype.destroy = function() {
85
- if (this.interval) {
86
- clearInterval(this.interval);
87
- }
88
- this.samples = null;
89
- this.audioCtx.close();
90
- this.audioCtx = null;
91
- };
92
-
93
- PCMPlayer.prototype.flush = function() {
94
- if (!this.samples.length) return;
95
- var bufferSource = this.audioCtx.createBufferSource(),
96
- length = this.samples.length / this.option.channels,
97
- audioBuffer = this.audioCtx.createBuffer(this.option.channels, length, this.option.sampleRate),
98
- audioData,
99
- channel,
100
- offset,
101
- i,
102
- decrement;
103
-
104
- for (channel = 0; channel < this.option.channels; channel++) {
105
- audioData = audioBuffer.getChannelData(channel);
106
- offset = channel;
107
- decrement = 50;
108
- for (i = 0; i < length; i++) {
109
- audioData[i] = this.samples[offset];
110
- /* fadein */
111
- if (i < 50) {
112
- audioData[i] = (audioData[i] * i) / 50;
113
- }
114
- /* fadeout*/
115
- if (i >= (length - 51)) {
116
- audioData[i] = (audioData[i] * decrement--) / 50;
117
- }
118
- offset += this.option.channels;
119
- }
120
- }
121
-
122
- if (this.startTime < this.audioCtx.currentTime) {
123
- this.startTime = this.audioCtx.currentTime;
124
- }
125
- console.log('start vs current '+this.startTime+' vs '+this.audioCtx.currentTime+' duration: '+audioBuffer.duration);
126
- bufferSource.buffer = audioBuffer;
127
- bufferSource.connect(this.gainNode);
128
- bufferSource.start(this.startTime);
129
- this.startTime += audioBuffer.duration;
130
- this.samples = new Float32Array();
131
- };
@@ -1,110 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8">
6
- <title>PCM player</title>
7
- <style>
8
- .visualizer{
9
- width: 400px;
10
- height:200px;
11
- }
12
- </style>
13
- </head>
14
-
15
- <body>
16
- <div id="container"
17
- style="width: 400px; margin: 0 auto;">
18
- <button onclick="loadPCM()">PlayPCM</button>
19
- <input type="range"
20
- max="1"
21
- value="0.1"
22
- min="0"
23
- id="range"
24
- onchange="changeVolume(event)"
25
- step="0.1"><br />
26
- <button onclick="pause()">PausePlaying</button>
27
- <button onclick="continuePlay()">ContinuePlaying</button>
28
- <canvas class="visualizer"></canvas>
29
- </div>
30
-
31
- <script src="./dist/index.js"></script>
32
- <script>
33
- let player
34
- window.loadPCM = function loadPCM() {
35
- var socketURL = 'ws://23.94.99.218:8899';
36
- // 这是我搭载自己服务器上的server端,用来接收pcm数据
37
- // 如果起了example里面的本地server端,改成对应的ws地址就行了
38
- // var socketURL = 'wss://pkjy.xyz/websocket';
39
-
40
- player = new PCMPlayer({
41
- inputCodec: 'Int16',
42
- channels: 2,
43
- sampleRate: 44100,
44
- flushTime: 200
45
- });
46
-
47
- var ws = new WebSocket(socketURL);
48
- ws.binaryType = 'arraybuffer';
49
- ws.addEventListener('message', function (event) {
50
- // 可以传 ArrayBuffer 或者 任意TypedArray
51
- player.feed(event.data);
52
- });
53
-
54
- // 绘制波形图
55
- const bufferLength = player.analyserNode.frequencyBinCount;
56
- const dataArray = new Uint8Array(bufferLength);
57
- player.analyserNode.getByteTimeDomainData(dataArray);
58
-
59
- function draw() {
60
- drawVisual = requestAnimationFrame(draw);
61
-
62
- player.analyserNode.getByteTimeDomainData(dataArray);
63
-
64
- const canvas = document.querySelector(".visualizer");
65
- const canvasCtx = canvas.getContext('2d')
66
- const WIDTH = canvas.width,HEIGHT=canvas.height
67
- canvasCtx.fillStyle = "rgb(200 200 200)";
68
- canvasCtx.fillRect(0, 0, WIDTH, HEIGHT);
69
-
70
- canvasCtx.lineWidth = 2;
71
- canvasCtx.strokeStyle = "rgb(0 0 0)";
72
-
73
- canvasCtx.beginPath();
74
-
75
- const sliceWidth = (WIDTH * 1.0) / bufferLength;
76
- let x = 0;
77
-
78
- for (let i = 0; i < bufferLength; i++) {
79
- const v = dataArray[i] / 128.0;
80
- const y = (v * HEIGHT) / 2;
81
-
82
- if (i === 0) {
83
- canvasCtx.moveTo(x, y);
84
- } else {
85
- canvasCtx.lineTo(x, y);
86
- }
87
-
88
- x += sliceWidth;
89
- }
90
-
91
- canvasCtx.lineTo(WIDTH, HEIGHT / 2);
92
- canvasCtx.stroke();
93
- }
94
-
95
- draw();
96
- }
97
-
98
- window.changeVolume = function changeVolume(e) {
99
- player.volume(document.querySelector('#range').value)
100
- }
101
- window.pause = async function pause() {
102
- await player.pause()
103
- }
104
- window.continuePlay = function continuePlay() {
105
- player.continue()
106
- }
107
- </script>
108
- </body>
109
-
110
- </html>
@@ -1,54 +0,0 @@
1
- const WebSocket = require('ws');
2
- const fs = require('fs');
3
-
4
- const pcm_file = './16bit-44100.pcm';
5
- let interval = 0,
6
- sampleRate = 44100,
7
- bytePerSample = 2,
8
- channels = 2,
9
- bytesChunk = (sampleRate * bytePerSample * channels),
10
- offset = 0,
11
- pcmData,
12
- wss;
13
-
14
- fs.readFile(pcm_file, (err, data) => {
15
- if (err) throw err;
16
- pcmData = data;
17
- openSocket();
18
- });
19
-
20
-
21
- function openSocket() {
22
- wss = new WebSocket.Server({ port: 8899 });
23
- console.log('Server ready...');
24
- wss.on('connection', function connection(ws) {
25
- ws.on('error', function (error) {
26
- console.log('disconnected 断开连接')
27
- })
28
-
29
- console.log('Socket connected. sending data... ws已连接 发送数据');
30
- if (interval) {
31
- clearInterval(interval);
32
- }
33
- interval = setInterval(function () {
34
- sendData();
35
- }, 500);
36
- });
37
- }
38
-
39
- function sendData() {
40
- let payload;
41
- if (offset >= pcmData.length) {
42
- clearInterval(interval);
43
- offset = 0;
44
- return;
45
- }
46
-
47
- payload = pcmData.subarray(offset, (offset + bytesChunk));
48
- offset += bytesChunk;
49
- wss.clients.forEach(function each(client) {
50
- if (client.readyState === WebSocket.OPEN) {
51
- client.send(payload);
52
- }
53
- });
54
- }
@@ -1,28 +0,0 @@
1
- -----BEGIN RSA PRIVATE KEY-----
2
- MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDLTDLHqk88nm2p
3
- WhAp0g8YdAgZiYe5zXw0pTDGPUYsMmkpUiRaOktI+NS8zYK+4G1uyogP8+ZbrtaC
4
- QjlhCuVn1Q5r5NuMhoQ5e7ulSDG+IR3cVZ/x6pq6ijeDcq4vVYnH9BinD0hBw4rV
5
- PWvzQa6GkGCcj/+mvlx90WPnusye/oQpDZCaVXWcmSx/eRp6lZ5bsUNDGlj69ypI
6
- ZTw2XsZcmM6PEVLJ5HVUStNncy/ReFgprBoLrEi8y2GaUbBPyWZOHd6l5Bu1IwMm
7
- BgD8e3jbjyU7wTDc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