podchat-browser 12.7.2-snapshot.1 → 12.7.2-snapshot.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/dist/node/call.module.js +399 -190
- package/dist/node/chat.js +2 -2
- package/dist/node/lib/call/deviceManager.js +48 -0
- package/dist/node/lib/errorHandler.js +16 -0
- package/dist/podchat-browser-bundle.js +586 -325
- package/package.json +1 -1
- package/src/call.module.js +316 -115
- package/src/chat.js +42 -23
- package/src/lib/call/deviceManager.js +45 -0
- package/src/lib/errorHandler.js +20 -3
- package/dist.zip +0 -0
package/dist/node/call.module.js
CHANGED
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
12
14
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
15
|
|
|
14
16
|
var _constants = require("./lib/constants");
|
|
@@ -52,6 +54,7 @@ function ChatCall(params) {
|
|
|
52
54
|
callVideoMinHeight = params.callOptions && params.callOptions.hasOwnProperty('callVideo') && (0, _typeof2["default"])(params.callOptions.callVideo) === 'object' && params.callOptions.callVideo.hasOwnProperty('minHeight') ? params.callOptions.callVideo.minHeight : 180,
|
|
53
55
|
currentCallParams = {},
|
|
54
56
|
currentCallId = null,
|
|
57
|
+
latestCallRequestId = null,
|
|
55
58
|
//shouldReconnectCallTimeout = null,
|
|
56
59
|
callMetaDataTypes = {
|
|
57
60
|
POORCONNECTION: 1,
|
|
@@ -358,7 +361,11 @@ function ChatCall(params) {
|
|
|
358
361
|
_deviceManager["default"].grantUserMediaDevicesPermissions({
|
|
359
362
|
audio: true
|
|
360
363
|
}).then(function () {
|
|
361
|
-
|
|
364
|
+
var audioInput = _deviceManager["default"].mediaStreams().getAudioInput();
|
|
365
|
+
|
|
366
|
+
_deviceManager["default"].watchAudioInputStream(raiseCallError);
|
|
367
|
+
|
|
368
|
+
options.audioStream = audioInput;
|
|
362
369
|
resolve(options);
|
|
363
370
|
})["catch"](function (error) {
|
|
364
371
|
reject(error);
|
|
@@ -493,7 +500,7 @@ function ChatCall(params) {
|
|
|
493
500
|
watchRTCPeerConnection: function watchRTCPeerConnection() {
|
|
494
501
|
consoleLogging && console.log("[SDK][watchRTCPeerConnection] called with: ", "userId: ", config.userId, "topic: ", config.topic, "mediaType: ", config.mediaType, "direction: ", config.direction);
|
|
495
502
|
var manager = this,
|
|
496
|
-
user = callUsers[config.userId];
|
|
503
|
+
user = callUsers[config.userId];
|
|
497
504
|
|
|
498
505
|
config.peer.peerConnection.onconnectionstatechange = function () {
|
|
499
506
|
if (!user || !config.peer) {
|
|
@@ -504,6 +511,7 @@ function ChatCall(params) {
|
|
|
504
511
|
|
|
505
512
|
if (config.peer.peerConnection.connectionState === 'disconnected') {
|
|
506
513
|
manager.removeConnectionQualityInterval();
|
|
514
|
+
manager.removeAudioWatcherInterval();
|
|
507
515
|
}
|
|
508
516
|
|
|
509
517
|
if (config.peer.peerConnection.connectionState === "failed") {
|
|
@@ -520,19 +528,25 @@ function ChatCall(params) {
|
|
|
520
528
|
}
|
|
521
529
|
|
|
522
530
|
if (config.peer.peerConnection.connectionState === 'connected') {
|
|
531
|
+
if (config.direction === 'send' && !user.topicMetaData[config.topic].connectionQualityInterval) {
|
|
532
|
+
user.topicMetaData[config.topic].connectionQualityInterval = setInterval(function () {
|
|
533
|
+
manager.checkConnectionQuality();
|
|
534
|
+
}, 1000);
|
|
535
|
+
}
|
|
536
|
+
|
|
523
537
|
if (config.mediaType === 'video') {
|
|
524
|
-
if
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}
|
|
538
|
+
/*if(config.direction === 'send') {
|
|
539
|
+
user.topicMetaData[config.topic].connectionQualityInterval = setInterval(function() {
|
|
540
|
+
manager.checkConnectionQuality()
|
|
541
|
+
}, 1000);
|
|
542
|
+
}*/
|
|
529
543
|
|
|
530
|
-
if
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}
|
|
544
|
+
/*if(config.direction === 'receive') {
|
|
545
|
+
chatEvents.fireEvent("callEvents", {
|
|
546
|
+
type: "RECEIVE_VIDEO_CONNECTION_ESTABLISHED",
|
|
547
|
+
userId: config.userId
|
|
548
|
+
})
|
|
549
|
+
}*/
|
|
536
550
|
}
|
|
537
551
|
}
|
|
538
552
|
};
|
|
@@ -573,6 +587,32 @@ function ChatCall(params) {
|
|
|
573
587
|
}
|
|
574
588
|
|
|
575
589
|
if (config.peer.peerConnection.iceConnectionState === "connected") {
|
|
590
|
+
if (config.mediaType === 'audio') {
|
|
591
|
+
manager.watchAudioLevel();
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (config.direction === 'send' && !user.topicMetaData[config.topic].connectionQualityInterval) {
|
|
595
|
+
user.topicMetaData[config.topic].connectionQualityInterval = setInterval(function () {
|
|
596
|
+
// if(config.mediaType === 'video' )
|
|
597
|
+
manager.checkConnectionQuality(); // else
|
|
598
|
+
// manager.checkAudioConnectionQuality();
|
|
599
|
+
}, 1000);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (config.mediaType === 'video') {
|
|
603
|
+
/*if(config.direction === 'send') {
|
|
604
|
+
user.topicMetaData[config.topic].connectionQualityInterval = setInterval(function() {
|
|
605
|
+
manager.checkConnectionQuality()
|
|
606
|
+
}, 1000);
|
|
607
|
+
}*/
|
|
608
|
+
if (config.direction === 'receive') {
|
|
609
|
+
_eventsModule.chatEvents.fireEvent("callEvents", {
|
|
610
|
+
type: "RECEIVE_VIDEO_CONNECTION_ESTABLISHED",
|
|
611
|
+
userId: config.userId
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
576
616
|
if (config.direction === 'receive' && config.mediaType === 'audio') {
|
|
577
617
|
manager.watchAudioLevel();
|
|
578
618
|
}
|
|
@@ -592,7 +632,7 @@ function ChatCall(params) {
|
|
|
592
632
|
watchAudioLevel: function watchAudioLevel() {
|
|
593
633
|
var manager = this,
|
|
594
634
|
audioCtx = new AudioContext(),
|
|
595
|
-
stream = config.peer.getRemoteStream();
|
|
635
|
+
stream = config.direction === 'receive' ? config.peer.getRemoteStream() : config.peer.getLocalStream();
|
|
596
636
|
|
|
597
637
|
if (config.peer && !stream) {
|
|
598
638
|
setTimeout(function () {
|
|
@@ -600,125 +640,199 @@ function ChatCall(params) {
|
|
|
600
640
|
}, 500);
|
|
601
641
|
return;
|
|
602
642
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
643
|
+
/*
|
|
644
|
+
const audioSourceNode = audioCtx.createMediaStreamSource(stream)
|
|
645
|
+
, analyserNode = audioCtx.createScriptProcessor(2048, 1, 1);
|
|
646
|
+
let instant = 0.0, counter = 0;
|
|
647
|
+
analyserNode.onaudioprocess = function(event) {
|
|
648
|
+
if(!config.peer) {
|
|
649
|
+
analyserNode.removeEventListener('audioprocess', null);
|
|
650
|
+
analyserNode.onaudioprocess = null;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
counter++;
|
|
654
|
+
|
|
655
|
+
if(counter % 20 !== 0) {
|
|
656
|
+
return;
|
|
657
|
+
} else {
|
|
658
|
+
counter = 0;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
const input = event.inputBuffer.getChannelData(0);
|
|
662
|
+
let i;
|
|
663
|
+
let sum = 0.0;
|
|
664
|
+
let clipcount = 0;
|
|
665
|
+
for (i = 0; i < input.length; ++i) {
|
|
666
|
+
sum += input[i] * input[i];
|
|
667
|
+
if (Math.abs(input[i]) > 0.99) {
|
|
668
|
+
clipcount += 1;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
instant = Math.floor( Math.sqrt(sum / input.length) * 10000);
|
|
673
|
+
chatEvents.fireEvent('callStreamEvents', {
|
|
674
|
+
type: 'USER_SPEAKING',
|
|
675
|
+
userId: config.userId,
|
|
676
|
+
audioLevel: convertToAudioLevel(instant)
|
|
677
|
+
})
|
|
678
|
+
};
|
|
679
|
+
analyserNode.fftSize = 256;
|
|
680
|
+
// const bufferLength = analyserNode.frequencyBinCount;
|
|
681
|
+
// const dataArray = new Uint8Array(bufferLength);
|
|
682
|
+
audioSourceNode.connect(analyserNode);
|
|
683
|
+
analyserNode.connect(audioCtx.destination);
|
|
684
|
+
|
|
685
|
+
function convertToAudioLevel(soundPower){
|
|
686
|
+
if(soundPower < 10) {
|
|
687
|
+
return 0;
|
|
688
|
+
} else if(soundPower >= 10 && soundPower < 100) {
|
|
689
|
+
return 1;
|
|
690
|
+
} else if(soundPower >= 100 && soundPower < 200) {
|
|
691
|
+
return 2;
|
|
692
|
+
} else if(soundPower >= 200 && soundPower < 300) {
|
|
693
|
+
return 3;
|
|
694
|
+
} else if(soundPower >= 300) {
|
|
695
|
+
return 4;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
*/
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
var user = callUsers[config.userId],
|
|
702
|
+
topicMetadata = user.topicMetaData[config.topic]; // Create and configure the audio pipeline
|
|
703
|
+
|
|
704
|
+
var audioContext = new AudioContext();
|
|
705
|
+
var analyzer = audioContext.createAnalyser();
|
|
706
|
+
analyzer.fftSize = 512;
|
|
707
|
+
analyzer.smoothingTimeConstant = 0.1;
|
|
708
|
+
var sourceNode = audioContext.createMediaStreamSource(stream);
|
|
709
|
+
sourceNode.connect(analyzer); // Analyze the sound
|
|
710
|
+
|
|
711
|
+
topicMetadata.audioLevelInterval = setInterval(function () {
|
|
712
|
+
// Compute the max volume level (-Infinity...0)
|
|
713
|
+
var fftBins = new Float32Array(analyzer.frequencyBinCount); // Number of values manipulated for each sample
|
|
714
|
+
|
|
715
|
+
analyzer.getFloatFrequencyData(fftBins); // audioPeakDB varies from -Infinity up to 0
|
|
716
|
+
|
|
717
|
+
var audioPeakDB = Math.max.apply(Math, (0, _toConsumableArray2["default"])(fftBins)); // Compute a wave (0...)
|
|
718
|
+
|
|
719
|
+
var frequencyRangeData = new Uint8Array(analyzer.frequencyBinCount);
|
|
720
|
+
analyzer.getByteFrequencyData(frequencyRangeData);
|
|
721
|
+
var sum = frequencyRangeData.reduce(function (p, c) {
|
|
722
|
+
return p + c;
|
|
723
|
+
}, 0); // audioMeter varies from 0 to 10
|
|
724
|
+
|
|
725
|
+
var audioMeter = Math.sqrt(sum / frequencyRangeData.length); //console.log({audioMeter}, {audioPeakDB});
|
|
726
|
+
|
|
727
|
+
if (audioPeakDB > -50 && audioMeter > 0) {
|
|
728
|
+
_eventsModule.chatEvents.fireEvent('callStreamEvents', {
|
|
729
|
+
type: 'USER_SPEAKING',
|
|
730
|
+
userId: config.userId,
|
|
731
|
+
audioLevel: convertToAudioLevel(audioPeakDB),
|
|
732
|
+
isNoise: false,
|
|
733
|
+
isMute: false
|
|
734
|
+
});
|
|
735
|
+
} else if (audioPeakDB !== -Infinity && audioPeakDB < -60 && audioMeter > 0) {
|
|
736
|
+
_eventsModule.chatEvents.fireEvent('callStreamEvents', {
|
|
737
|
+
type: 'USER_SPEAKING',
|
|
738
|
+
userId: config.userId,
|
|
739
|
+
audioLevel: 0,
|
|
740
|
+
isNoise: true,
|
|
741
|
+
isMute: false
|
|
742
|
+
});
|
|
743
|
+
} else if (audioPeakDB === -Infinity && audioMeter == 0) {
|
|
744
|
+
_eventsModule.chatEvents.fireEvent('callStreamEvents', {
|
|
745
|
+
type: 'USER_SPEAKING',
|
|
746
|
+
userId: config.userId,
|
|
747
|
+
audioLevel: 0,
|
|
748
|
+
isNoise: false,
|
|
749
|
+
isMute: true
|
|
750
|
+
});
|
|
634
751
|
}
|
|
635
|
-
|
|
636
|
-
instant = Math.floor(Math.sqrt(sum / input.length) * 10000);
|
|
637
|
-
|
|
638
|
-
_eventsModule.chatEvents.fireEvent('callStreamEvents', {
|
|
639
|
-
type: 'USER_SPEAKING',
|
|
640
|
-
userId: config.userId,
|
|
641
|
-
audioLevel: convertToAudioLevel(instant)
|
|
642
|
-
});
|
|
643
|
-
};
|
|
644
|
-
|
|
645
|
-
analyserNode.fftSize = 256; // const bufferLength = analyserNode.frequencyBinCount;
|
|
646
|
-
// const dataArray = new Uint8Array(bufferLength);
|
|
647
|
-
|
|
648
|
-
audioSourceNode.connect(analyserNode);
|
|
649
|
-
analyserNode.connect(audioCtx.destination);
|
|
752
|
+
}, 300);
|
|
650
753
|
|
|
651
754
|
function convertToAudioLevel(soundPower) {
|
|
652
|
-
if (soundPower
|
|
755
|
+
if (soundPower <= -60) {
|
|
653
756
|
return 0;
|
|
654
|
-
} else if (soundPower >=
|
|
757
|
+
} else if (soundPower >= -60 && soundPower < -50) {
|
|
655
758
|
return 1;
|
|
656
|
-
} else if (soundPower >=
|
|
759
|
+
} else if (soundPower >= -50 && soundPower < -40) {
|
|
657
760
|
return 2;
|
|
658
|
-
} else if (soundPower >=
|
|
761
|
+
} else if (soundPower >= -40 && soundPower < 30) {
|
|
659
762
|
return 3;
|
|
660
|
-
} else if (soundPower >=
|
|
763
|
+
} else if (soundPower >= -30) {
|
|
661
764
|
return 4;
|
|
662
765
|
}
|
|
663
766
|
}
|
|
664
767
|
},
|
|
665
768
|
checkConnectionQuality: function checkConnectionQuality() {
|
|
769
|
+
var manager = this;
|
|
770
|
+
|
|
666
771
|
if (!callUsers[config.userId] || !config.peer || !config.peer.peerConnection) {
|
|
667
772
|
this.removeConnectionQualityInterval();
|
|
773
|
+
this.removeAudioWatcherInterval();
|
|
668
774
|
return;
|
|
669
775
|
}
|
|
670
776
|
|
|
671
777
|
config.peer.peerConnection.getStats(null).then(function (stats) {
|
|
672
|
-
//console.log(' watchRTCPeerConnection:: window.setInterval then(stats:', stats)
|
|
673
|
-
//let statsOutput = "";
|
|
778
|
+
// console.log(' watchRTCPeerConnection:: window.setInterval then(stats:', stats)
|
|
779
|
+
// let statsOutput = "";
|
|
674
780
|
var user = callUsers[config.userId],
|
|
675
781
|
topicMetadata = user.topicMetaData[config.topic];
|
|
676
782
|
stats.forEach(function (report) {
|
|
677
783
|
if (report && report.type && report.type === 'remote-inbound-rtp') {
|
|
678
|
-
|
|
679
|
-
|
|
784
|
+
// statsOutput += `<h2>Report: ${report.type}</h2>\n<strong>ID:</strong> ${report.id}<br>\n` +
|
|
785
|
+
// `<strong>Timestamp:</strong> ${report.timestamp}<br>\n`;
|
|
680
786
|
// Now the statistics for this report; we intentially drop the ones we
|
|
681
787
|
// sorted to the top above
|
|
682
788
|
if (!report['roundTripTime'] || report['roundTripTime'] > 1) {
|
|
683
789
|
if (topicMetadata.poorConnectionCount === 10) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
790
|
+
// chatEvents.fireEvent('callEvents', {
|
|
791
|
+
// type: 'POOR_VIDEO_CONNECTION',
|
|
792
|
+
// subType: 'LONG_TIME',
|
|
793
|
+
// message: 'Poor connection for a long time',
|
|
794
|
+
// metadata: {
|
|
795
|
+
// elementId: "uiRemoteVideo-" + config.topic,
|
|
796
|
+
// topic: config.topic,
|
|
797
|
+
// userId: config.userId
|
|
798
|
+
// }
|
|
799
|
+
// });
|
|
800
|
+
sendQualityCheckEvent({
|
|
801
|
+
userId: config.userId,
|
|
802
|
+
topic: config.topic,
|
|
803
|
+
mediaType: config.mediaType,
|
|
804
|
+
isLongTime: true
|
|
693
805
|
});
|
|
694
806
|
}
|
|
695
807
|
|
|
696
808
|
if (topicMetadata.poorConnectionCount > 3 && !topicMetadata.isConnectionPoor) {
|
|
697
809
|
//alert('Poor connection detected...');
|
|
698
|
-
consoleLogging && console.log('[SDK][checkConnectionQuality] Poor connection detected...');
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
}
|
|
709
|
-
});
|
|
810
|
+
consoleLogging && console.log('[SDK][checkConnectionQuality] Poor connection detected...'); // chatEvents.fireEvent('callEvents', {
|
|
811
|
+
// type: 'POOR_VIDEO_CONNECTION',
|
|
812
|
+
// subType: 'SHORT_TIME',
|
|
813
|
+
// message: 'Poor connection detected',
|
|
814
|
+
// metadata: {
|
|
815
|
+
// elementId: "uiRemoteVideo-" + config.topic,
|
|
816
|
+
// topic: config.topic,
|
|
817
|
+
// userId: config.userId
|
|
818
|
+
// }
|
|
819
|
+
// });
|
|
710
820
|
|
|
821
|
+
sendQualityCheckEvent({
|
|
822
|
+
userId: config.userId,
|
|
823
|
+
topic: config.topic,
|
|
824
|
+
mediaType: config.mediaType
|
|
825
|
+
});
|
|
711
826
|
topicMetadata.isConnectionPoor = true;
|
|
712
827
|
topicMetadata.poorConnectionCount = 0;
|
|
713
|
-
topicMetadata.poorConnectionResolvedCount = 0;
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
});
|
|
828
|
+
topicMetadata.poorConnectionResolvedCount = 0; // sendCallMetaData({
|
|
829
|
+
// id: callMetaDataTypes.POORCONNECTION,
|
|
830
|
+
// userid: config.userId,
|
|
831
|
+
// content: {
|
|
832
|
+
// title: 'Poor Connection',
|
|
833
|
+
// description: config.topic,
|
|
834
|
+
// }
|
|
835
|
+
// });
|
|
722
836
|
} else {
|
|
723
837
|
callUsers[config.userId].topicMetaData[config.topic].poorConnectionCount++;
|
|
724
838
|
}
|
|
@@ -727,37 +841,30 @@ function ChatCall(params) {
|
|
|
727
841
|
topicMetadata.poorConnectionResolvedCount = 0;
|
|
728
842
|
topicMetadata.poorConnectionCount = 0;
|
|
729
843
|
topicMetadata.isConnectionPoor = false;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
userid: config.userId,
|
|
744
|
-
content: {
|
|
745
|
-
title: 'Poor Connection Resolved',
|
|
746
|
-
description: config.topic
|
|
747
|
-
}
|
|
748
|
-
});
|
|
844
|
+
sendQualityCheckEvent({
|
|
845
|
+
userId: config.userId,
|
|
846
|
+
topic: config.topic,
|
|
847
|
+
mediaType: config.mediaType,
|
|
848
|
+
isResolved: true
|
|
849
|
+
}); // sendCallMetaData({
|
|
850
|
+
// id: callMetaDataTypes.POORCONNECTIONRESOLVED,
|
|
851
|
+
// userid: config.userId,
|
|
852
|
+
// content: {
|
|
853
|
+
// title: 'Poor Connection Resolved',
|
|
854
|
+
// description: config.topic
|
|
855
|
+
// }
|
|
856
|
+
// });
|
|
749
857
|
} else {
|
|
750
858
|
topicMetadata.poorConnectionResolvedCount++;
|
|
751
859
|
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
});*/
|
|
860
|
+
} // Object.keys(report).forEach(function (statName) {
|
|
861
|
+
// if (statName !== "id" && statName !== "timestamp" && statName !== "type") {
|
|
862
|
+
// statsOutput += `<strong>${statName}:</strong> ${report[statName]}<br>\n`;
|
|
863
|
+
// }
|
|
864
|
+
// });
|
|
758
865
|
|
|
759
866
|
}
|
|
760
|
-
}); //document.querySelector(".stats-box").innerHTML = statsOutput;
|
|
867
|
+
}); // document.querySelector(".stats-box").innerHTML = statsOutput;
|
|
761
868
|
});
|
|
762
869
|
},
|
|
763
870
|
removeConnectionQualityInterval: function removeConnectionQualityInterval() {
|
|
@@ -766,6 +873,11 @@ function ChatCall(params) {
|
|
|
766
873
|
clearInterval(callUsers[config.userId].topicMetaData[config.topic]['connectionQualityInterval']);
|
|
767
874
|
}
|
|
768
875
|
},
|
|
876
|
+
removeAudioWatcherInterval: function removeAudioWatcherInterval() {
|
|
877
|
+
if (callUsers[config.userId] && callUsers[config.userId].topicMetaData[config.topic]) {
|
|
878
|
+
clearInterval(callUsers[config.userId].topicMetaData[config.topic]['audioLevelInterval']);
|
|
879
|
+
}
|
|
880
|
+
},
|
|
769
881
|
shouldReconnectTopic: function shouldReconnectTopic() {
|
|
770
882
|
var manager = this,
|
|
771
883
|
iceConnectionState = config.peer.peerConnection.iceConnectionState;
|
|
@@ -779,29 +891,35 @@ function ChatCall(params) {
|
|
|
779
891
|
errorInfo: config.peer
|
|
780
892
|
});
|
|
781
893
|
|
|
782
|
-
|
|
783
|
-
id: 'STOP',
|
|
784
|
-
topic: config.topic
|
|
785
|
-
}, function (result) {
|
|
786
|
-
if (result.done === 'TRUE' || result.done === 'SKIP') {
|
|
787
|
-
manager.reconnectTopic();
|
|
788
|
-
}
|
|
789
|
-
/* else if (result.done === 'SKIP') {
|
|
790
|
-
manager.reconnectTopic();
|
|
791
|
-
} */
|
|
792
|
-
else {
|
|
793
|
-
consoleLogging && console.log('STOP topic faced a problem', result);
|
|
794
|
-
endCall({
|
|
795
|
-
callId: currentCallId
|
|
796
|
-
});
|
|
797
|
-
callStop();
|
|
798
|
-
}
|
|
799
|
-
}, {
|
|
800
|
-
timeoutTime: 5000
|
|
801
|
-
});
|
|
894
|
+
manager.recreateTopic();
|
|
802
895
|
}
|
|
803
896
|
}
|
|
804
897
|
},
|
|
898
|
+
recreateTopic: function recreateTopic() {
|
|
899
|
+
var manager = this;
|
|
900
|
+
return new Promise(function (resolve, reject) {
|
|
901
|
+
sendCallMessage({
|
|
902
|
+
id: 'STOP',
|
|
903
|
+
topic: config.topic
|
|
904
|
+
}, function (result) {
|
|
905
|
+
if (result.done === 'TRUE' || result.done === 'SKIP') {
|
|
906
|
+
manager.reconnectTopic();
|
|
907
|
+
resolve();
|
|
908
|
+
}
|
|
909
|
+
/* else if (result.done === 'SKIP') {
|
|
910
|
+
manager.reconnectTopic();
|
|
911
|
+
} */
|
|
912
|
+
else {
|
|
913
|
+
consoleLogging && console.log('STOP topic faced a problem', result);
|
|
914
|
+
endCall({
|
|
915
|
+
callId: currentCallId
|
|
916
|
+
});
|
|
917
|
+
callStop();
|
|
918
|
+
reject();
|
|
919
|
+
}
|
|
920
|
+
}, {});
|
|
921
|
+
});
|
|
922
|
+
},
|
|
805
923
|
reconnectTopic: function reconnectTopic() {
|
|
806
924
|
var manager = this;
|
|
807
925
|
manager.removeTopic().then(function () {
|
|
@@ -837,6 +955,7 @@ function ChatCall(params) {
|
|
|
837
955
|
|
|
838
956
|
metadataInstance.clearIceCandidateInterval();
|
|
839
957
|
manager.removeConnectionQualityInterval();
|
|
958
|
+
manager.removeAudioWatcherInterval();
|
|
840
959
|
|
|
841
960
|
if (config.direction === 'send' && !config.isScreenShare) {
|
|
842
961
|
/*let constraint = {
|
|
@@ -1420,7 +1539,8 @@ function ChatCall(params) {
|
|
|
1420
1539
|
connectionQualityInterval: null,
|
|
1421
1540
|
poorConnectionCount: 0,
|
|
1422
1541
|
poorConnectionResolvedCount: 0,
|
|
1423
|
-
isConnectionPoor: false
|
|
1542
|
+
isConnectionPoor: false,
|
|
1543
|
+
audioLevelInterval: null
|
|
1424
1544
|
};
|
|
1425
1545
|
user.topicMetaData[user.audioTopicName] = {
|
|
1426
1546
|
interval: null,
|
|
@@ -2208,29 +2328,42 @@ function ChatCall(params) {
|
|
|
2208
2328
|
|
|
2209
2329
|
switch (id) {
|
|
2210
2330
|
case callMetaDataTypes.POORCONNECTION:
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2331
|
+
// chatEvents.fireEvent("callEvents", {
|
|
2332
|
+
// type: 'POOR_VIDEO_CONNECTION',
|
|
2333
|
+
// subType: 'SHORT_TIME',
|
|
2334
|
+
// message: 'Poor connection detected',
|
|
2335
|
+
// metadata: {
|
|
2336
|
+
// elementId: "uiRemoteVideo-" + jMessage.content.description,
|
|
2337
|
+
// topic: jMessage.content.description,
|
|
2338
|
+
// userId: jMessage.userid
|
|
2339
|
+
// }
|
|
2340
|
+
// });
|
|
2341
|
+
sendQualityCheckEvent({
|
|
2342
|
+
userId: jMessage.userid,
|
|
2343
|
+
topic: jMessage.content.description,
|
|
2344
|
+
//jMessage.topic,
|
|
2345
|
+
mediaType: jMessage.content.description.indexOf('Vi') !== -1 ? 'video' : 'audio',
|
|
2346
|
+
//jMessage.mediaType,
|
|
2347
|
+
canSendCallMetaData: false
|
|
2220
2348
|
});
|
|
2221
|
-
|
|
2222
2349
|
break;
|
|
2223
2350
|
|
|
2224
2351
|
case callMetaDataTypes.POORCONNECTIONRESOLVED:
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2352
|
+
sendQualityCheckEvent({
|
|
2353
|
+
userId: jMessage.userid,
|
|
2354
|
+
topic: jMessage.content.description,
|
|
2355
|
+
mediaType: jMessage.content.description.indexOf('Vi') !== -1 ? 'video' : 'audio',
|
|
2356
|
+
isResolved: true,
|
|
2357
|
+
canSendCallMetaData: false
|
|
2358
|
+
}); // chatEvents.fireEvent('callEvents', {
|
|
2359
|
+
// type: 'POOR_VIDEO_CONNECTION_RESOLVED',
|
|
2360
|
+
// message: 'Poor connection resolved',
|
|
2361
|
+
// metadata: {
|
|
2362
|
+
// elementId: "uiRemoteVideo-" + jMessage.content.description,
|
|
2363
|
+
// topic: jMessage.content.description,
|
|
2364
|
+
// userId: jMessage.userid
|
|
2365
|
+
// }
|
|
2366
|
+
// });
|
|
2234
2367
|
|
|
2235
2368
|
break;
|
|
2236
2369
|
|
|
@@ -2319,6 +2452,54 @@ function ChatCall(params) {
|
|
|
2319
2452
|
startCallInfo: currentCallParams,
|
|
2320
2453
|
customData: customData
|
|
2321
2454
|
};
|
|
2455
|
+
},
|
|
2456
|
+
sendQualityCheckEvent = function sendQualityCheckEvent(_ref2) {
|
|
2457
|
+
var userId = _ref2.userId,
|
|
2458
|
+
topic = _ref2.topic,
|
|
2459
|
+
mediaType = _ref2.mediaType,
|
|
2460
|
+
_ref2$isLongTime = _ref2.isLongTime,
|
|
2461
|
+
isLongTime = _ref2$isLongTime === void 0 ? false : _ref2$isLongTime,
|
|
2462
|
+
_ref2$isResolved = _ref2.isResolved,
|
|
2463
|
+
isResolved = _ref2$isResolved === void 0 ? false : _ref2$isResolved,
|
|
2464
|
+
_ref2$canSendCallMeta = _ref2.canSendCallMetaData,
|
|
2465
|
+
canSendCallMetaData = _ref2$canSendCallMeta === void 0 ? true : _ref2$canSendCallMeta;
|
|
2466
|
+
|
|
2467
|
+
if (mediaType === 'video') {
|
|
2468
|
+
//TODO: Deprecated!
|
|
2469
|
+
_eventsModule.chatEvents.fireEvent('callEvents', {
|
|
2470
|
+
type: isResolved ? 'POOR_VIDEO_CONNECTION_RESOLVED' : 'POOR_VIDEO_CONNECTION',
|
|
2471
|
+
subType: isResolved ? undefined : isLongTime ? 'LONG_TIME' : 'SHORT_TIME',
|
|
2472
|
+
message: 'Poor connection resolved',
|
|
2473
|
+
metadata: {
|
|
2474
|
+
elementId: "uiRemoteVideo-" + topic,
|
|
2475
|
+
topic: topic,
|
|
2476
|
+
userId: userId
|
|
2477
|
+
}
|
|
2478
|
+
});
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
_eventsModule.chatEvents.fireEvent('callEvents', {
|
|
2482
|
+
type: isResolved ? 'POOR_CONNECTION_RESOLVED' : 'POOR_CONNECTION',
|
|
2483
|
+
subType: isResolved ? undefined : isLongTime ? 'LONG_TIME' : 'SHORT_TIME',
|
|
2484
|
+
message: "Poor connection ".concat(isResolved ? 'resolved' : ''),
|
|
2485
|
+
metadata: {
|
|
2486
|
+
media: mediaType,
|
|
2487
|
+
elementId: "uiRemoteVideo-" + topic,
|
|
2488
|
+
topic: topic,
|
|
2489
|
+
userId: userId
|
|
2490
|
+
}
|
|
2491
|
+
});
|
|
2492
|
+
|
|
2493
|
+
if (canSendCallMetaData) {
|
|
2494
|
+
sendCallMetaData({
|
|
2495
|
+
id: isResolved ? callMetaDataTypes.POORCONNECTIONRESOLVED : callMetaDataTypes.POORCONNECTION,
|
|
2496
|
+
userid: userId,
|
|
2497
|
+
content: {
|
|
2498
|
+
title: "Poor Connection ".concat(isResolved ? 'Resolved' : ''),
|
|
2499
|
+
description: topic
|
|
2500
|
+
}
|
|
2501
|
+
});
|
|
2502
|
+
}
|
|
2322
2503
|
};
|
|
2323
2504
|
|
|
2324
2505
|
this.updateToken = function (newToken) {
|
|
@@ -2462,16 +2643,10 @@ function ChatCall(params) {
|
|
|
2462
2643
|
} else {
|
|
2463
2644
|
return false;
|
|
2464
2645
|
}
|
|
2465
|
-
/* if((!currentCallId || currentCallId && threadId != currentCallId) && restrictedMessageTypes.includes(type)){
|
|
2466
|
-
return true;
|
|
2467
|
-
} else {
|
|
2468
|
-
return false
|
|
2469
|
-
} */
|
|
2470
|
-
|
|
2471
2646
|
}
|
|
2472
2647
|
|
|
2473
2648
|
this.handleChatMessages = function (type, messageContent, contentCount, threadId, uniqueId) {
|
|
2474
|
-
consoleLogging && console.debug("[SDK][CALL_MODULE][handleChatMessages]", "type:", type, "threadId:", threadId, "currentCallId:", currentCallId, "shouldNotProcessChatMessage:", shouldNotProcessChatMessage(type, threadId));
|
|
2649
|
+
consoleLogging && console.debug("[SDK][CALL_MODULE][handleChatMessages]", "type:", type, "threadId:", threadId, "currentCallId:", currentCallId, "latestCallRequestId:", latestCallRequestId, "shouldNotProcessChatMessage:", shouldNotProcessChatMessage(type, threadId));
|
|
2475
2650
|
|
|
2476
2651
|
if (shouldNotProcessChatMessage(type, threadId)) {
|
|
2477
2652
|
return;
|
|
@@ -2499,9 +2674,8 @@ function ChatCall(params) {
|
|
|
2499
2674
|
});
|
|
2500
2675
|
|
|
2501
2676
|
if (messageContent.callId > 0) {
|
|
2502
|
-
if
|
|
2503
|
-
|
|
2504
|
-
}
|
|
2677
|
+
// if(!currentCallId ) {
|
|
2678
|
+
latestCallRequestId = messageContent.callId; // }
|
|
2505
2679
|
} else {
|
|
2506
2680
|
_eventsModule.chatEvents.fireEvent('callEvents', {
|
|
2507
2681
|
type: 'PARTNER_RECEIVED_YOUR_CALL',
|
|
@@ -2556,11 +2730,10 @@ function ChatCall(params) {
|
|
|
2556
2730
|
_eventsModule.chatEvents.fireEvent('callEvents', {
|
|
2557
2731
|
type: 'RECEIVE_CALL',
|
|
2558
2732
|
result: messageContent
|
|
2559
|
-
});
|
|
2733
|
+
}); // if(!currentCallId ) {
|
|
2560
2734
|
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
}
|
|
2735
|
+
|
|
2736
|
+
latestCallRequestId = messageContent.callId; // }
|
|
2564
2737
|
} else {
|
|
2565
2738
|
_eventsModule.chatEvents.fireEvent('callEvents', {
|
|
2566
2739
|
type: 'PARTNER_RECEIVED_YOUR_CALL',
|
|
@@ -2585,6 +2758,7 @@ function ChatCall(params) {
|
|
|
2585
2758
|
}
|
|
2586
2759
|
|
|
2587
2760
|
callStop(false, false, false);
|
|
2761
|
+
currentCallId = threadId;
|
|
2588
2762
|
|
|
2589
2763
|
if (chatMessaging.messagesCallbacks[uniqueId]) {
|
|
2590
2764
|
chatMessaging.messagesCallbacks[uniqueId](_utility["default"].createReturnData(false, '', 0, messageContent, contentCount));
|
|
@@ -2740,9 +2914,8 @@ function ChatCall(params) {
|
|
|
2740
2914
|
}
|
|
2741
2915
|
|
|
2742
2916
|
if (messageContent.callId > 0) {
|
|
2743
|
-
if
|
|
2744
|
-
|
|
2745
|
-
}
|
|
2917
|
+
// if(!currentCallId ) {
|
|
2918
|
+
latestCallRequestId = messageContent.callId; // }
|
|
2746
2919
|
}
|
|
2747
2920
|
|
|
2748
2921
|
_eventsModule.chatEvents.fireEvent('callEvents', {
|
|
@@ -3934,9 +4107,9 @@ function ChatCall(params) {
|
|
|
3934
4107
|
});
|
|
3935
4108
|
};
|
|
3936
4109
|
|
|
3937
|
-
function calculateScreenSize(
|
|
3938
|
-
var
|
|
3939
|
-
quality =
|
|
4110
|
+
function calculateScreenSize(_ref3) {
|
|
4111
|
+
var _ref3$quality = _ref3.quality,
|
|
4112
|
+
quality = _ref3$quality === void 0 ? 3 : _ref3$quality;
|
|
3940
4113
|
var screenSize = window.screen,
|
|
3941
4114
|
qualities = [{
|
|
3942
4115
|
width: Math.round(screenSize.width / 3),
|
|
@@ -4654,9 +4827,9 @@ function ChatCall(params) {
|
|
|
4654
4827
|
}
|
|
4655
4828
|
};
|
|
4656
4829
|
|
|
4657
|
-
this.sendCallSticker = function (
|
|
4658
|
-
var
|
|
4659
|
-
sticker =
|
|
4830
|
+
this.sendCallSticker = function (_ref4, callback) {
|
|
4831
|
+
var _ref4$sticker = _ref4.sticker,
|
|
4832
|
+
sticker = _ref4$sticker === void 0 ? _constants.callStickerTypes.RAISE_HAND : _ref4$sticker;
|
|
4660
4833
|
var sendMessageParams = {
|
|
4661
4834
|
chatMessageVOType: _constants.chatMessageVOTypes.CALL_STICKER_SYSTEM_MESSAGE,
|
|
4662
4835
|
typeCode: generalTypeCode,
|
|
@@ -4682,8 +4855,8 @@ function ChatCall(params) {
|
|
|
4682
4855
|
});
|
|
4683
4856
|
};
|
|
4684
4857
|
|
|
4685
|
-
this.recallThreadParticipant = function (
|
|
4686
|
-
var invitees =
|
|
4858
|
+
this.recallThreadParticipant = function (_ref5, callback) {
|
|
4859
|
+
var invitees = _ref5.invitees;
|
|
4687
4860
|
var sendData = {
|
|
4688
4861
|
chatMessageVOType: _constants.chatMessageVOTypes.RECALL_THREAD_PARTICIPANT,
|
|
4689
4862
|
typeCode: generalTypeCode,
|
|
@@ -4719,6 +4892,42 @@ function ChatCall(params) {
|
|
|
4719
4892
|
};
|
|
4720
4893
|
|
|
4721
4894
|
this.deviceManager = _deviceManager["default"];
|
|
4895
|
+
|
|
4896
|
+
this.resetCallStream = function (_ref6, callback) {
|
|
4897
|
+
var userId = _ref6.userId,
|
|
4898
|
+
_ref6$streamType = _ref6.streamType,
|
|
4899
|
+
streamType = _ref6$streamType === void 0 ? 'audio' : _ref6$streamType;
|
|
4900
|
+
return new Promise(function (resolve, reject) {
|
|
4901
|
+
if (userId === 'screenShare' || streamType === 'video') {
|
|
4902
|
+
if (callUsers[userId]) {
|
|
4903
|
+
callUsers[userId].videoTopicManager.recreateTopic().then(function () {
|
|
4904
|
+
resolve();
|
|
4905
|
+
callback && callback({
|
|
4906
|
+
hasError: false
|
|
4907
|
+
});
|
|
4908
|
+
})["catch"](function () {
|
|
4909
|
+
reject();
|
|
4910
|
+
callback && callback({
|
|
4911
|
+
hasError: true
|
|
4912
|
+
});
|
|
4913
|
+
});
|
|
4914
|
+
}
|
|
4915
|
+
} else {
|
|
4916
|
+
callUsers[userId].audioTopicManager.recreateTopic().then(function () {
|
|
4917
|
+
resolve();
|
|
4918
|
+
callback && callback({
|
|
4919
|
+
hasError: false
|
|
4920
|
+
});
|
|
4921
|
+
})["catch"](function () {
|
|
4922
|
+
reject();
|
|
4923
|
+
callback && callback({
|
|
4924
|
+
hasError: true
|
|
4925
|
+
});
|
|
4926
|
+
});
|
|
4927
|
+
}
|
|
4928
|
+
});
|
|
4929
|
+
};
|
|
4930
|
+
|
|
4722
4931
|
this.callStop = callStop;
|
|
4723
4932
|
this.restartMedia = restartMedia;
|
|
4724
4933
|
}
|