implement muting in a safe way, fixes #41
This commit is contained in:
parent
58a4243627
commit
b78fda3a55
|
@ -55,6 +55,8 @@ function ColibriFocus(connection, bridgejid) {
|
||||||
this.addssrc = [];
|
this.addssrc = [];
|
||||||
// ssrc lines to be removed on next update
|
// ssrc lines to be removed on next update
|
||||||
this.removessrc = [];
|
this.removessrc = [];
|
||||||
|
// pending mute/unmute video op that modify local description
|
||||||
|
this.pendingop = null;
|
||||||
|
|
||||||
// container for candidates from the focus
|
// container for candidates from the focus
|
||||||
// gathered before confid is known
|
// gathered before confid is known
|
||||||
|
@ -802,8 +804,8 @@ ColibriFocus.prototype.terminate = function (session, reason) {
|
||||||
|
|
||||||
ColibriFocus.prototype.modifySources = function () {
|
ColibriFocus.prototype.modifySources = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (!(this.addssrc.length || this.removessrc.length)) return;
|
|
||||||
if (this.peerconnection.signalingState == 'closed') return;
|
if (this.peerconnection.signalingState == 'closed') return;
|
||||||
|
if (!(this.addssrc.length || this.removessrc.length || this.pendingop !== null)) return;
|
||||||
|
|
||||||
// FIXME: this is a big hack
|
// FIXME: this is a big hack
|
||||||
// https://code.google.com/p/webrtc/issues/detail?id=2688
|
// https://code.google.com/p/webrtc/issues/detail?id=2688
|
||||||
|
@ -844,6 +846,25 @@ ColibriFocus.prototype.modifySources = function () {
|
||||||
self.peerconnection.createAnswer(
|
self.peerconnection.createAnswer(
|
||||||
function (modifiedAnswer) {
|
function (modifiedAnswer) {
|
||||||
console.log('modifiedAnswer created');
|
console.log('modifiedAnswer created');
|
||||||
|
|
||||||
|
// change video direction, see https://github.com/jitsi/jitmeet/issues/41
|
||||||
|
if (self.pendingop !== null) {
|
||||||
|
var sdp = new SDP(modifiedAnswer.sdp);
|
||||||
|
if (sdp.media.length > 1) {
|
||||||
|
switch(self.pendingop) {
|
||||||
|
case 'mute':
|
||||||
|
sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
|
||||||
|
break;
|
||||||
|
case 'unmute':
|
||||||
|
sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sdp.raw = sdp.session + sdp.media.join('');
|
||||||
|
modifiedAnswer.sdp = sdp.raw;
|
||||||
|
}
|
||||||
|
self.pendingop = null;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: pushing down an answer while ice connection state
|
// FIXME: pushing down an answer while ice connection state
|
||||||
// is still checking is bad...
|
// is still checking is bad...
|
||||||
//console.log(self.peerconnection.iceConnectionState);
|
//console.log(self.peerconnection.iceConnectionState);
|
||||||
|
@ -900,6 +921,15 @@ ColibriFocus.prototype.modifySources = function () {
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ColibriFocus.prototype.hardMuteVideo = function (muted) {
|
||||||
|
this.pendingop = muted ? 'mute' : 'unmute';
|
||||||
|
this.modifySources();
|
||||||
|
|
||||||
|
this.localStream.getVideoTracks.forEach(function (track) {
|
||||||
|
track.enabled = !muted;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// A colibri session is similar to a jingle session, it just implements some things differently
|
// A colibri session is similar to a jingle session, it just implements some things differently
|
||||||
// FIXME: inherit jinglesession, see https://github.com/legastero/Jingle-RTCPeerConnection/blob/master/index.js
|
// FIXME: inherit jinglesession, see https://github.com/legastero/Jingle-RTCPeerConnection/blob/master/index.js
|
||||||
function ColibriSession(me, sid, connection) {
|
function ColibriSession(me, sid, connection) {
|
||||||
|
|
Loading…
Reference in New Issue