Code Monkey home page Code Monkey logo

muaz-khan / getstats Goto Github PK

View Code? Open in Web Editor NEW
258.0 258.0 82.0 111 KB

getStats is a tiny JavaScript library using WebRTC getStats API to return peer connection stats i.e. bandwidth usage, packets lost, local/remote ip addresses and ports, type of connection etc.

Home Page: https://www.webrtc-experiment.com/getStats/

License: MIT License

JavaScript 71.79% HTML 28.21%
detect-bandwidth-speed getstats peer-connection-stats webrtc-getstats-api

getstats's Issues

Maximu call stack exceeded on chrome 63

On invoking the window.getStats function, the error maximum call stack exceeded is thrown.

Code:

function callback (r) {
    console.log(r.bandwidth.speed);
}
console.log(window.getStats);
window.getStats(mediaStream.getTracks()[0], callback, 2000);

same video/audio of peers in demo

It looks like the default demo will show us the same video/audio sources between peer1/peer2. Then how to separate local/remote sources differently in getStats demo?

AMD/UMD declaration

Can you please wrap the lib in AMD/UMD declaration so that it will work properly in environments like Webpack.

Currently we can't import the lib like so:

const getStats = require('getstats');

because there are no exports.

RoudTrip Time on firefox

For the love of god i am trying for days to get roundTripTime on firefox and yet only jitter in available.
Any reason for this? Your help will be much appreciated

audio codec

Hello

As I understand to get info about used codec we call RTCPeerConnection.getStats
Am I right? And find type == 'codec'
Please tell me what next?

Firefox: getStatsResult.audio[sendrecvType] is undefined

getStats v1.2.0
Firefox 89.0 (64-bit) this example: https://www.webrtc-experiment.com/getStats/

I'm getting this error:

getStatsResult.audio[sendrecvType] is undefined getStats/getStatsParser.checkAudioTracks@https://cdn.webrtc-experiment.com/getStats.js:368:13
getStatsLooper/</</<@https://cdn.webrtc-experiment.com/getStats.js:260:48
getStatsLooper/</<@https://cdn.webrtc-experiment.com/getStats.js:257:45
getStatsLooper/<@https://cdn.webrtc-experiment.com/getStats.js:255:21
getStatsWrapper/<@https://cdn.webrtc-experiment.com/getStats.js:312:19
promise callback*getStatsWrapper@https://cdn.webrtc-experiment.com/getStats.js:307:60
getStatsLooper@https://cdn.webrtc-experiment.com/getStats.js:252:24
getStats@https://cdn.webrtc-experiment.com/getStats.js:956:5
answererPeer/answerer.ontrack@https://www.webrtc-experiment.com/getStats/:442:33

Use getStats in Nightwatch

Is it possible to use getStats in a Nightwatch test to get the stats from a WebRTC Videoconference test from a certain website (like Nextcloud Talk, Jitsi meet and 3CX Webmeeting)? If so, how can I do this?

breaking change in 1.0.8 ?

My application is crashed because i used "getstate": "^1.0.6" in my package.json.
I think 1.0.6 to 1.0.8 should just be a PATCH version in Semantic Versioning. But it seems that its behavior has changed.

here is 1.0.6 code

    if (arguments[0] instanceof RTCPeerConnection) {
        peer = arguments[0];

        if (!!navigator.mozGetUserMedia) {
            mediaStreamTrack = arguments[1];
            callback = arguments[2];
            interval = arguments[3];
        }

        if (!(mediaStreamTrack instanceof MediaStreamTrack) && !!navigator.mozGetUserMedia) {
            throw '2nd argument is not instance of MediaStreamTrack.';
        }
    } else if (!(mediaStreamTrack instanceof MediaStreamTrack) && !!navigator.mozGetUserMedia) {
        throw '1st argument is not instance of MediaStreamTrack.';
    }

this arguments type check support getStats(RTCPeerConnection, MediaStreamTrack, ...) and getStats(MediaStreamTrack, ...)
but in 1.0.8 code

    if (!(arguments[0] instanceof RTCPeerConnection)) {
        throw '1st argument is not instance of RTCPeerConnection.';
    }

    peer = arguments[0];

    if (arguments[1] instanceof MediaStreamTrack) {
        mediaStreamTrack = arguments[1]; // redundant on non-safari
        callback = arguments[2];
        interval = arguments[3];
    }

this type check only support getStats(RTCPeerConnection, MediaStreamTrack, ...)
getStats(MediaStreamTrack, ...) will throw error 1st argument is not instance of RTCPeerConnection.

Time interval should be calculated when calculating bandwidth speed

https://github.com/muaz-khan/getStats/blob/master/dev/getStats.js#L39

        if (getStatsResult.audio && getStatsResult.video) {
            getStatsResult.bandwidth.speed = (getStatsResult.audio.bytesSent - getStatsResult.bandwidth.helper.audioBytesSent) + (getStatsResult.video.bytesSent - getStatsResult.bandwidth.helper.videoBytesSent);
            getStatsResult.bandwidth.helper.audioBytesSent = getStatsResult.audio.bytesSent;
            getStatsResult.bandwidth.helper.videoBytesSent = getStatsResult.video.bytesSent;
        }

video props not available

A number of props are documented as being available but are not showing up in the result object.

These and a number of others are not showing up.

result.video.packetsLost
result.video.packetsSent
result.video.googFrameRateInput
result.video.googFrameRateSent

Used v1.0.6 with Chrome 62.0.3202.94 and 64.0.3271.0 on MacOSX

Is the documentation accurate?

Error on line 170 of getStats.js

Seems to have error on line 170 of getStats.js
if (result.datachannelid && v.type === 'datachannel') {
There are no such variable "v"
Probably it should be "result.type".

Ability to stop calling getStats for peer that doesn't exist anymore (when it's `closed`)

I can't seem to find (or it doesn't exist) a way to stop calling getStats callback. My use case is that RTC peer connection can be closed at one point and new one can be crated. Even though old one is closed, getStats callback still gets called for it.

I gave a quick glance to getStats.js and couldn't find a way to do it. Comment on ine 191 mentions closed signaling state but I can't see it being used anywhere.

Any suggestions? Can this be done, or needs to be implemented?

support Android/IOS webrtc bridge.

@muaz-khan Can you talk about

 peer.getStats(function(res) {
                var items = [];
                res.result().forEach(function(res) {
                    var item = {};
                    try {
                        res.names().forEach(function(name) {
                            item[name] = res.stat(name);
                        });
                    } catch (error) {
                        console.error(error);
                    }
                    item.id = res.id;
                    item.type = res.type;
                    item.timestamp = res.timestamp;
                    items.push(item);
                });
                cb(items);
            })

I have mocked stat() function, but I didn't know what names() function mean

Too much recursion

I have an issue with getStats on firefox 39: getStats return promise with status rejected and reason TypeError

In Firefox: getStatsResult.video[sendrecvType] is undefined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.