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

feat(audio-only): be able to lock a browser into capturing audio only

tags/v0.0.2
virtuacoplenny 8 лет назад
Родитель
Сommit
9eaf57f157
3 измененных файлов: 27 добавлений и 3 удалений
  1. 12
    0
      JitsiMediaDevices.js
  2. 11
    0
      modules/RTC/RTCBrowserType.js
  3. 4
    3
      modules/RTC/RTCUtils.js

+ 12
- 0
JitsiMediaDevices.js Просмотреть файл

@@ -138,6 +138,18 @@ const JitsiMediaDevices = {
138 138
      */
139 139
     emitEvent(event, ...args) {
140 140
         eventEmitter.emit(event, ...args);
141
+    },
142
+
143
+    /**
144
+     * Returns whether or not the current browser can support capturing video,
145
+     * be it camera or desktop, and displaying received video.
146
+     *
147
+     * @returns {boolean}
148
+     */
149
+    supportsVideo() {
150
+        // Defer to RTCBrowserType to allow exposure of the api to the consumer
151
+        // but prevent other files from having to import JitsiMediaDevices.
152
+        return RTCBrowserType.supportsVideo();
141 153
     }
142 154
 };
143 155
 

+ 11
- 0
modules/RTC/RTCBrowserType.js Просмотреть файл

@@ -283,6 +283,17 @@ const RTCBrowserType = {
283 283
 
284 284
     supportsRtpSender() {
285 285
         return RTCBrowserType.isFirefox();
286
+    },
287
+
288
+    /**
289
+     * Returns whether or not the current browser can support capturing video,
290
+     * be it camera or desktop, and displaying received video.
291
+     *
292
+     * @returns {boolean}
293
+     */
294
+    supportsVideo() {
295
+        // Currently all browsers are assumed to support video.
296
+        return true;
286 297
     }
287 298
 
288 299
     // Add version getters for other browsers when needed

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

@@ -1231,7 +1231,7 @@ class RTCUtils extends Listenable {
1231 1231
     _newGetDesktopMedia(
1232 1232
             desktopSharingExtensionExternalInstallation,
1233 1233
             desktopSharingSources) {
1234
-        if (!screenObtainer.isSupported()) {
1234
+        if (!screenObtainer.isSupported() || !RTCBrowserType.supportsVideo()) {
1235 1235
             return Promise.reject(
1236 1236
                 new Error('Desktop sharing is not supported!'));
1237 1237
         }
@@ -1505,8 +1505,9 @@ class RTCUtils extends Listenable {
1505 1505
          */
1506 1506
         const maybeRequestCaptureDevices = function() {
1507 1507
             const umDevices = options.devices || [ 'audio', 'video' ];
1508
-            const requestedCaptureDevices = umDevices.filter(
1509
-                device => device !== 'desktop');
1508
+            const requestedCaptureDevices = umDevices.filter(device =>
1509
+                device === 'audio'
1510
+                || (device === 'video' && RTCBrowserType.supportsVideo()));
1510 1511
 
1511 1512
             if (!requestedCaptureDevices.length) {
1512 1513
                 return Promise.resolve();

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