Просмотр исходного кода

Set FPS constraints only when video has been requested

dev1
Domenic Murtari 9 лет назад
Родитель
Сommit
7d0325fe9d
1 измененных файлов: 12 добавлений и 16 удалений
  1. 12
    16
      modules/RTC/RTCUtils.js

+ 12
- 16
modules/RTC/RTCUtils.js Просмотреть файл

@@ -172,6 +172,18 @@ function getConstraints(um, options) {
172 172
             });
173 173
         }
174 174
 
175
+        if (options.minFps || options.maxFps || options.fps) {
176
+            // for some cameras it might be necessary to request 30fps
177
+            // so they choose 30fps mjpg over 10fps yuy2
178
+            if (options.minFps || options.fps) {
179
+                options.minFps = options.minFps || options.fps; //Fall back to options.fps for backwards compatibility
180
+                constraints.video.mandatory.minFrameRate = options.minFps;
181
+            }
182
+            if (options.maxFps) {
183
+                constraints.video.mandatory.maxFrameRate = options.maxFps;
184
+            }
185
+        }
186
+
175 187
         constraints.video.optional.push({ googLeakyBucket: true });
176 188
 
177 189
         setResolutionConstraints(constraints, options.resolution);
@@ -273,22 +285,6 @@ function getConstraints(um, options) {
273 285
         constraints.video.optional.push({bandwidth: options.bandwidth});
274 286
     }
275 287
 
276
-    if(options.minFps || options.maxFps || options.fps) {
277
-        // for some cameras it might be necessary to request 30fps
278
-        // so they choose 30fps mjpg over 10fps yuy2
279
-        if (!constraints.video) {
280
-            // same behaviour as true;
281
-            constraints.video = {mandatory: {}, optional: []};
282
-        }
283
-        if(options.minFps || options.fps) {
284
-            options.minFps = options.minFps || options.fps; //Fall back to options.fps for backwards compatibility
285
-            constraints.video.mandatory.minFrameRate = options.minFps;
286
-        }
287
-        if(options.maxFps) {
288
-            constraints.video.mandatory.maxFrameRate = options.maxFps;
289
-        }
290
-    }
291
-
292 288
     // we turn audio for both audio and video tracks, the fake audio & video seems to work
293 289
     // only when enabled in one getUserMedia call, we cannot get fake audio separate by fake video
294 290
     // this later can be a problem with some of the tests

Загрузка…
Отмена
Сохранить