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