Browse Source

Disable enableRenegotiationSupport per default to make the stuff mergeable.

pull/112/head
Simon Eisenmann 11 years ago
parent
commit
4903fec5cd
  1. 99
      static/js/mediastream/usermedia.js

99
static/js/mediastream/usermedia.js

@ -24,6 +24,10 @@ define(['jquery', 'underscore', 'audiocontext', 'webrtc.adapter'], function($, _
var context = AudioContext ? new AudioContext() : null; var context = AudioContext ? new AudioContext() : null;
var peerconnections = {}; var peerconnections = {};
// Disabled for now until browser support matures. If enabled this totally breaks
// Firefox and Chrome with Firefox interop.
var enableRenegotiationSupport = false;
var UserMedia = function(options) { var UserMedia = function(options) {
this.options = $.extend({}, options); this.options = $.extend({}, options);
@ -262,29 +266,50 @@ define(['jquery', 'underscore', 'audiocontext', 'webrtc.adapter'], function($, _
UserMedia.prototype.applyAudioMute = function(mute) { UserMedia.prototype.applyAudioMute = function(mute) {
this.audioMute = !!mute; var m = !!mute;
if (this.localStream) { if (!enableRenegotiationSupport) {
var audioTracks = this.localStream.getAudioTracks(); // Disable streams only - does not require renegotiation but keeps mic
if (audioTracks.length === 0) { // active and the stream will transmit silence.
//console.log('No local audio available.');
return; if (this.localStream) {
}
var audioTracks = this.localStream.getAudioTracks();
if (audioTracks.length === 0) {
//console.log('No local audio available.');
return;
}
for (var i = 0; i < audioTracks.length; i++) {
audioTracks[i].enabled = !mute;
}
if (mute) {
console.log("Local audio muted by disabling audio tracks.");
} else {
console.log("Local audio unmuted by enabling audio tracks.");
}
for (i = 0; i < audioTracks.length; i++) {
audioTracks[i].enabled = !mute;
} }
if (mute) { } else {
console.log("Local audio muted.")
// Remove audio stream, by creating a new stream and doing renegotiation. This
// is the way to go to disable the mic when audio is muted.
if (this.localStream) {
if (this.audioMute !== m) {
this.audioMute = m;
this.doGetUserMediaWithConstraints();
}
} else { } else {
console.log("Local audio unmuted.") this.audioMute = m;
} }
} }
return mute; return m;
}; };
@ -292,34 +317,46 @@ define(['jquery', 'underscore', 'audiocontext', 'webrtc.adapter'], function($, _
var m = !!mute; var m = !!mute;
if (this.localStream) { if (!enableRenegotiationSupport) {
/*var videoTracks = this.localStream.getVideoTracks(); // Disable streams only - does not require renegotiation but keeps camera
if (videoTracks.length === 0) { // active and the stream will transmit black.
//console.log('No local video available.');
return; if (this.localStream) {
} var videoTracks = this.localStream.getVideoTracks();
if (videoTracks.length === 0) {
//console.log('No local video available.');
return;
}
for (var i = 0; i < videoTracks.length; i++) {
videoTracks[i].enabled = !mute;
}
if (mute) {
console.log("Local video muted by disabling video tracks.");
} else {
console.log("Local video unmuted by enabling video tracks.");
}
for (i = 0; i < videoTracks.length; i++) {
videoTracks[i].enabled = !mute;
} }
} else {
if (mute) { // Removevideo stream, by creating a new stream and doing renegotiation. This
console.log("Local video muted.") // is the way to go to disable the camera when video is muted.
} else {
console.log("Local video unmuted.")
}*/
if (this.videoMute !== m) { if (this.localStream) {
if (this.videoMute !== m) {
this.videoMute = m;
this.doGetUserMediaWithConstraints();
}
} else {
this.videoMute = m; this.videoMute = m;
this.doGetUserMediaWithConstraints();
} }
} else {
this.videoMute = m;
} }
return mute; return m;
}; };

Loading…
Cancel
Save