Adds experimental active speaker detection.
This commit is contained in:
parent
6d96981520
commit
e3f33c7a77
|
@ -1,3 +1,4 @@
|
||||||
|
/* global connection, Strophe, updateLargeVideo*/
|
||||||
/**
|
/**
|
||||||
* Callback triggered by PeerConnection when new data channel is opened
|
* Callback triggered by PeerConnection when new data channel is opened
|
||||||
* on the bridge.
|
* on the bridge.
|
||||||
|
@ -27,6 +28,34 @@ function onDataChannel(event)
|
||||||
{
|
{
|
||||||
var msgData = event.data;
|
var msgData = event.data;
|
||||||
console.info("Got Data Channel Message:", msgData, dataChannel);
|
console.info("Got Data Channel Message:", msgData, dataChannel);
|
||||||
|
|
||||||
|
// Active speaker event
|
||||||
|
if (msgData.indexOf('activeSpeaker') === 0)
|
||||||
|
{
|
||||||
|
// Endpoint ID from the bridge
|
||||||
|
var endpointId = msgData.split(":")[1];
|
||||||
|
console.info("New active speaker: " + endpointId);
|
||||||
|
|
||||||
|
var container = document.getElementById(
|
||||||
|
'participant_' + endpointId);
|
||||||
|
// Check if local video
|
||||||
|
if (!container)
|
||||||
|
{
|
||||||
|
if (endpointId ===
|
||||||
|
Strophe.getResourceFromJid(connection.emuc.myroomjid))
|
||||||
|
{
|
||||||
|
container = document.getElementById('localVideoContainer');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (container)
|
||||||
|
{
|
||||||
|
var video = container.getElementsByTagName("video");
|
||||||
|
if (video.length)
|
||||||
|
{
|
||||||
|
updateLargeVideo(video[0].src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
dataChannel.onclose = function ()
|
dataChannel.onclose = function ()
|
||||||
|
@ -48,7 +77,7 @@ function bindDataChannelListener(peerConnection)
|
||||||
// and peer as single channel can be used for sending and receiving data.
|
// and peer as single channel can be used for sending and receiving data.
|
||||||
// So either channel opened by the bridge or the one opened here is enough
|
// So either channel opened by the bridge or the one opened here is enough
|
||||||
// for communication with the bridge.
|
// for communication with the bridge.
|
||||||
var dataChannelOptions =
|
/*var dataChannelOptions =
|
||||||
{
|
{
|
||||||
reliable: true
|
reliable: true
|
||||||
};
|
};
|
||||||
|
@ -60,4 +89,9 @@ function bindDataChannelListener(peerConnection)
|
||||||
{
|
{
|
||||||
dataChannel.send("My channel !!!");
|
dataChannel.send("My channel !!!");
|
||||||
};
|
};
|
||||||
|
dataChannel.onmessage = function (event)
|
||||||
|
{
|
||||||
|
var msgData = event.data;
|
||||||
|
console.info("Got My Data Channel Message:", msgData, dataChannel);
|
||||||
|
};*/
|
||||||
}
|
}
|
|
@ -33,7 +33,7 @@ function TraceablePeerConnection(ice_config, constraints) {
|
||||||
|
|
||||||
// override as desired
|
// override as desired
|
||||||
this.trace = function (what, info) {
|
this.trace = function (what, info) {
|
||||||
console.warn('WTRACE', what, info);
|
//console.warn('WTRACE', what, info);
|
||||||
self.updateLog.push({
|
self.updateLog.push({
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
type: what,
|
type: what,
|
||||||
|
|
3
muc.js
3
muc.js
|
@ -21,6 +21,9 @@ Strophe.addConnectionPlugin('emuc', {
|
||||||
},
|
},
|
||||||
doJoin: function (jid, password) {
|
doJoin: function (jid, password) {
|
||||||
this.myroomjid = jid;
|
this.myroomjid = jid;
|
||||||
|
|
||||||
|
console.info("Joined MUC as " + this.myroomjid);
|
||||||
|
|
||||||
this.initPresenceMap(this.myroomjid);
|
this.initPresenceMap(this.myroomjid);
|
||||||
|
|
||||||
if (!this.roomjid) {
|
if (!this.roomjid) {
|
||||||
|
|
Loading…
Reference in New Issue