Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webrtc

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webrtc - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

4

package.json
{
"name": "webrtc",
"version": "0.5.1",
"version": "0.5.2",
"keywords": ["webrtc", "browser"],

@@ -17,3 +17,3 @@ "repository": {

"hark": "0.1.1",
"mediastream-gain": "0.0.2",
"mediastream-gain": "0.1.0",
"mockconsole": "0.0.1"

@@ -20,0 +20,0 @@ },

@@ -347,3 +347,3 @@ (function(e){if("function"==typeof bootstrap)bootstrap("webrtc",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeWebRTC=e}else"undefined"!=typeof window?window.WebRTC=e():global.WebRTC=e()})(function(){var define,ses,bootstrap,module,exports;

},{"getusermedia":3,"hark":6,"mediastream-gain":7,"mockconsole":8,"rtcpeerconnection":4,"webrtcsupport":2,"wildemitter":5}],2:[function(require,module,exports){
},{"getusermedia":3,"hark":6,"mediastream-gain":8,"mockconsole":7,"rtcpeerconnection":4,"webrtcsupport":2,"wildemitter":5}],2:[function(require,module,exports){
// created by @HenrikJoreteg

@@ -579,3 +579,3 @@ var PC = window.mozRTCPeerConnection || window.webkitRTCPeerConnection || window.RTCPeerConnection;

},{}],8:[function(require,module,exports){
},{}],7:[function(require,module,exports){
var methods = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(",");

@@ -620,4 +620,97 @@ var l = methods.length;

},{}],4:[function(require,module,exports){
},{}],6:[function(require,module,exports){
var WildEmitter = require('wildemitter');
function getMaxVolume (analyser, fftBins) {
var maxVolume = -Infinity;
analyser.getFloatFrequencyData(fftBins);
for(var i=0, ii=fftBins.length; i < ii; i++) {
if (fftBins[i] > maxVolume && fftBins[i] < 0) {
maxVolume = fftBins[i];
}
};
return maxVolume;
}
module.exports = function(stream, options) {
var harker = new WildEmitter();
// make it not break in non-supported browsers
if (!window.webkitAudioContext) return harker;
//Config
var options = options || {},
smoothing = (options.smoothing || 0.5),
interval = (options.interval || 100),
threshold = options.threshold,
play = options.play;
//Setup Audio Context
var audioContext = new webkitAudioContext();
var sourceNode, fftBins, analyser;
analyser = audioContext.createAnalyser();
analyser.fftSize = 512;
analyser.smoothingTimeConstant = smoothing;
fftBins = new Float32Array(analyser.fftSize);
if (stream.jquery) stream = stream[0];
if (stream instanceof HTMLAudioElement) {
//Audio Tag
sourceNode = audioContext.createMediaElementSource(stream);
if (typeof play === 'undefined') play = true;
threshold = threshold || -65;
} else {
//WebRTC Stream
sourceNode = audioContext.createMediaStreamSource(stream);
threshold = threshold || -45;
}
sourceNode.connect(analyser);
if (play) analyser.connect(audioContext.destination);
harker.speaking = false;
harker.setThreshold = function(t) {
threshold = t;
};
harker.setInterval = function(i) {
interval = i;
};
// Poll the analyser node to determine if speaking
// and emit events if changed
var looper = function() {
setTimeout(function() {
var currentVolume = getMaxVolume(analyser, fftBins);
harker.emit('volume_change', currentVolume, threshold);
if (currentVolume > threshold) {
if (!harker.speaking) {
harker.speaking = true;
harker.emit('speaking');
}
} else {
if (harker.speaking) {
harker.speaking = false;
harker.emit('stopped_speaking');
}
}
looper();
}, interval);
};
looper();
return harker;
}
},{"wildemitter":5}],4:[function(require,module,exports){
var WildEmitter = require('wildemitter');
var webrtc = require('webrtcsupport');

@@ -759,96 +852,3 @@

},{"webrtcsupport":9,"wildemitter":5}],6:[function(require,module,exports){
var WildEmitter = require('wildemitter');
function getMaxVolume (analyser, fftBins) {
var maxVolume = -Infinity;
analyser.getFloatFrequencyData(fftBins);
for(var i=0, ii=fftBins.length; i < ii; i++) {
if (fftBins[i] > maxVolume && fftBins[i] < 0) {
maxVolume = fftBins[i];
}
};
return maxVolume;
}
module.exports = function(stream, options) {
var harker = new WildEmitter();
// make it not break in non-supported browsers
if (!window.webkitAudioContext) return harker;
//Config
var options = options || {},
smoothing = (options.smoothing || 0.5),
interval = (options.interval || 100),
threshold = options.threshold,
play = options.play;
//Setup Audio Context
var audioContext = new webkitAudioContext();
var sourceNode, fftBins, analyser;
analyser = audioContext.createAnalyser();
analyser.fftSize = 512;
analyser.smoothingTimeConstant = smoothing;
fftBins = new Float32Array(analyser.fftSize);
if (stream.jquery) stream = stream[0];
if (stream instanceof HTMLAudioElement) {
//Audio Tag
sourceNode = audioContext.createMediaElementSource(stream);
if (typeof play === 'undefined') play = true;
threshold = threshold || -65;
} else {
//WebRTC Stream
sourceNode = audioContext.createMediaStreamSource(stream);
threshold = threshold || -45;
}
sourceNode.connect(analyser);
if (play) analyser.connect(audioContext.destination);
harker.speaking = false;
harker.setThreshold = function(t) {
threshold = t;
};
harker.setInterval = function(i) {
interval = i;
};
// Poll the analyser node to determine if speaking
// and emit events if changed
var looper = function() {
setTimeout(function() {
var currentVolume = getMaxVolume(analyser, fftBins);
harker.emit('volume_change', currentVolume, threshold);
if (currentVolume > threshold) {
if (!harker.speaking) {
harker.speaking = true;
harker.emit('speaking');
}
} else {
if (harker.speaking) {
harker.speaking = false;
harker.emit('stopped_speaking');
}
}
looper();
}, interval);
};
looper();
return harker;
}
},{"wildemitter":5}],7:[function(require,module,exports){
},{"webrtcsupport":9,"wildemitter":5}],8:[function(require,module,exports){
var support = require('webrtcsupport');

@@ -858,3 +858,3 @@

function GainController(stream) {
this.support = support.webAudio;
this.support = support.webAudio && support.mediaStream;

@@ -861,0 +861,0 @@ // set our starting value

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