New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

webrtc-troubleshoot

Package Overview
Dependencies
Maintainers
2
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webrtc-troubleshoot - npm Package Compare versions

Comparing version 6.1.6 to 7.0.0

LICENSE

2

package.json
{
"name": "webrtc-troubleshoot",
"version": "6.1.6",
"version": "7.0.0",
"description": "A way to add webrtc troubleshooting to your app",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -10,3 +10,3 @@ // adapted from https://github.com/webrtc/testrtc/blob/master/src/js/bandwidth_test.js

super(...arguments);
this.name = 'Bandwidth Test';
this.name = 'Audio Bandwidth Test';
this.maxAudioBitrateKbps = 510;

@@ -137,41 +137,28 @@ this.durationMs = 40000;

gotStats (response) {
const isWebkit = 'WebkitAppearance' in document.documentElement.style;
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
if (isWebkit && response) {
if (!response) {
this.addLog('error', 'Got no response from stats... odd...');
} else {
const results = typeof response.result === 'function' ? response.result() : response;
results.forEach((report) => {
if (report.type === 'ssrc' && report.mediaType === 'audio') {
const rtt = parseInt(report['googRtt'], 10) || 0;
this.rttStats.add(Date.parse(report.timestamp), rtt);
const bytes = parseInt(report['bytesSent'], 10);
this.bweStats.add(Date.parse(report.timestamp), bytes);
// Grab the last stats.
this.jitter = report['googJitterReceived'];
this.packetsLost = report['packetsLost'];
this.packetsSent = report['packetsSent'];
if (report.availableOutgoingBitrate) {
const value = parseInt(report.availableOutgoingBitrate, 10);
this.bweStats.add(new Date(report.timestamp), value);
}
if (report.totalRoundTripTime || report.roundTripTime) {
const value = parseInt(report.totalRoundTripTime || report.roundTripTime, 10);
this.rttStats.add(new Date(report.timestamp), value);
}
if (report.packetsSent) {
this.packetsSent = report.packetsSent;
}
if (report.packetsLost) {
this.packetsLost = report.packetsLost;
}
if (report.frameWidth) {
this.videoStats[0] = report.frameWidth;
}
if (report.frameHeight) {
this.videoStats[1] = report.frameHeight;
}
});
} else if (isFirefox && response) {
for (let j in response) {
let stats = response[j];
if (stats.id.startsWith('outbound_rtcp_audio_')) {
this.rttStats.add(Date.parse(stats.timestamp), parseInt(stats.mozRtt, 10));
// Grab the last stats.
this.jitter = stats.jitter;
this.packetsLost = stats.packetsLost;
} else if (stats.id.startsWith('outbound_rtp_audio_')) {
const bytes = parseInt(stats['bytesSent'], 10);
this.bweStats.add(Date.parse(stats.timestamp), bytes);
this.packetsSent = stats.packetsSent;
}
}
} else if (!response) {
this.addLog('error', 'Got no response from stats... oddd..');
return Promise.reject(new Error('No response from stats'));
} else {
this.addLog('error', 'Only Firefox and Chrome getStats implementations are supported.');
return Promise.reject(new Error('Only Firefox and Chrome getStats implementations are supported.'));
}

@@ -194,6 +181,5 @@

stats.packetsSent = parseInt(this.packetsSent);
stats.jitter = parseInt(this.jitter);
if (this.packetsSent) {
stats.packetLoss = parseInt(this.packetsLost, 10) / parseFloat(this.packetsSent);
stats.packetLoss = parseInt(this.packetsLost || 0, 10) / parseFloat(this.packetsSent);
}

@@ -203,3 +189,2 @@

this.addLog('info', `RTT max: ${stats.rttMax} ms`);
this.addLog('info', `Jitter: ${stats.rttMax} ms`);
this.addLog('info', `Packets sent: ${stats.rttMax} ms`);

@@ -206,0 +191,0 @@ this.addLog('info', `Packet loss %: ${stats.packetLoss}`);

@@ -10,3 +10,3 @@ // adapted from https://github.com/webrtc/testrtc/blob/master/src/js/bandwidth_test.js

super(...arguments);
this.name = 'Bandwidth Test';
this.name = 'Video Bandwidth Test';
this.maxVideoBitrateKbps = 2000;

@@ -16,2 +16,3 @@ this.durationMs = 40000;

this.bweStats = new StatisticsAggregate(0.75 * this.maxVideoBitrateKbps * 1000);
window.bweStats = this.bweStats;
this.rttStats = new StatisticsAggregate();

@@ -156,42 +157,28 @@ this.packetsLost = null;

gotStats (response) {
const isWebkit = 'WebkitAppearance' in document.documentElement.style;
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
if (isWebkit && response) {
if (!response) {
this.addLog('error', 'Got no response from stats... odd...');
} else {
const results = typeof response.result === 'function' ? response.result() : response;
results.forEach((report) => {
if (report.id === 'bweforvideo' && report.googAvailableSendBandwidth) {
const value = parseInt(report['googAvailableSendBandwidth'], 10);
this.bweStats.add(Date.parse(report.timestamp), value);
} else if (report.type === 'ssrc' && report.googRtt) {
const value = parseInt(report['googRtt'], 10);
this.rttStats.add(Date.parse(report.timestamp), value);
// Grab the last stats.
this.videoStats[0] = report['googFrameWidthSent'];
this.videoStats[1] = report['googFrameHeightSent'];
this.packetsLost = report['packetsLost'];
this.packetsSent = report['packetsSent'];
if (report.availableOutgoingBitrate) {
const value = parseInt(report.availableOutgoingBitrate, 10);
this.bweStats.add(new Date(report.timestamp), value);
}
if (report.totalRoundTripTime || report.roundTripTime) {
const value = parseInt(report.totalRoundTripTime || report.roundTripTime, 10);
this.rttStats.add(new Date(report.timestamp), value);
}
if (report.packetsSent) {
this.packetsSent = report.packetsSent;
}
if (report.packetsLost) {
this.packetsLost = report.packetsLost;
}
if (report.frameWidth) {
this.videoStats[0] = report.frameWidth;
}
if (report.frameHeight) {
this.videoStats[1] = report.frameHeight;
}
});
} else if (isFirefox && response) {
for (let j in response) {
let stats = response[j];
if (stats.id.startsWith('outbound_rtcp_video_')) {
this.rttStats.add(Date.parse(stats.timestamp), parseInt(stats.mozRtt, 10));
// Grab the last stats.
this.jitter = stats.jitter;
this.packetsLost = stats.packetsLost;
} else if (stats.id.startsWith('outbound_rtp_video_')) {
// TODO: Get dimensions from getStats when supported in FF.
this.videoStats[0] = 'Not supported on Firefox';
this.videoStats[1] = 'Not supported on Firefox';
this.bitrateMean = stats.bitrateMean;
this.bitrateStdDev = stats.bitrateStdDev;
this.packetsSent = stats.packetsSent;
this.framerateMean = stats.framerateMean;
}
}
} else if (!response) {
this.addLog('error', 'Got no response from stats... oddd..');
} else {
this.addLog('error', 'Only Firefox and Chrome getStats implementations are supported.');
}

@@ -250,3 +237,3 @@ return new Promise((resolve, reject) => {

if (this.packetsSent) {
stats.packetLoss = parseInt(this.packetsLost, 10) / parseFloat(this.packetsSent);
stats.packetLoss = parseInt(this.packetsLost || 0, 10) / parseFloat(this.packetsSent);
}

@@ -253,0 +240,0 @@

@@ -26,3 +26,3 @@ export default class StatisticsAggregate {

}
return Math.round(this.sum / this.count);
return this.sum / this.count;
}

@@ -29,0 +29,0 @@ getMax () {

@@ -14,3 +14,3 @@ /* global WebRTCTroubleshooter */

const result = `test completed ${test.name} ${success ? 'success' : 'failure'} ${res} ${res && res.details ? res.details : 'no results'}`;
console.log(result);
console.log(result, res);
const p = document.createElement('p');

@@ -42,2 +42,6 @@ p.innerText = result;

testSuite.addTest(audioTest);
const audioBandwidthTest = new webRTCTroubleshooter.AudioBandwidthTest({ iceConfig: iceConfig, mediaOptions: mediaOptions });
audioBandwidthTest.promise.then(testCompleted.bind(null, audioBandwidthTest, true), testCompleted.bind(null, audioBandwidthTest, false));
testSuite.addTest(audioBandwidthTest);
}

@@ -44,0 +48,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc