use only a single GUM call
This commit is contained in:
parent
7f9bf974fb
commit
54ea1da98e
42
app.js
42
app.js
|
@ -100,11 +100,23 @@ function connect(jid, password) {
|
||||||
if (config.useStunTurn) {
|
if (config.useStunTurn) {
|
||||||
connection.jingle.getStunAndTurnCredentials();
|
connection.jingle.getStunAndTurnCredentials();
|
||||||
}
|
}
|
||||||
obtainAudioAndVideoPermissions(function () {
|
obtainAudioAndVideoPermissions(function (stream) {
|
||||||
getUserMediaWithConstraints(['audio'], audioStreamReady,
|
audioStream = new webkitMediaStream(stream);
|
||||||
function (error) {
|
videoStream = new webkitMediaStream(stream);
|
||||||
console.error('failed to obtain audio stream - stop', error);
|
var videoTracks = stream.getVideoTracks();
|
||||||
});
|
var audioTracks = stream.getAudioTracks();
|
||||||
|
for (var i = 0; i < videoTracks.length; i++) {
|
||||||
|
audioStream.removeTrack(videoTracks[i]);
|
||||||
|
}
|
||||||
|
audioStreamReady(audioStream);
|
||||||
|
VideoLayout.changeLocalAudio(audioStream);
|
||||||
|
startLocalRtpStatsCollector(audioStream);
|
||||||
|
|
||||||
|
for (i = 0; i < audioTracks.length; i++) {
|
||||||
|
videoStream.removeTrack(audioTracks[i]);
|
||||||
|
}
|
||||||
|
VideoLayout.changeLocalVideo(videoStream, true);
|
||||||
|
doJoin();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('connect').disabled = true;
|
document.getElementById('connect').disabled = true;
|
||||||
|
@ -146,8 +158,7 @@ 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);
|
||||||
|
@ -156,24 +167,7 @@ function obtainAudioAndVideoPermissions(callback) {
|
||||||
|
|
||||||
function audioStreamReady(stream) {
|
function audioStreamReady(stream) {
|
||||||
|
|
||||||
VideoLayout.changeLocalAudio(stream);
|
|
||||||
|
|
||||||
startLocalRtpStatsCollector(stream);
|
|
||||||
|
|
||||||
if (RTC.browser !== 'firefox') {
|
|
||||||
getUserMediaWithConstraints(['video'],
|
|
||||||
videoStreamReady,
|
|
||||||
videoStreamFailed,
|
|
||||||
config.resolution || '360');
|
|
||||||
} else {
|
|
||||||
doJoin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function videoStreamReady(stream) {
|
|
||||||
VideoLayout.changeLocalVideo(stream, true);
|
|
||||||
|
|
||||||
doJoin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function videoStreamFailed(error) {
|
function videoStreamFailed(error) {
|
||||||
|
|
Loading…
Reference in New Issue