Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webrtc-test-suite

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webrtc-test-suite - npm Package Compare versions

Comparing version 1.2.8 to 1.2.9

checks/feature_support.js

2

index.js

@@ -5,2 +5,3 @@ import checkPeerConnection from "./checks/peerConnection";

import countDevies from "./checks/count_devices";
import checkFeatureSupport from "./checks/feature_support";
// Utils

@@ -18,2 +19,3 @@ import flat from "./utils/simplify_promise";

getUserMedia,
checkFeatureSupport,
checkPeerConnectionSilent(){return flat(checkPeerConnection(...arguments))},

@@ -20,0 +22,0 @@ checkMediaCaptureSilent(){return flat(checkMediaCapture(...arguments))},

2

package.json
{
"name": "webrtc-test-suite",
"version": "1.2.8",
"version": "1.2.9",
"main": "index.js",

@@ -5,0 +5,0 @@ "repository": "git@github.com:theanam/webrtc-test-suite.git",

@@ -6,12 +6,4 @@ # Real life Capability testing and utilities for WebRTC.

## What It's not:
This is not a replacement of [Modernizr](https://modernizr.com/) or similar tools. This will not check if a feature is supported by the browser. For example a browser might have support for `getUserMedia`. Which Modernizr or similar tool will find out. But having support for `getUserMedia` does not mean that the user is guaranteed to access the feature. Maybe the user does not have a webcam, or the user's audio input device might be broken.
Or in a different scenario, maybe the users's firewall will block any Peer connection and you need to know if the user's internet connection supports peer connection.
this package will help you test for these real life scenarios in your webRTC application.
> Please include the [webRTC Adapter](https://www.npmjs.com/package/webrtc-adapter) package in your project. This plugin tries to cover most of the variations of the API but adapter covers almost all of it.
## What Can It do
* Test basic feature support.
* Test If `getUserMedia` Actually works.

@@ -38,3 +30,3 @@ * Test if the browser and internet is capable of `RTCPeerConnection`

```html
<script src="https://unpkg.com/webrtc-test-suite@1.2.8/dist/index.js"></script>
<script src="https://unpkg.com/webrtc-test-suite@1.2.9/dist/index.js"></script>
```

@@ -46,6 +38,51 @@ Yoou will get a global object called: `_rtc`. And you can access all the functionalities from that object.

> Please include the [webRTC Adapter](https://www.npmjs.com/package/webrtc-adapter) package in your project. This plugin tries to cover most of the variations of the API but adapter covers almost all of it.
> Functions that return a promise has a `silent` version that does not reject the promise on error. Instead returns null. Good for working with `async-await`.
> Functions that accepts the `verbose` (Boolean) argument, will generate logs in the console if `verbose` is set to `true`. Default is `false`.
### 0. `checkFeatureSupport`:
> Please note: *Feaeture detection is not the primary objective of this tool, Detecting if the feature actually works is the primary objective. Feature detection is provided just as an additional tool*
> `checkFeatureSupport([verbose = false]) // Returns result object`.
This is the newest addition to this tool in version 1.2.9. This checks for the feature support in the browser. (e.g: if the browser supports HTML5 video and Audio elements or `RTCPeerConnection`). Much like [Modernizr](https://modernizr.com/). This wasn't primarily intended to be in this package since there's already tool like [Modernizr](https://modernizr.com/) that does this job really well. But since this detection is intended to be used internally, and it's always good to have one less dependency. It returns an output like this:
```js
{
video : {
basic : true
},
audio : {
basic : true,
webAudio : true
},
rtcPeerConnection : true,
rtcDataChannel : false,
getUserMedia : "prefix-webkit",
getDisplayMedia : false
}
```
Checks available:
| Check | Meaning |
|-------|---------|
|video.basic|Basic HTML5 Video Support|
|audio.basic|Basic HTML5 Audio Support|
|audio.webAudio|Support for Web Audio API|
|rtcPeerConnection|Support for RTCPeerConnection API|
|rtcDataChannel|Support for RTC Data Channel API|
|getUserMedia|Support for the Audio Video Capture|
|getDisplayMedia|Support for Screen Capture|
All the options can have these values:
|Value | Meaning |
|------|----------------|
|false | Unsupported |
|"old" | Supported, but with older version of the API |
|"prefix-webkit"| Supported with `webkit` prefix|
|"prefix-moz"| Supported with `moz` prefix |
### 1. `checkMediaCapture` and `checkMediaCaptureSilent`:

@@ -52,0 +89,0 @@ > `checkMediaCapture(constraints, [verbose = false]); // Returns Promise`

@@ -17,14 +17,15 @@ import _rtc from "../index";

function init(){
let verbose = false;
let pc = $(".peerconnection");
loading(pc,"Testing Peer Connection");
_rtc.checkPeerConnection({},true).then(()=>yes(pc,"Peer connection Established")).catch(()=>no(pc,"Peer connection did not work"));
_rtc.checkPeerConnection({},verbose).then(()=>yes(pc,"Peer connection Established")).catch(()=>no(pc,"Peer connection did not work"));
let _net = $(".internet");
loading(_net,"Testing Internet Connection");
_rtc.checkInternetSpeed("test.png",true).then(speed=>yes(_net,`Your speed is ${speed}mbps with this server`)).catch(()=>no(_net,"Could not test internet speed"));
_rtc.checkInternetSpeed("test.png",verbose).then(speed=>yes(_net,`Your speed is ${speed}mbps with this server`)).catch(()=>no(_net,"Could not test internet speed"));
let _cd = $(".count");
loading(_cd,"Counting devices");
_rtc.countDevies(true).then(l=>yes(_cd,`You have ${l.audio.in} audio input, ${l.video.in} video input`)).catch(e=>no(_cd,"Could not count hardware"));
_rtc.countDevies(verbose).then(l=>yes(_cd,`You have ${l.audio.in} audio input, ${l.video.in} video input`)).catch(e=>no(_cd,"Could not count hardware"));
let um = $(".usermedia");
loading(um,"Testing getUserMedia");
_rtc.checkMediaCapture({audio:true, video: true},true).then(()=>yes(um,"Media Capture Successful")).catch(err=>no(um,"Media Capture failed"));
_rtc.checkMediaCapture({audio:true, video: true}, verbose).then(()=>yes(um,"Media Capture Successful")).catch(err=>no(um,"Media Capture failed"));
}

@@ -34,2 +35,4 @@

$(function(){
console.log(_rtc.checkFeatureSupport());
})

@@ -21,2 +21,7 @@ export default function getUserMedia(constraints, verbose = false){

}
else if(navigator.mozGetUserMedia){
verbose && console.log(`[get-user-media]: Using navigator.mozGetUserMedia`);
navigator.mozGetUserMedia(constraints, _success, _err);
gum = "mozGetUserMedia";
}
if(!gum) return reject(new Error("No version of getusermedia was found"));

@@ -23,0 +28,0 @@ if(gum.then) gum.then(resolve);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc