Fixes the issue with the chrome video that is not displayed in firefox.

This commit is contained in:
hristoterezov 2014-11-14 17:44:38 +02:00
parent dd608080b3
commit 2e26c212a2
4 changed files with 37 additions and 4 deletions

24
app.js
View File

@ -13,6 +13,7 @@ var roomName = null;
var ssrc2jid = {}; var ssrc2jid = {};
var mediaStreams = []; var mediaStreams = [];
var bridgeIsDown = false; var bridgeIsDown = false;
var notReceivedSSRCs = [];
/** /**
* The stats collector that process stats data and triggers updates to app.js. * The stats collector that process stats data and triggers updates to app.js.
@ -270,7 +271,7 @@ function waitForRemoteVideo(selector, ssrc, stream) {
videoSrcToSsrc[selector.attr('src')] = ssrc; videoSrcToSsrc[selector.attr('src')] = ssrc;
} else { } else {
console.warn("No ssrc given for video", selector); console.warn("No ssrc given for video", selector);
messageHandler.showError('Warning', 'No ssrc was given for the video.'); // messageHandler.showError('Warning', 'No ssrc was given for the video.');
} }
$(document).trigger('videoactive.jingle', [selector]); $(document).trigger('videoactive.jingle', [selector]);
@ -331,6 +332,26 @@ function waitForPresence(data, sid) {
} }
} }
if(RTC.browser == "firefox")
{
if((notReceivedSSRCs.length == 0) ||
!ssrc2jid[notReceivedSSRCs[notReceivedSSRCs.length - 1]])
{
// TODO(gp) limit wait duration to 1 sec.
setTimeout(function(d, s) {
return function() {
waitForPresence(d, s);
}
}(data, sid), 250);
return;
}
thessrc = notReceivedSSRCs.pop();
if (ssrc2jid[thessrc]) {
data.peerjid = ssrc2jid[thessrc];
}
}
// NOTE(gp) now that we have simulcast, a media stream can have more than 1 // NOTE(gp) now that we have simulcast, a media stream can have more than 1
// ssrc. We should probably take that into account in our MediaStream // ssrc. We should probably take that into account in our MediaStream
// wrapper. // wrapper.
@ -853,6 +874,7 @@ $(document).bind('presence.muc', function (event, jid, info, pres) {
//console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc')); //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
var ssrcV = ssrc.getAttribute('ssrc'); var ssrcV = ssrc.getAttribute('ssrc');
ssrc2jid[ssrcV] = jid; ssrc2jid[ssrcV] = jid;
notReceivedSSRCs.push(ssrcV);
var type = ssrc.getAttribute('type'); var type = ssrc.getAttribute('type');
ssrc2videoType[ssrcV] = type; ssrc2videoType[ssrcV] = type;

View File

@ -454,7 +454,7 @@ ColibriFocus.prototype.createdConference = function (result) {
'a=rtcp-fb:100 ccm fir\r\n' + 'a=rtcp-fb:100 ccm fir\r\n' +
'a=rtcp-fb:100 nack\r\n' + 'a=rtcp-fb:100 nack\r\n' +
'a=rtcp-fb:100 nack pli\r\n' + 'a=rtcp-fb:100 nack pli\r\n' +
'a=rtcp-fb:100 goog-remb\r\n' + // 'a=rtcp-fb:100 goog-remb\r\n' +
'a=rtpmap:116 red/90000\r\n' + 'a=rtpmap:116 red/90000\r\n' +
'a=rtpmap:117 ulpfec/90000\r\n' + 'a=rtpmap:117 ulpfec/90000\r\n' +
(config.useRtcpMux ? 'a=rtcp-mux\r\n' : '') + (config.useRtcpMux ? 'a=rtcp-mux\r\n' : '') +

View File

@ -530,6 +530,14 @@ function setupRTC() {
callback(null); callback(null);
}); });
}; };
RTC.getStreamID = function (stream) {
var tracks = stream.getVideoTracks();
if(!tracks || tracks.length == 0)
{
tracks = stream.getAudioTracks();
}
return tracks[0].id.replace(/[\{,\}]/g,"");
}
} }
} else if (navigator.webkitGetUserMedia) { } else if (navigator.webkitGetUserMedia) {
console.log('This appears to be Chrome'); console.log('This appears to be Chrome');
@ -559,6 +567,9 @@ function setupRTC() {
RTC.getLocalSSRC = function (session, callback) { RTC.getLocalSSRC = function (session, callback) {
callback(null); callback(null);
} }
RTC.getStreamID = function (stream) {
return stream.id;
}
} }
if (RTC === null) { if (RTC === null) {
try { console.log('Browser does not appear to be WebRTC-capable'); } catch (e) { } try { console.log('Browser does not appear to be WebRTC-capable'); } catch (e) { }

View File

@ -23,7 +23,7 @@ var VideoLayout = (function (my) {
connection.jingle.localVideo = stream; connection.jingle.localVideo = stream;
var localVideo = document.createElement('video'); var localVideo = document.createElement('video');
localVideo.id = 'localVideo_' + stream.id; localVideo.id = 'localVideo_' + RTC.getStreamID(stream);
localVideo.autoplay = true; localVideo.autoplay = true;
localVideo.volume = 0; // is it required if audio is separated ? localVideo.volume = 0; // is it required if audio is separated ?
localVideo.oncontextmenu = function () { return false; }; localVideo.oncontextmenu = function () { return false; };
@ -427,7 +427,7 @@ var VideoLayout = (function (my) {
? document.createElement('video') ? document.createElement('video')
: document.createElement('audio'); : document.createElement('audio');
var id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') var id = (isVideo ? 'remoteVideo_' : 'remoteAudio_')
+ sid + '_' + stream.id; + sid + '_' + RTC.getStreamID(stream);
element.id = id; element.id = id;
element.autoplay = true; element.autoplay = true;