浏览代码

Adds experimental active speaker detection.

master
paweldomas 11 年前
父节点
当前提交
e3f33c7a77
共有 3 个文件被更改,包括 39 次插入2 次删除
  1. 35
    1
      data_channels.js
  2. 1
    1
      libs/strophe/strophe.jingle.adapter.js
  3. 3
    0
      muc.js

+ 35
- 1
data_channels.js 查看文件

@@ -1,3 +1,4 @@
1
+/* global connection, Strophe, updateLargeVideo*/
1 2
 /**
2 3
  * Callback triggered by PeerConnection when new data channel is opened
3 4
  * on the bridge.
@@ -27,6 +28,34 @@ function onDataChannel(event)
27 28
     {
28 29
         var msgData = event.data;
29 30
         console.info("Got Data Channel Message:", msgData, dataChannel);
31
+
32
+        // Active speaker event
33
+        if (msgData.indexOf('activeSpeaker') === 0)
34
+        {
35
+            // Endpoint ID from the bridge
36
+            var endpointId = msgData.split(":")[1];
37
+            console.info("New active speaker: " + endpointId);
38
+
39
+            var container  = document.getElementById(
40
+                'participant_' + endpointId);
41
+            // Check if local video
42
+            if (!container)
43
+            {
44
+                if (endpointId ===
45
+                        Strophe.getResourceFromJid(connection.emuc.myroomjid))
46
+                {
47
+                    container = document.getElementById('localVideoContainer');
48
+                }
49
+            }
50
+            if (container)
51
+            {
52
+                var video = container.getElementsByTagName("video");
53
+                if (video.length)
54
+                {
55
+                    updateLargeVideo(video[0].src);
56
+                }
57
+            }
58
+        }
30 59
     };
31 60
 
32 61
     dataChannel.onclose = function ()
@@ -48,7 +77,7 @@ function bindDataChannelListener(peerConnection)
48 77
     // and peer as single channel can be used for sending and receiving data.
49 78
     // So either channel opened by the bridge or the one opened here is enough
50 79
     // for communication with the bridge.
51
-    var dataChannelOptions =
80
+    /*var dataChannelOptions =
52 81
     {
53 82
         reliable: true
54 83
     };
@@ -60,4 +89,9 @@ function bindDataChannelListener(peerConnection)
60 89
     {
61 90
         dataChannel.send("My channel !!!");
62 91
     };
92
+    dataChannel.onmessage = function (event)
93
+    {
94
+        var msgData = event.data;
95
+        console.info("Got My Data Channel Message:", msgData, dataChannel);
96
+    };*/
63 97
 }

+ 1
- 1
libs/strophe/strophe.jingle.adapter.js 查看文件

@@ -33,7 +33,7 @@ function TraceablePeerConnection(ice_config, constraints) {
33 33
 
34 34
     // override as desired
35 35
     this.trace = function (what, info) {
36
-        console.warn('WTRACE', what, info);
36
+        //console.warn('WTRACE', what, info);
37 37
         self.updateLog.push({
38 38
             time: new Date(),
39 39
             type: what,

+ 3
- 0
muc.js 查看文件

@@ -21,6 +21,9 @@ Strophe.addConnectionPlugin('emuc', {
21 21
     },
22 22
     doJoin: function (jid, password) {
23 23
         this.myroomjid = jid;
24
+
25
+        console.info("Joined MUC as " + this.myroomjid);
26
+
24 27
         this.initPresenceMap(this.myroomjid);
25 28
 
26 29
         if (!this.roomjid) {

正在加载...
取消
保存