} data The object containing the pid and lid
* of a peer connection.
*/
function removePeerConnection(data) {
var element = $(getPeerConnectionId(data));
if (element) {
delete peerConnectionDataStore[element.id];
peerConnectionsListElem.removeChild(element);
}
}
/**
* Adds a peer connection.
*
* @param {!Object} data The object containing the pid, lid, url, servers, and
* constraints of a peer connection.
*/
function addPeerConnection(data) {
var id = getPeerConnectionId(data);
if (!peerConnectionDataStore[id]) {
peerConnectionDataStore[id] = new PeerConnectionRecord();
}
peerConnectionDataStore[id].initialize(
data.url, data.servers, data.constraints);
var peerConnectionElement = $(id);
if (!peerConnectionElement) {
peerConnectionElement = document.createElement('li');
peerConnectionsListElem.appendChild(peerConnectionElement);
peerConnectionElement.id = id;
}
peerConnectionElement.innerHTML =
'PeerConnection ' + peerConnectionElement.id + '
' +
'' + data.url + ' ' + data.servers + ' ' + data.constraints +
'
';
// Clicking the heading can expand or collapse the peer connection item.
peerConnectionElement.firstChild.title = 'Click to collapse or expand';
peerConnectionElement.firstChild.addEventListener('click', function(e) {
if (e.target.parentElement.className == '')
e.target.parentElement.className = 'peer-connection-hidden';
else
e.target.parentElement.className = '';
});
return peerConnectionElement;
}
/**
* Adds a peer connection update.
*
* @param {!PeerConnectionUpdateEntry} data The peer connection update data.
*/
function updatePeerConnection(data) {
var peerConnectionElement = $(getPeerConnectionId(data));
addPeerConnectionUpdate(peerConnectionElement, data);
}
/**
* Adds the information of all peer connections created so far.
*
* @param {Array.} data An array of the information of all peer
* connections. Each array item contains pid, lid, url, servers,
* constraints, and an array of updates as the log.
*/
function updateAllPeerConnections(data) {
for (var i = 0; i < data.length; ++i) {
var peerConnection = addPeerConnection(data[i]);
var log = data[i].log;
for (var j = 0; j < log.length; ++j) {
addPeerConnectionUpdate(peerConnection, log[j]);
}
}
}
/**
* Handles the report of stats.
*
* @param {!Object} data The object containing pid, lid, and reports, where
* reports is an array of stats reports. Each report contains id, type,
* and stats, where stats is the object containing timestamp and values,
* which is an array of strings, whose even index entry is the name of the
* stat, and the odd index entry is the value.
*/
function addStats(data) {
var peerConnectionElement = $(getPeerConnectionId(data));
if (!peerConnectionElement)
return;
for (var i = 0; i < data.reports.length; ++i) {
var report = data.reports[i];
statsTable.addStatsReport(peerConnectionElement, report);
drawSingleReport(peerConnectionElement, report);
}
}
/**
* Delegates to dumpCreator to update the recording status.
* @param {!Object.} update Key-value pairs describing the status of the
* RTP recording.
*/
function updateDumpStatus(update) {
dumpCreator.onUpdate(update);
}