Browse Source

Adds RTCUIHelper class which gathers methods specific to WebRTC and UI.

master
paweldomas 9 years ago
parent
commit
495606e352
3 changed files with 55 additions and 6 deletions
  1. 3
    1
      JitsiMeetJS.js
  2. 2
    5
      modules/RTC/RTC.js
  3. 50
    0
      modules/RTC/RTCUIHelper.js

+ 3
- 1
JitsiMeetJS.js View File

@@ -7,6 +7,7 @@ var JitsiTrackEvents = require("./JitsiTrackEvents");
7 7
 var JitsiTrackErrors = require("./JitsiTrackErrors");
8 8
 var Logger = require("jitsi-meet-logger");
9 9
 var RTC = require("./modules/RTC/RTC");
10
+var RTCUIHelper = require("./modules/RTC/RTCUIHelper");
10 11
 var Statistics = require("./modules/statistics/statistics");
11 12
 var Resolutions = require("./service/RTC/Resolutions");
12 13
 var ScriptUtil = require("./modules/util/ScriptUtil");
@@ -139,7 +140,8 @@ var LibJitsiMeet = {
139 140
      */
140 141
     util: {
141 142
         ScriptUtil: ScriptUtil,
142
-    },
143
+        RTCUIHelper: RTCUIHelper
144
+    }
143 145
 };
144 146
 
145 147
 //Setups the promise object.

+ 2
- 5
modules/RTC/RTC.js View File

@@ -241,10 +241,6 @@ RTC.stopMediaStream = function (mediaStream) {
241 241
  */
242 242
 RTC.isDesktopSharingEnabled = function () {
243 243
     return RTCUtils.isDesktopSharingEnabled();
244
-}
245
-
246
-RTC.prototype.getVideoElementName = function () {
247
-    return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
248 244
 };
249 245
 
250 246
 RTC.prototype.dispose = function() {
@@ -267,5 +263,6 @@ RTC.prototype.setAudioLevel = function (jid, audioLevel) {
267 263
     var resource = Strophe.getResourceFromJid(jid);
268 264
     if(this.remoteStreams[resource] && this.remoteStreams[resource][JitsiTrack.AUDIO])
269 265
         this.remoteStreams[resource][JitsiTrack.AUDIO].setAudioLevel(audioLevel);
270
-}
266
+};
267
+
271 268
 module.exports = RTC;

+ 50
- 0
modules/RTC/RTCUIHelper.js View File

@@ -0,0 +1,50 @@
1
+/* global $ */
2
+var RTCBrowserType = require("./RTCBrowserType");
3
+
4
+var RTCUIHelper = {
5
+
6
+    /**
7
+     * Returns the name of 'video' element depending on the browser that we're
8
+     * currently using.
9
+     * @returns {string} 'video' or 'object' string name of WebRTC video element
10
+     */
11
+    getVideoElementName: function () {
12
+        return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
13
+    },
14
+
15
+    /**
16
+     * Finds video element inside of the given container.
17
+     * @param containerElement HTML element node instance which is supposed to
18
+     *        contain the video element.
19
+     * @returns {HTMLElement} video HTML element instance if found inside of the
20
+     *          container or undefined otherwise.
21
+     */
22
+    findVideoElement: function (containerElement) {
23
+        var videoElemName = RTCUIHelper.getVideoElementName();
24
+        if (!RTCBrowserType.isTemasysPluginUsed()) {
25
+            return $(containerElement).find(videoElemName)[0];
26
+        } else {
27
+            var matching = $(containerElement).find(
28
+                ' ' + videoElemName + '>param[value="video"]');
29
+            if (matching.length < 2) {
30
+                return matching.parent()[0];
31
+            } else {
32
+                // there are 2 video objects from FF
33
+                // object with id which ends with '_default'
34
+                // (like 'remoteVideo_default')
35
+                // doesn't contain video, so we ignore it
36
+                for (var i = 0; i < matching.length; i += 1) {
37
+                    var el = matching[i].parentNode;
38
+
39
+                    // check id suffix
40
+                    if (el.id.substr(-8) !== '_default') {
41
+                        return el;
42
+                    }
43
+                }
44
+            }
45
+        }
46
+        return undefined;
47
+    }
48
+};
49
+
50
+module.exports = RTCUIHelper;

Loading…
Cancel
Save