Skip to content

Commit

Permalink
Now ackuaria subscribes to erizo stats
Browse files Browse the repository at this point in the history
  • Loading branch information
aalonsog committed Jun 26, 2017
1 parent c51d6e3 commit fec8cd8
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 75 deletions.
4 changes: 2 additions & 2 deletions ackuaria.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ N.API.getRooms(function(roomList) {
amqper.connect(function() {
"use strict";
amqper.bind_broadcast('event', api.event);
amqper.bind_broadcast('stats', api.stats);
amqper.bind_broadcast('stats_subscriptions', api.stats);

var getErizoAgents = function() {
API.agents = {};
amqper.broadcast('ErizoAgent', {method: 'getErizoAgents', args: []}, function (agent) {
console.log(agent);
// console.log(agent);
if (agent === 'timeout') {
console.log('No agents available');
return;
Expand Down
51 changes: 5 additions & 46 deletions common/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,52 +411,11 @@ API.send_event_to_clients = function(event, rooms, streams, users, states) {
}

API.send_stats_to_clients = function(event) {
if (!event.subs) {
var pubID = String(event.pub);
var stats = event.stats;
var video, audio;
if (stats) {
for (var ssrc in stats) {
if (stats[ssrc].type === 'video') {
video = stats[ssrc];
video.ssrc = ssrc;
} else if (stats[ssrc].type === 'audio') {
audio = stats[ssrc];
audio.ssrc = ssrc;
}
}
}

for (var s in API.sockets) {
API.sockets[s].emit('newSR', {
event: event,
audio: audio,
video: video
});
}
} else {
var pubID = String(event.pub);
var subID = event.subs;
var stats = event.stats;
var video, audio;
if (stats) {
for (var ssrc in stats) {
if (stats[ssrc].type === 'video') {
video = stats[ssrc];
video.ssrc = ssrc;
} else if (stats[ssrc].type === 'audio') {
audio = stats[ssrc];
audio.ssrc = ssrc;
}
}
}
for (var s in API.sockets) {
API.sockets[s].emit('newRR', {
event: event,
audio: audio,
video: video
});
}
event.timestamp = (new Date()).getTime();
for (var s in API.sockets) {
API.sockets[s].emit('newStats', {
event: event
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/mdb/dataBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
var dataBaseURL = require("./../../ackuaria_config").ackuaria.dataBaseURL;

var collections = ["events", "stats", "rooms", "sessions"];
exports.db = require("mongojs").connect(dataBaseURL, collections);
exports.db = require("mongojs")(dataBaseURL, collections);

4 changes: 4 additions & 0 deletions controllers/ackuaria_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ exports.loadSubscribers = function(req, res) {
}
}

amqper.broadcast('ErizoJS', {method: 'subscribeToStats', args: [streamID, 60, 1]}, function(resp){
console.log('Stats subscription result to ', streamID, ':', resp);
});

res.render('subscribers', {
view: "subscribers",
roomID: roomID,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"express-partials": "^0.3.0",
"jade": "~1.6.0",
"log4js": "0.6.21",
"mongojs": "0.14.2",
"mongojs": "2.4.0",
"morgan": "~1.3.0",
"node-getopt": "0.2.3",
"serve-favicon": "~2.1.3",
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/graphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var newDataSub = function(subID, data) {
updateFLAudioChart(newDataFLAudio);
}
if (data.BW) {
var BW = data.BW / 1000;
var BW = data.BW;
var newDataBW = {date: date, val: BW};
updateBWChart(newDataBW);
}
Expand Down
50 changes: 26 additions & 24 deletions public/javascripts/subscribers.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,33 @@ $(document).ready(function(){
if (sub_modal_now == event.subID) updateModalState(event.subID);
});

socket.on('newSR', function(evt) {
socket.on('newStats', function(evt) {
var event = evt.event;
var pubID = event.pub;
audio = evt.audio;
video = evt.video;
var timestamp = event.timestamp;
var pubID = event.streamId;
delete event.streamId;
if (pubID == streamID){
updateSR(audio, video, timestamp);
}
});

socket.on('newRR', function(evt) {
var event = evt.event;

var audio = evt.audio;
var video = evt.video;
var pubID = event.pub;
var subID = event.subs;
var timestamp = event.timestamp;
var stats = {audio: audio, video: video};
if (pubID == streamID) {
subscribers[subID] = stats;
if (sub_modal_now == subID) {
updateRR(subID, audio, video, timestamp);
var video, audio, stats;
for (var id in event) {
for (var ssrc in event[id]) {
if (event[id][ssrc].type === 'video') {
video = event[id][ssrc];
video.ssrc = ssrc;
} else if (event[id][ssrc].type === 'audio') {
audio = event[id][ssrc];
audio.ssrc = ssrc;
}
}
if (id === 'publisher') {
updateSR(audio, video, event.timestamp);
} else {
stats = {audio: audio, video: video};
subscribers[id] = stats;
if (sub_modal_now == id) {
updateRR(id, audio, video, event.timestamp);
}
}
}

}
});

Expand Down Expand Up @@ -329,7 +331,7 @@ $(document).ready(function(){
var FLVideo, FLAudio, BW;
if (video) {
FLVideo = video.fractionLost;
BW = video.bandwidth;
BW = video.bitrateCalculated/1000;
}
if (audio) FLAudio = audio.fractionLost;

Expand All @@ -345,7 +347,7 @@ $(document).ready(function(){

if (video && ssrcs[video.sourceSsrc]) {
$('#dataModal #videoSSRC').html(video.ssrc);
$('#dataModal #videoBandwidth').html(video.bandwidth);
$('#dataModal #videoBandwidth').html(video.bitrateCalculated/1000);
$('#dataModal #pli').html(video.PLI);
$('#dataModal #videoFractionLost').html(Math.round((video.fractionLost * 100 / 256) *100) / 100 + "%");
$('#dataModal #videoJitter').html(video.jitter);
Expand Down

0 comments on commit fec8cd8

Please sign in to comment.