|
@@ -69,6 +69,24 @@ function init() {
|
69
|
69
|
return;
|
70
|
70
|
}
|
71
|
71
|
|
|
72
|
+ obtainAudioAndVideoPermissions(function (stream) {
|
|
73
|
+ var audioStream = new webkitMediaStream(stream);
|
|
74
|
+ var videoStream = new webkitMediaStream(stream);
|
|
75
|
+ var videoTracks = stream.getVideoTracks();
|
|
76
|
+ var audioTracks = stream.getAudioTracks();
|
|
77
|
+ for (var i = 0; i < videoTracks.length; i++) {
|
|
78
|
+ audioStream.removeTrack(videoTracks[i]);
|
|
79
|
+ }
|
|
80
|
+ VideoLayout.changeLocalAudio(audioStream);
|
|
81
|
+ startLocalRtpStatsCollector(audioStream);
|
|
82
|
+
|
|
83
|
+ for (i = 0; i < audioTracks.length; i++) {
|
|
84
|
+ videoStream.removeTrack(audioTracks[i]);
|
|
85
|
+ }
|
|
86
|
+ VideoLayout.changeLocalVideo(videoStream, true);
|
|
87
|
+ maybeDoJoin();
|
|
88
|
+ });
|
|
89
|
+
|
72
|
90
|
var jid = document.getElementById('jid').value || config.hosts.anonymousdomain || config.hosts.domain || window.location.hostname;
|
73
|
91
|
connect(jid);
|
74
|
92
|
}
|
|
@@ -100,17 +118,11 @@ function connect(jid, password) {
|
100
|
118
|
if (config.useStunTurn) {
|
101
|
119
|
connection.jingle.getStunAndTurnCredentials();
|
102
|
120
|
}
|
103
|
|
- obtainAudioAndVideoPermissions(function () {
|
104
|
|
- getUserMediaWithConstraints(['audio'], audioStreamReady,
|
105
|
|
- function (error) {
|
106
|
|
- console.error('failed to obtain audio stream - stop', error);
|
107
|
|
- });
|
108
|
|
- });
|
109
|
|
-
|
110
|
121
|
document.getElementById('connect').disabled = true;
|
111
|
122
|
|
112
|
123
|
if(password)
|
113
|
124
|
authenticatedUser = true;
|
|
125
|
+ maybeDoJoin();
|
114
|
126
|
} else if (status === Strophe.Status.CONNFAIL) {
|
115
|
127
|
if(msg === 'x-strophe-bad-non-anon-jid') {
|
116
|
128
|
anonymousConnectionFailed = true;
|
|
@@ -146,41 +158,21 @@ function obtainAudioAndVideoPermissions(callback) {
|
146
|
158
|
getUserMediaWithConstraints(
|
147
|
159
|
['audio', 'video'],
|
148
|
160
|
function (avStream) {
|
149
|
|
- avStream.stop();
|
150
|
|
- callback();
|
|
161
|
+ callback(avStream);
|
151
|
162
|
},
|
152
|
163
|
function (error) {
|
153
|
164
|
console.error('failed to obtain audio/video stream - stop', error);
|
154
|
|
- });
|
|
165
|
+ },
|
|
166
|
+ config.resolution || '360');
|
155
|
167
|
}
|
156
|
168
|
|
157
|
|
-function audioStreamReady(stream) {
|
158
|
|
-
|
159
|
|
- VideoLayout.changeLocalAudio(stream);
|
160
|
|
-
|
161
|
|
- startLocalRtpStatsCollector(stream);
|
162
|
|
-
|
163
|
|
- if (RTC.browser !== 'firefox') {
|
164
|
|
- getUserMediaWithConstraints(['video'],
|
165
|
|
- videoStreamReady,
|
166
|
|
- videoStreamFailed,
|
167
|
|
- config.resolution || '360');
|
168
|
|
- } else {
|
|
169
|
+function maybeDoJoin() {
|
|
170
|
+ if (connection && connection.connected && Strophe.getResourceFromJid(connection.jid) // .connected is true while connecting?
|
|
171
|
+ && (connection.jingle.localAudio || connection.jingle.localVideo)) {
|
169
|
172
|
doJoin();
|
170
|
173
|
}
|
171
|
174
|
}
|
172
|
175
|
|
173
|
|
-function videoStreamReady(stream) {
|
174
|
|
- VideoLayout.changeLocalVideo(stream, true);
|
175
|
|
-
|
176
|
|
- doJoin();
|
177
|
|
-}
|
178
|
|
-
|
179
|
|
-function videoStreamFailed(error) {
|
180
|
|
- console.warn("Failed to obtain video stream - continue anyway", error);
|
181
|
|
-
|
182
|
|
- doJoin();
|
183
|
|
-}
|
184
|
176
|
|
185
|
177
|
function doJoin() {
|
186
|
178
|
var roomnode = null;
|