Merge pull request #102 from jitsi/gumchanges
use only a single GUM call
This commit is contained in:
commit
61a051b135
58
app.js
58
app.js
|
@ -69,6 +69,24 @@ function init() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
obtainAudioAndVideoPermissions(function (stream) {
|
||||||
|
var audioStream = new webkitMediaStream(stream);
|
||||||
|
var videoStream = new webkitMediaStream(stream);
|
||||||
|
var videoTracks = stream.getVideoTracks();
|
||||||
|
var audioTracks = stream.getAudioTracks();
|
||||||
|
for (var i = 0; i < videoTracks.length; i++) {
|
||||||
|
audioStream.removeTrack(videoTracks[i]);
|
||||||
|
}
|
||||||
|
VideoLayout.changeLocalAudio(audioStream);
|
||||||
|
startLocalRtpStatsCollector(audioStream);
|
||||||
|
|
||||||
|
for (i = 0; i < audioTracks.length; i++) {
|
||||||
|
videoStream.removeTrack(audioTracks[i]);
|
||||||
|
}
|
||||||
|
VideoLayout.changeLocalVideo(videoStream, true);
|
||||||
|
maybeDoJoin();
|
||||||
|
});
|
||||||
|
|
||||||
var jid = document.getElementById('jid').value || config.hosts.anonymousdomain || config.hosts.domain || window.location.hostname;
|
var jid = document.getElementById('jid').value || config.hosts.anonymousdomain || config.hosts.domain || window.location.hostname;
|
||||||
connect(jid);
|
connect(jid);
|
||||||
}
|
}
|
||||||
|
@ -100,17 +118,11 @@ function connect(jid, password) {
|
||||||
if (config.useStunTurn) {
|
if (config.useStunTurn) {
|
||||||
connection.jingle.getStunAndTurnCredentials();
|
connection.jingle.getStunAndTurnCredentials();
|
||||||
}
|
}
|
||||||
obtainAudioAndVideoPermissions(function () {
|
|
||||||
getUserMediaWithConstraints(['audio'], audioStreamReady,
|
|
||||||
function (error) {
|
|
||||||
console.error('failed to obtain audio stream - stop', error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('connect').disabled = true;
|
document.getElementById('connect').disabled = true;
|
||||||
|
|
||||||
if(password)
|
if(password)
|
||||||
authenticatedUser = true;
|
authenticatedUser = true;
|
||||||
|
maybeDoJoin();
|
||||||
} else if (status === Strophe.Status.CONNFAIL) {
|
} else if (status === Strophe.Status.CONNFAIL) {
|
||||||
if(msg === 'x-strophe-bad-non-anon-jid') {
|
if(msg === 'x-strophe-bad-non-anon-jid') {
|
||||||
anonymousConnectionFailed = true;
|
anonymousConnectionFailed = true;
|
||||||
|
@ -146,41 +158,21 @@ function obtainAudioAndVideoPermissions(callback) {
|
||||||
getUserMediaWithConstraints(
|
getUserMediaWithConstraints(
|
||||||
['audio', 'video'],
|
['audio', 'video'],
|
||||||
function (avStream) {
|
function (avStream) {
|
||||||
avStream.stop();
|
callback(avStream);
|
||||||
callback();
|
|
||||||
},
|
},
|
||||||
function (error) {
|
function (error) {
|
||||||
console.error('failed to obtain audio/video stream - stop', error);
|
console.error('failed to obtain audio/video stream - stop', error);
|
||||||
});
|
},
|
||||||
|
config.resolution || '360');
|
||||||
}
|
}
|
||||||
|
|
||||||
function audioStreamReady(stream) {
|
function maybeDoJoin() {
|
||||||
|
if (connection && connection.connected && Strophe.getResourceFromJid(connection.jid) // .connected is true while connecting?
|
||||||
VideoLayout.changeLocalAudio(stream);
|
&& (connection.jingle.localAudio || connection.jingle.localVideo)) {
|
||||||
|
|
||||||
startLocalRtpStatsCollector(stream);
|
|
||||||
|
|
||||||
if (RTC.browser !== 'firefox') {
|
|
||||||
getUserMediaWithConstraints(['video'],
|
|
||||||
videoStreamReady,
|
|
||||||
videoStreamFailed,
|
|
||||||
config.resolution || '360');
|
|
||||||
} else {
|
|
||||||
doJoin();
|
doJoin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function videoStreamReady(stream) {
|
|
||||||
VideoLayout.changeLocalVideo(stream, true);
|
|
||||||
|
|
||||||
doJoin();
|
|
||||||
}
|
|
||||||
|
|
||||||
function videoStreamFailed(error) {
|
|
||||||
console.warn("Failed to obtain video stream - continue anyway", error);
|
|
||||||
|
|
||||||
doJoin();
|
|
||||||
}
|
|
||||||
|
|
||||||
function doJoin() {
|
function doJoin() {
|
||||||
var roomnode = null;
|
var roomnode = null;
|
||||||
|
|
Loading…
Reference in New Issue