Ver código fonte

use only a single GUM call

master
Philipp Hancke 11 anos atrás
pai
commit
54ea1da98e
1 arquivos alterados com 18 adições e 24 exclusões
  1. 18
    24
      app.js

+ 18
- 24
app.js Ver arquivo

100
             if (config.useStunTurn) {
100
             if (config.useStunTurn) {
101
                 connection.jingle.getStunAndTurnCredentials();
101
                 connection.jingle.getStunAndTurnCredentials();
102
             }
102
             }
103
-            obtainAudioAndVideoPermissions(function () {
104
-                getUserMediaWithConstraints(['audio'], audioStreamReady,
105
-                    function (error) {
106
-                        console.error('failed to obtain audio stream - stop', error);
107
-                    });
103
+            obtainAudioAndVideoPermissions(function (stream) {
104
+                audioStream = new webkitMediaStream(stream);
105
+                videoStream = new webkitMediaStream(stream);
106
+                var videoTracks = stream.getVideoTracks();
107
+                var audioTracks = stream.getAudioTracks();
108
+                for (var i = 0; i < videoTracks.length; i++) {
109
+                    audioStream.removeTrack(videoTracks[i]);
110
+                }
111
+                audioStreamReady(audioStream);
112
+                VideoLayout.changeLocalAudio(audioStream);
113
+                startLocalRtpStatsCollector(audioStream);
114
+
115
+                for (i = 0; i < audioTracks.length; i++) {
116
+                    videoStream.removeTrack(audioTracks[i]);
117
+                }
118
+                VideoLayout.changeLocalVideo(videoStream, true);
119
+                doJoin();
108
             });
120
             });
109
 
121
 
110
             document.getElementById('connect').disabled = true;
122
             document.getElementById('connect').disabled = true;
146
     getUserMediaWithConstraints(
158
     getUserMediaWithConstraints(
147
         ['audio', 'video'],
159
         ['audio', 'video'],
148
         function (avStream) {
160
         function (avStream) {
149
-            avStream.stop();
150
-            callback();
161
+            callback(avStream);
151
         },
162
         },
152
         function (error) {
163
         function (error) {
153
             console.error('failed to obtain audio/video stream - stop', error);
164
             console.error('failed to obtain audio/video stream - stop', error);
156
 
167
 
157
 function audioStreamReady(stream) {
168
 function audioStreamReady(stream) {
158
 
169
 
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
-        doJoin();
170
-    }
171
-}
172
 
170
 
173
-function videoStreamReady(stream) {
174
-    VideoLayout.changeLocalVideo(stream, true);
175
-
176
-    doJoin();
177
 }
171
 }
178
 
172
 
179
 function videoStreamFailed(error) {
173
 function videoStreamFailed(error) {

Carregando…
Cancelar
Salvar