Fixes the issue with not receiving video in chrome from firefox when trickle is enabled.

This commit is contained in:
hristoterezov 2014-11-14 13:56:02 +02:00
parent f5189d5cdc
commit dd608080b3
1 changed files with 51 additions and 31 deletions

View File

@ -23,7 +23,7 @@ function JingleSession(me, sid, connection) {
this.ice_config = {}; this.ice_config = {};
this.drip_container = []; this.drip_container = [];
this.usetrickle = false; this.usetrickle = true;
this.usepranswer = false; // early transport warmup -- mind you, this might fail. depends on webrtc issue 1718 this.usepranswer = false; // early transport warmup -- mind you, this might fail. depends on webrtc issue 1718
this.usedrip = false; // dripping is sending trickle candidates not one-by-one this.usedrip = false; // dripping is sending trickle candidates not one-by-one
@ -359,7 +359,7 @@ JingleSession.prototype.createdOffer = function (sdp) {
var self = this; var self = this;
this.localSDP = new SDP(sdp.sdp); this.localSDP = new SDP(sdp.sdp);
//this.localSDP.mangle(); //this.localSDP.mangle();
if (this.usetrickle) { var sendJingle = function () {
var init = $iq({to: this.peerjid, var init = $iq({to: this.peerjid,
type: 'set'}) type: 'set'})
.c('jingle', {xmlns: 'urn:xmpp:jingle:1', .c('jingle', {xmlns: 'urn:xmpp:jingle:1',
@ -388,6 +388,15 @@ JingleSession.prototype.createdOffer = function (sdp) {
sdp.sdp = this.localSDP.raw; sdp.sdp = this.localSDP.raw;
this.peerconnection.setLocalDescription(sdp, this.peerconnection.setLocalDescription(sdp,
function () { function () {
if(this.usetrickle)
{
RTC.getLocalSSRC(function(ssrc)
{
sendJingle(ssrc);
$(document).trigger('setLocalDescription.jingle', [self.sid]);
});
}
else
$(document).trigger('setLocalDescription.jingle', [self.sid]); $(document).trigger('setLocalDescription.jingle', [self.sid]);
//console.log('setLocalDescription success'); //console.log('setLocalDescription success');
}, },
@ -579,17 +588,27 @@ JingleSession.prototype.createdAnswer = function (sdp, provisional) {
//this.localSDP.mangle(); //this.localSDP.mangle();
this.usepranswer = provisional === true; this.usepranswer = provisional === true;
if (this.usetrickle) { if (this.usetrickle) {
if (!this.usepranswer) { if (this.usepranswer) {
var accept = $iq({to: this.peerjid, sdp.type = 'pranswer';
for (var i = 0; i < this.localSDP.media.length; i++) {
this.localSDP.media[i] = this.localSDP.media[i].replace('a=sendrecv\r\n', 'a=inactive\r\n');
}
this.localSDP.raw = this.localSDP.session + '\r\n' + this.localSDP.media.join('');
}
}
var self = this;
var sendJingle = function (ssrcs) {
var accept = $iq({to: self.peerjid,
type: 'set'}) type: 'set'})
.c('jingle', {xmlns: 'urn:xmpp:jingle:1', .c('jingle', {xmlns: 'urn:xmpp:jingle:1',
action: 'session-accept', action: 'session-accept',
initiator: this.initiator, initiator: self.initiator,
responder: this.responder, responder: self.responder,
sid: this.sid }); sid: self.sid });
var publicLocalDesc = simulcast.reverseTransformLocalDescription(sdp); var publicLocalDesc = simulcast.reverseTransformLocalDescription(sdp);
var publicLocalSDP = new SDP(publicLocalDesc.sdp); var publicLocalSDP = new SDP(publicLocalDesc.sdp);
publicLocalSDP.toJingle(accept, this.initiator == this.me ? 'initiator' : 'responder'); publicLocalSDP.toJingle(accept, self.initiator == self.me ? 'initiator' : 'responder', ssrcs);
this.connection.sendIQ(accept, this.connection.sendIQ(accept,
function () { function () {
var ack = {}; var ack = {};
@ -605,19 +624,20 @@ JingleSession.prototype.createdAnswer = function (sdp, provisional) {
$(document).trigger('error.jingle', [self.sid, error]); $(document).trigger('error.jingle', [self.sid, error]);
}, },
10000); 10000);
} else {
sdp.type = 'pranswer';
for (var i = 0; i < this.localSDP.media.length; i++) {
this.localSDP.media[i] = this.localSDP.media[i].replace('a=sendrecv\r\n', 'a=inactive\r\n');
}
this.localSDP.raw = this.localSDP.session + '\r\n' + this.localSDP.media.join('');
}
} }
sdp.sdp = this.localSDP.raw; sdp.sdp = this.localSDP.raw;
this.peerconnection.setLocalDescription(sdp, this.peerconnection.setLocalDescription(sdp,
function () { function () {
$(document).trigger('setLocalDescription.jingle', [self.sid]);
//console.log('setLocalDescription success'); //console.log('setLocalDescription success');
if (self.usetrickle && !self.usepranswer) {
RTC.getLocalSSRC(self, function (ssrc) {
sendJingle(ssrc);
$(document).trigger('setLocalDescription.jingle', [self.sid]);
});
}
else
$(document).trigger('setLocalDescription.jingle', [self.sid]);
}, },
function (e) { function (e) {
console.error('setLocalDescription failed', e); console.error('setLocalDescription failed', e);