Browse Source

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 years ago
parent
commit
4fb7001b00
1 changed files with 11 additions and 7 deletions
  1. 11
    7
      modules/RTC/RTCUtils.js

+ 11
- 7
modules/RTC/RTCUtils.js View File

1
 //This should be uncommented when app.js supports require
1
 //This should be uncommented when app.js supports require
2
 //var RTCBrowserType = require("../../service/RTC/RTCBrowserType.js");
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
     if (resolution && !constraints.video || isAndroid) {
6
     if (resolution && !constraints.video || isAndroid) {
9
         constraints.video = { mandatory: {}, optional: [] };// same behaviour as true
7
         constraints.video = { mandatory: {}, optional: [] };// same behaviour as true
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
     if (um.indexOf('video') >= 0) {
63
     if (um.indexOf('video') >= 0) {
64
         constraints.video = { mandatory: {}, optional: [] };// same behaviour as true
64
         constraints.video = { mandatory: {}, optional: [] };// same behaviour as true
65
     }
65
     }
115
         }
115
         }
116
     }
116
     }
117
 
117
 
118
-    setResolutionConstraints(resolution, isAndroid);
118
+    setResolutionConstraints(constraints, resolution, isAndroid);
119
 
119
 
120
     if (bandwidth) { // doesn't work currently, see webrtc issue 1846
120
     if (bandwidth) { // doesn't work currently, see webrtc issue 1846
121
         if (!constraints.video) constraints.video = {mandatory: {}, optional: []};//same behaviour as true
121
         if (!constraints.video) constraints.video = {mandatory: {}, optional: []};//same behaviour as true
126
         if (!constraints.video) constraints.video = {mandatory: {}, optional: []};// same behaviour as true;
126
         if (!constraints.video) constraints.video = {mandatory: {}, optional: []};// same behaviour as true;
127
         constraints.video.mandatory.minFrameRate = fps;
127
         constraints.video.mandatory.minFrameRate = fps;
128
     }
128
     }
129
+
130
+    return constraints;
129
 }
131
 }
130
 
132
 
131
 
133
 
220
     // Check if we are running on Android device
222
     // Check if we are running on Android device
221
     var isAndroid = navigator.userAgent.indexOf('Android') != -1;
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
     var isFF = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
228
     var isFF = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
226
 
229
 
251
                     success_callback(stream);
254
                     success_callback(stream);
252
                 },
255
                 },
253
                 function (error) {
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
                     if (failure_callback) {
259
                     if (failure_callback) {
256
                         failure_callback(error);
260
                         failure_callback(error);
257
                     }
261
                     }

Loading…
Cancel
Save