Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "webrtc", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"keywords": ["webrtc", "browser"], | ||
@@ -12,7 +12,8 @@ "repository": { | ||
"dependencies": { | ||
"webrtcsupport": "0.3.2", | ||
"webrtcsupport": "0.4.0", | ||
"wildemitter": "0.0.5", | ||
"rtcpeerconnection": "0.2.0", | ||
"getusermedia": "0.2.0", | ||
"hark": "0.1.1" | ||
"getusermedia": "0.2.1", | ||
"hark": "0.1.1", | ||
"mediastream-gain": "0.0.1" | ||
}, | ||
@@ -19,0 +20,0 @@ "devDependencies": { |
@@ -8,2 +8,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; | ||
var hark = require('hark'); | ||
var GainController = require('mediastream-gain'); | ||
var log; | ||
@@ -90,4 +91,6 @@ | ||
} | ||
self.localStream = self.setupMicVolumeControl(stream); | ||
self.localStream = stream; | ||
self.gainController = new GainController(stream); | ||
// start out somewhat muted if we can track audio | ||
@@ -140,27 +143,2 @@ self.setMicIfEnabled(0.5); | ||
WebRTC.prototype.setupMicVolumeControl = function (stream) { | ||
if (!webrtc.webAudio || !this.config.autoAdjustMic) return stream; | ||
var context = new webkitAudioContext(); | ||
var microphone = context.createMediaStreamSource(stream); | ||
var gainFilter = this.gainFilter = context.createGainNode(); | ||
var destination = context.createMediaStreamDestination(); | ||
var outputStream = destination.stream; | ||
microphone.connect(gainFilter); | ||
gainFilter.connect(destination); | ||
stream.removeTrack(stream.getAudioTracks()[0]); | ||
stream.addTrack(outputStream.getAudioTracks()[0]); | ||
return stream; | ||
}; | ||
// sets the gain input on the microphone if web audio | ||
// is available. | ||
WebRTC.prototype.setMicVolume = function (volume) { | ||
if (!webrtc.webAudio) return; | ||
this.gainFilter.gain.value = volume; | ||
}; | ||
// We do this as a seperate method in order to | ||
@@ -171,3 +149,3 @@ // still leave the "setMicVolume" as a working | ||
if (!this.config.autoAdjustMic) return; | ||
this.setMicVolume(volume); | ||
this.gainController.setGain(volume); | ||
}; | ||
@@ -343,3 +321,3 @@ | ||
},{"getusermedia":4,"hark":6,"rtcpeerconnection":3,"webrtcsupport":2,"wildemitter":5}],2:[function(require,module,exports){ | ||
},{"getusermedia":3,"hark":6,"mediastream-gain":7,"rtcpeerconnection":4,"webrtcsupport":2,"wildemitter":5}],2:[function(require,module,exports){ | ||
// created by @HenrikJoreteg | ||
@@ -357,3 +335,3 @@ var PC = window.mozRTCPeerConnection || window.webkitRTCPeerConnection || window.RTCPeerConnection; | ||
var screenSharing = navigator.userAgent.match('Chrome') && parseInt(navigator.userAgent.match(/Chrome\/(.*) /)[1], 10) >= 26; | ||
var webAudio = !!window.webkitAudioContext; | ||
var AudioContext = window.webkitAudioContext || window.AudioContext; | ||
@@ -365,4 +343,5 @@ // export support flags and constructors.prototype && PC | ||
prefix: prefix, | ||
webAudio: webAudio, | ||
webAudio: !!AudioContext.prototype.createMediaStreamSource, | ||
screenSharing: screenSharing, | ||
AudioContext: AudioContext, | ||
PeerConnection: PC, | ||
@@ -373,3 +352,3 @@ SessionDescription: SessionDescription, | ||
},{}],4:[function(require,module,exports){ | ||
},{}],3:[function(require,module,exports){ | ||
// getUserMedia helper by @HenrikJoreteg | ||
@@ -575,3 +554,30 @@ var func = (navigator.getUserMedia || | ||
},{}],3:[function(require,module,exports){ | ||
},{}],8:[function(require,module,exports){ | ||
// created by @HenrikJoreteg | ||
var PC = window.mozRTCPeerConnection || window.webkitRTCPeerConnection || window.RTCPeerConnection; | ||
var IceCandidate = window.mozRTCIceCandidate || window.RTCIceCandidate; | ||
var SessionDescription = window.mozRTCSessionDescription || window.RTCSessionDescription; | ||
var prefix = function () { | ||
if (window.mozRTCPeerConnection) { | ||
return 'moz'; | ||
} else if (window.webkitRTCPeerConnection) { | ||
return 'webkit'; | ||
} | ||
}(); | ||
var screenSharing = navigator.userAgent.match('Chrome') && parseInt(navigator.userAgent.match(/Chrome\/(.*) /)[1], 10) >= 26; | ||
var webAudio = !!window.webkitAudioContext; | ||
// export support flags and constructors.prototype && PC | ||
module.exports = { | ||
support: !!PC, | ||
dataChannel: !!(PC && PC.prototype && PC.prototype.createDataChannel), | ||
prefix: prefix, | ||
webAudio: webAudio, | ||
screenSharing: screenSharing, | ||
PeerConnection: PC, | ||
SessionDescription: SessionDescription, | ||
IceCandidate: IceCandidate | ||
}; | ||
},{}],4:[function(require,module,exports){ | ||
var WildEmitter = require('wildemitter'); | ||
@@ -714,3 +720,3 @@ var webrtc = require('webrtcsupport'); | ||
},{"webrtcsupport":2,"wildemitter":5}],6:[function(require,module,exports){ | ||
},{"webrtcsupport":8,"wildemitter":5}],6:[function(require,module,exports){ | ||
var WildEmitter = require('wildemitter'); | ||
@@ -808,4 +814,51 @@ | ||
},{"wildemitter":5}]},{},[1])(1) | ||
},{"wildemitter":5}],7:[function(require,module,exports){ | ||
var support = require('webrtcsupport'); | ||
function GainController(stream) { | ||
this.support = support.webAudio; | ||
// set our starting value | ||
this.gain = 1; | ||
if (this.support) { | ||
var context = this.context = new support.AudioContext(); | ||
this.microphone = context.createMediaStreamSource(stream); | ||
this.gainFilter = context.createGain(); | ||
this.destination = context.createMediaStreamDestination(); | ||
this.outputStream = this.destination.stream; | ||
this.microphone.connect(this.gainFilter); | ||
this.gainFilter.connect(this.destination); | ||
stream.removeTrack(stream.getAudioTracks()[0]); | ||
stream.addTrack(this.outputStream.getAudioTracks()[0]); | ||
} | ||
this.stream = stream; | ||
} | ||
// setting | ||
GainController.prototype.setGain = function (val) { | ||
// check for support | ||
if (!this.support) return; | ||
this.gainFilter.gain.value = val; | ||
this.gain = val; | ||
}; | ||
GainController.prototype.getGain = function () { | ||
return this.gain; | ||
}; | ||
GainController.prototype.off = function () { | ||
return this.setGain(0); | ||
}; | ||
GainController.prototype.on = function () { | ||
this.setGain(1); | ||
}; | ||
module.exports = GainController; | ||
},{"webrtcsupport":2}]},{},[1])(1) | ||
}); | ||
; |
@@ -6,2 +6,3 @@ var webrtc = require('webrtcsupport'); | ||
var hark = require('hark'); | ||
var GainController = require('mediastream-gain'); | ||
var log; | ||
@@ -88,4 +89,6 @@ | ||
} | ||
self.localStream = self.setupMicVolumeControl(stream); | ||
self.localStream = stream; | ||
self.gainController = new GainController(stream); | ||
// start out somewhat muted if we can track audio | ||
@@ -138,27 +141,2 @@ self.setMicIfEnabled(0.5); | ||
WebRTC.prototype.setupMicVolumeControl = function (stream) { | ||
if (!webrtc.webAudio || !this.config.autoAdjustMic) return stream; | ||
var context = new webkitAudioContext(); | ||
var microphone = context.createMediaStreamSource(stream); | ||
var gainFilter = this.gainFilter = context.createGainNode(); | ||
var destination = context.createMediaStreamDestination(); | ||
var outputStream = destination.stream; | ||
microphone.connect(gainFilter); | ||
gainFilter.connect(destination); | ||
stream.removeTrack(stream.getAudioTracks()[0]); | ||
stream.addTrack(outputStream.getAudioTracks()[0]); | ||
return stream; | ||
}; | ||
// sets the gain input on the microphone if web audio | ||
// is available. | ||
WebRTC.prototype.setMicVolume = function (volume) { | ||
if (!webrtc.webAudio) return; | ||
this.gainFilter.gain.value = volume; | ||
}; | ||
// We do this as a seperate method in order to | ||
@@ -169,3 +147,3 @@ // still leave the "setMicVolume" as a working | ||
if (!this.config.autoAdjustMic) return; | ||
this.setMicVolume(volume); | ||
this.gainController.setGain(volume); | ||
}; | ||
@@ -172,0 +150,0 @@ |
35550
994
6
+ Addedmediastream-gain@0.0.1
+ Addedgetusermedia@0.2.1(transitive)
+ Addedmediastream-gain@0.0.1(transitive)
+ Addedwebrtcsupport@0.4.0(transitive)
- Removedgetusermedia@0.2.0(transitive)
Updatedgetusermedia@0.2.1
Updatedwebrtcsupport@0.4.0