|
|
@@ -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;
|