Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
balazskreith committed Apr 4, 2024
1 parent 6e73dc3 commit d918812
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@observertc/observer-js",
"version": "0.40.16",
"version": "0.40.17",
"description": "Server Side NodeJS Library for processing ObserveRTC Samples",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
9 changes: 9 additions & 0 deletions src/monitors/TurnUsageMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export type TurnStats = {
totalPacketsReceived: number;
deltaBytesSent: number;
deltaBytesReceived: number;
timestamp: number;
outboundBitrate: number;
inboundBitrate: number;
}

type ObservedConnection = {
Expand Down Expand Up @@ -64,10 +67,16 @@ export class TurnUsageMonitor extends EventEmitter {
totalPacketsReceived: 0,
deltaBytesSent: 0,
deltaBytesReceived: 0,
timestamp: Date.now(),
outboundBitrate: 0,
inboundBitrate: 0,
};

stats.deltaBytesSent = usage.totalBytesSent - stats.totalBytesSent;
stats.deltaBytesReceived = usage.totalBytesReceived - stats.totalBytesReceived;
stats.timestamp = Date.now();
stats.outboundBitrate = (stats.deltaBytesSent * 8) / ((stats.timestamp - stats.timestamp) / 1000.0);
stats.inboundBitrate = (stats.deltaBytesReceived * 8) / ((stats.timestamp - stats.timestamp) / 1000.0);
stats.totalBytesSent = usage.totalBytesSent;
stats.totalBytesReceived = usage.totalBytesReceived;
stats.totalPacketsSent = usage.totalPacketsSent;
Expand Down

0 comments on commit d918812

Please sign in to comment.