소스 검색

Converts 'constraints' to local variable in order to fix desktop sharing issues(audio constraints were retained in global var and get desktop stream failed).

j8
paweldomas 10 년 전
부모
커밋
4fb7001b00
1개의 변경된 파일11개의 추가작업 그리고 7개의 파일을 삭제
  1. 11
    7
      modules/RTC/RTCUtils.js

+ 11
- 7
modules/RTC/RTCUtils.js 파일 보기

@@ -1,9 +1,7 @@
1 1
 //This should be uncommented when app.js supports require
2 2
 //var RTCBrowserType = require("../../service/RTC/RTCBrowserType.js");
3 3
 
4
-var constraints = {audio: false, video: false};
5
-
6
-function setResolutionConstraints(resolution, isAndroid)
4
+function setResolutionConstraints(constraints, resolution, isAndroid)
7 5
 {
8 6
     if (resolution && !constraints.video || isAndroid) {
9 7
         constraints.video = { mandatory: {}, optional: [] };// same behaviour as true
@@ -58,8 +56,10 @@ function setResolutionConstraints(resolution, isAndroid)
58 56
 }
59 57
 
60 58
 
61
-function setConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid)
59
+function getConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid)
62 60
 {
61
+    var constraints = {audio: false, video: false};
62
+
63 63
     if (um.indexOf('video') >= 0) {
64 64
         constraints.video = { mandatory: {}, optional: [] };// same behaviour as true
65 65
     }
@@ -115,7 +115,7 @@ function setConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid
115 115
         }
116 116
     }
117 117
 
118
-    setResolutionConstraints(resolution, isAndroid);
118
+    setResolutionConstraints(constraints, resolution, isAndroid);
119 119
 
120 120
     if (bandwidth) { // doesn't work currently, see webrtc issue 1846
121 121
         if (!constraints.video) constraints.video = {mandatory: {}, optional: []};//same behaviour as true
@@ -126,6 +126,8 @@ function setConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid
126 126
         if (!constraints.video) constraints.video = {mandatory: {}, optional: []};// same behaviour as true;
127 127
         constraints.video.mandatory.minFrameRate = fps;
128 128
     }
129
+
130
+    return constraints;
129 131
 }
130 132
 
131 133
 
@@ -220,7 +222,8 @@ RTCUtils.prototype.getUserMediaWithConstraints = function(
220 222
     // Check if we are running on Android device
221 223
     var isAndroid = navigator.userAgent.indexOf('Android') != -1;
222 224
 
223
-    setConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid);
225
+    var constraints = getConstraints(
226
+        um, resolution, bandwidth, fps, desktopStream, isAndroid);
224 227
 
225 228
     var isFF = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
226 229
 
@@ -251,7 +254,8 @@ RTCUtils.prototype.getUserMediaWithConstraints = function(
251 254
                     success_callback(stream);
252 255
                 },
253 256
                 function (error) {
254
-                    console.warn('Failed to get access to local media. Error ', error);
257
+                    console.warn('Failed to get access to local media. Error ',
258
+                        error, constraints);
255 259
                     if (failure_callback) {
256 260
                         failure_callback(error);
257 261
                     }

Loading…
취소
저장