monitor-webrtc-connection
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Monitor WebRTC Statistics

Overview

This package would help to monitor the WebRTC real-time peer to peer connection based on the data provided by the WebRTC connection.

This package would also help us detect the situtations such as Internet Connectivity issue, Audio & Video related issues etc.

We have check functions to check and classify the parameters in categories whether they are in GOOD, AVERAGE OR POOR category and also trigger events which would help us detect which event is happening such as SLOW CONNECTION, NO CONNECTION, LOW AUDIO etc. and also provide us with the functionality of callback function.

Installation

npm i monitor-webrtc-connection

Usage

To get started with the package we need the peerConnection instance so that we can fetch the meaningful data. We also need MonitorWebRTC instance to start the analysis. Refer to the code snippet given below.

let Monitor = require("monitor-webrtc-connection");
let localConnection... // RTCPeerConnection Instance

// Configurable Parameters (Optional)
let CONFIGURABLE_PARAMETERS = {
	SAMPLING_TIME_PERIOD: 1000, // Time in Milliseconds after which data is collected
	REPORT_MAX_LENGTH: 500, // Maximum number of stats report stored at a time
	EVENT_EMIT_TIME_PERIOD: 3000, // time interval between 2 events emit of the same kind
	STRIKES_THRESHOLD: 3, // number of strikes used for categorization
	LOGGER_FUNCTION: console.log,	// can be used to send the stats report to the backend
};

// create new MonitorWebRTC instance
let monitor = new Monitor.MonitorWebRTC(localConnection, CONFIGURABLE_PARAMETERS);

Listener Functions

You can use the following listener functions.

let monitor = new Monitor.MonitorWebRTC(localConnection, CONFIGURABLE_PARAMETERS);

monitor.eventEmitter.on("LOW_AUDIO", callback);
monitor.eventEmitter.on("LOW_PACKETS_SENT", callback);
monitor.eventEmitter.on("LOW_PACKETS_SENT_VIDEO", callback);
monitor.eventEmitter.on("HIGH_RETRANSMITTED_PACKETS_SENT", callback);
monitor.eventEmitter.on("HIGH_INBOUND_PACKET_LOSS", callback);
monitor.eventEmitter.on("HIGH_REMOTE_INBOUND_PACKET_LOSS", callback);
monitor.eventEmitter.on("HIGH_JITTER", callback);
monitor.eventEmitter.on("HIGH_ROUND_TRIP_TIME", callback);
monitor.eventEmitter.on("LOW_MOS_VALUE", callback);
monitor.eventEmitter.on("CONNECTION_PROBLEM", callback);
monitor.eventEmitter.on("CONNECTED", callback);
monitor.eventEmitter.on("NO_CONNECTION", callback);
monitor.eventEmitter.on("SLOW_CONNECTION", callback);
monitor.eventEmitter.on("INPUT_VIDEO_STREAM_OFF", callback);
monitor.eventEmitter.on("INPUT_VIDEO_STREAM_ON", callback);
monitor.eventEmitter.on("OUTPUT_VIDEO_STREAM_OFF", callback);
monitor.eventEmitter.on("LOW_PACKETS_RECEIVED_VIDEO", callback);

Getter Methods

You can use the following getter methods to get the real time values of WebRTC parameters.

.getStatsLog() : Complete Connection log of WebRTC Connection.

.getRealtimeStats() : Real-time Connection log of WebRTC Connection.

.getPacketsSentICECandidate() : Number of Packets Sent by ICE Candidate

.getPacketsReceivedICECandidate() : Number of Packets Received by ICE Candidate

.getCurrentRoundTripTimeICECandidate() : Current Round Trip Time for the WebRTC Connection

.getAvailableOutgoingBitrateICECandidate() : Available Outgoing Bitrate for the WebRTC Connection

Audio Parameters

.getAudioLevel() : Current Input Audio Level of Local Peer.

.getRTTRemoteOutbound() : Round Trip Time given by Remote Outbound audio stream

.getRTTRemoteInbound() : Round Trip Time given by Remote Inbound audio stream

.getJitter() : Jitter given by Remote Inbound audio stream

.getPacketsLostInbound() : Number of Packets Lost given by Inbound Audio stream

.getPacketsReceivedInbound() : Number of Packets Received given by Inbound Audio stream

.getInsertedSamplesForDeceleration() : Number of Samples Inserted for Deceleration given by Inbound Audio stream

.getRemovedSamplesForAcceleration() : Number of Samples Removed for Acceleration given by Inbound Audio stream

.getPacketsLostRemoteInbound() : Number of Packets Lost given by Remote Inbound Audio stream

.getPacketsSentOutbound() : Number of Packets Sent by Outbound Audio stream

.getRetransmittedPacketsSentOutbound() : Number of Retransmitted Packets Sent given by Outbound Audio stream

.getMeanOpinionScore() : Mean Opinion Score Audio (MOS) for the WebRTC Connection

Video Parameters

.getPacketsSentOutboundVideo() : Number of Packets Sent by Outbound Video stream

.getRetransmittedPacketsSentOutboundVideo() : Number of Retransmitted Packets Sent given by Outbound Video stream

.getJitterVideo() : Jitter given by Remote Inbound video stream

.getRTTRemoteInboundVideo() : Round Trip Time given by Remote Inbound video stream

.getPacketsLostRemoteInboundVideo() : Number of Packets Lost given by Remote Inbound video stream

.getPacketsLostInboundVideo() : Number of Packets Lost given by Inbound video stream

.getPacketsReceivedInboundVideo() : Number of Packets Received given by Inbound video stream

.getFramesSentOutboundVideo() : Number of Frames Sent by Outbound Video stream

.getFramesReceivedInboundVideo() : Number of Frames Received by Inbound Video stream

.getFrameWidthInboundVideo() : Frame Width of Inbound Video stream

.getFrameHeightInboundVideo() : Frame Height of Inbound Video stream

.getFrameWidthOutboundVideo() : Frame Width of Outbound Video stream

.getFrameHeightOutboundVideo() : Frame Height of Outbound Video stream

.getMeanOpinionScoreVideo() : Mean Opinion Score Video(MOS) for the WebRTC Connection

Checker Methods

You can also use following following Checker functions.

.checkIsConnection() : Checks whether the WebRTC connection exists at the current instance

.checkMicOn() : Determine whether local Peer's Mic is ON or OFF

Audio Parameters

.checkPacketsSentPerSecond() : Check and categorise the quality of WebRTC Connection based on Packets Sent Per second of Outbound Stream

.checkRetransmittedPacketsSentPerSecond() : Check and categorise the quality of WebRTC Connection based on Retransmitted Packets Sent Per second of Outbound Stream

.checkAudioQuality(): Check and categorise Audio Quality of Local Peer based on Audio Level of Media-source

.checkPacketsLostPercentageInbound() : Check and categorise the quality of WebRTC Connection based on Packets Lost Percentage of Inbound Stream

.checkPacketsLostPercentageRemoteInbound() : Check and categorise the quality of WebRTC Connection based on Packets Lost Percentage of Remote Inbound Stream

.checkConnectionQuality() : Check and categorise the quality of WebRTC Connection based on Jitter and Round Trip Time of Remote Inbound Stream

.checkMOSValue() : Check and categorise the quality of WebRTC Connection based on Mean Opinion Score (MOS)

Video Parameters

.checkPacketsSentPerSecondVideo() : Check and categorise the quality of WebRTC Connection based on Packets Sent Per second of Outbound Stream

.checkPacketsReceivedPerSecondVideo() : Check and categorise the quality of WebRTC Connection based on Packets Received Per second of Inound Stream

.checkRetransmittedPacketsSentPerSecondVideo() : Check and categorise the quality of WebRTC Connection based on Retransmitted Packets Sent Per second of Outbound Stream

.checkPacketsLostPercentageInboundVideo() : Check and categorise the quality of WebRTC Connection based on Packets Lost Percentage of Inbound Stream

.checkPacketsLostPercentageRemoteInboundVideo() : Check and categorise the quality of WebRTC Connection based on Packets Lost Percentage of Remote Inbound Stream

.checkConnectionQualityVideo() : Check and categorise the quality of WebRTC Connection based on Jitter and Round Trip Time of Remote Inbound Stream

.checkMOSValueVideo() : Check and categorise the quality of WebRTC Connection based on Mean Opinion Score (MOS)

Library details

Description of Checker Methods of MonitorWebRTC:

Using Audio & Video Parameters

  1. Check connection quality using Packets Sent per second in Outbound Stream
  2. Check connection quality Retransmitted Packets Sent Per Second in Outbound Stream
  3. Check connection quality Packets Lost Percentage in Inbound Stream
  4. Check connection quality Packets Lost Percentage in Remote Inbound Stream
  5. Check connection quality using MOS value
  6. Check connection quality using Jitter and Round Trip Time
  7. Check whether there is connection or not
  8. Check audio Quality (only for audio)
  9. Check connection quality using Packets Received per second in Inbound Stream (only for video)

We can also get the meaningful data such as :

  1. Available Outgoing Bitrate for the Connection
  2. Current Round Trip Time of the Connection (only for audio)
  3. Number of Packets Sent by the Connection
  4. Number of Packets Received by the Connection
  5. Realtime Connection Log
  6. Connection Log for Last Few Insatnces based on user input

Using Audio & Video Parameters

  1. Jitter of the Remote Inbound Stream
  2. Round Trip Time of the Remote Inbound Stream
  3. Number of Packets Lost in the Inbound Stream
  4. Number of Packets received by Inbound Stream
  5. Number of Packets Lost Remote Inbound
  6. Number of Packets Sent in the Outbound Stream
  7. Number of Retransmitted Packets Sent in the Outbound Stream
  8. Mean Opinion Score (MOS)
  9. AudioLevel of the Source (only for audio)
  10. Round Trip Time of Remote Outbound (only for audio)
  11. Number of Samples Inserted for the Deceleration in the Inbound Stream (only for audio)
  12. Number of Samples Removed for the Acceleration in the Inbound Stream (only for audio)
  13. Frame Resolution (Height & Width) of Inbound Stream (only for video)
  14. Frame Resolution (Height & Width) of Outbound Stream (only for video)

Dependents (0)

Package Sidebar

Install

npm i monitor-webrtc-connection

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

125 kB

Total Files

20

Last publish

Collaborators

  • shivam_491