{"id":27213283,"url":"https://github.com/theanam/webrtc-test-suite","last_synced_at":"2025-10-03T12:48:37.650Z","repository":{"id":42809598,"uuid":"269730861","full_name":"theanam/webrtc-test-suite","owner":"theanam","description":"Capability testing and Tools for WebRTC 📹 🎤 🔬","archived":false,"fork":false,"pushed_at":"2023-01-06T08:01:38.000Z","size":2261,"stargazers_count":12,"open_issues_count":11,"forks_count":6,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-30T15:36:21.228Z","etag":null,"topics":["audiocall","checkinternet","getusermedia","getusermedia-access","rtcpeerconnection","videocall","webrtc","webrtc-tools"],"latest_commit_sha":null,"homepage":"https://npm.im/webrtc-test-suite","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theanam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-05T18:06:48.000Z","updated_at":"2023-07-24T06:53:26.000Z","dependencies_parsed_at":"2023-02-05T16:30:29.410Z","dependency_job_id":null,"html_url":"https://github.com/theanam/webrtc-test-suite","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theanam%2Fwebrtc-test-suite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theanam%2Fwebrtc-test-suite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theanam%2Fwebrtc-test-suite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theanam%2Fwebrtc-test-suite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theanam","download_url":"https://codeload.github.com/theanam/webrtc-test-suite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248143141,"owners_count":21054713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audiocall","checkinternet","getusermedia","getusermedia-access","rtcpeerconnection","videocall","webrtc","webrtc-tools"],"created_at":"2025-04-10T02:21:46.464Z","updated_at":"2025-10-03T12:48:32.610Z","avatar_url":"https://github.com/theanam.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Real life Capability testing and utilities for WebRTC. \n Testing webRTC capabilities by trying to use them. Not a feature detector. A capability tester.Also packs some utilities to make developer's live easier while making webRTC tools. \n\n## 🚀 [Test Your Browser](https://theanam.github.io/webrtc-test-suite)\n\n## What Can It do\n* Test basic feature support.\n* Test If `getUserMedia` Actually works.\n* Test if the browser and internet is capable of `RTCPeerConnection`\n* Test if the internet Speed is good enough for WebRTC streaming.\n* Handle API differences for `getUserMedia`, adding stream to DOM.\n* Provide utility functions for webRTC media application.\n\n## Installation:\n\n### Using a package manager:\nTo install the package use this command. \n```shell\nyarn add webrtc-test-suite\n```\nThen you can import it in your code like this:\n```js\nimport * as _rtc from \"webrtc-test-suite\";\n```\n\n### Including the JS file directly:\nAdd this to your HTML file:\n```html\n\u003cscript src=\"https://unpkg.com/webrtc-test-suite@2.1.2/dist/index.js\"\u003e\u003c/script\u003e\n```\nYou will get a global object called: `_rtc`. And you can access all the functionalities from that object.\n\n## How to use\nThis tool comes with a lot of capability test and utility functions. You can use them to create WebRTC enabled application and positively determine feature support. All the functions are described below.\n\n\u003e 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. \n\n\u003e 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`.\n\n\u003e Functions that accepts the `verbose` (Boolean) argument, will generate logs in the console if `verbose` is set to `true`. Default is `false`.\n\n\u003e Function that accepts a timeout, that will automatically reject if the internal request does not fulfill before time. setting the timeout to `0` will disable timeout. The default timeout for peer connection related functions is 30000ms (30 seconds) and for media capture is 60000ms (1 minute).\n### 0. `checkFeatureSupport`: \n\u003e 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*\n\n\u003e `checkFeatureSupport([verbose = false]) // Returns result object`.\n\nThis 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: \n\n```js\n{\n        video : {\n            basic    : true\n        },\n        audio : {\n            basic    : true,\n            webAudio : true\n        },\n        rtcPeerConnection : true,\n        rtcDataChannel    : false,\n        getUserMedia      : \"prefix-webkit\",\n        getDisplayMedia   : false\n    }\n```\nChecks available: \n\n| Check | Meaning |\n|-------|---------|\n|video.basic|Basic HTML5 Video Support|\n|audio.basic|Basic HTML5 Audio Support|\n|audio.webAudio|Support for Web Audio API|\n|rtcPeerConnection|Support for RTCPeerConnection API|\n|rtcDataChannel|Support for RTC Data Channel API|\n|getUserMedia|Support for the Audio Video Capture|\n|getDisplayMedia|Support for Screen Capture|\n\n\nAll the options can have these values:\n|Value | Meaning        |\n|------|----------------|\n|false | Unsupported    |\n|\"old\" | Supported, but with older version of the API |\n|\"prefix-webkit\"| Supported with `webkit` prefix|\n|\"prefix-moz\"| Supported with `moz` prefix |\n\n\n### 1. `checkMediaCapture` and `checkMediaCaptureSilent`:\n\u003e `checkMediaCapture(constraints, [verbose = false,getStream = false, timeout = 60000]); // Returns Promise`\n\nExample Use: \n```js\n_rtc.checkMediaCapture({audio: true, video: true})\n    .then(()=\u003econsole.log(\"Could capture media stream\"))\n    .catch(()=\u003econsole.error(\"Could not capture media stream\"));\n```\nThis function takes [MediaTrackConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints) as argument, calls `getUserMedia` API with those constraints, retrieves the Media stream, Checks if audio and video stream is active and according to the [constraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints) provided. Then automatically stops the media capture and returns the result. If `getStream` is set to true, the `mediaStream` is not stopped, it's returned instead, on success.\n\n### 2. `checkPeerConnection` and `checkPeerConnectionSilent`:\n\u003e `checkPeerConnection(RTCConfiguration, [verbose = false, timeout = 30000]) // Returns Promise`\n\nExample Use: \n```js\n_rtc.checkPeerConnection({})\n    .then(()=\u003econsole.log(\"Peer connection works\"))\n    .catch(()=\u003econsole.log(\"Peer connection does not work\"));\n```\nThis function takes [RTCConfiguration](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection#RTCConfiguration_dictionary) as argument Creates two `RTCPeerConnection` with the provided RTCConfiguration and creates a data channel between those two. Check if data transfer is possible between the two `RTCPeerConnection` instances. And returns the results. \n\n\u003e Tip: If you want to test your STUN (relay) server, pass `iceTransportPolict: \"relay\"` ([See Documentation](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection#RTCIceTransportPolicy_enum)) with your RTCConfiguration. This will force the two PeerConnection to communicate through the relay server. \n\n### 3. `checkRelayPerformance` and `checkRelayPerformanceSilent`:\n\u003e `checkRelayPerformance(RTCConfiguration, [verbose = false, timeout = 30000]) // Returns Promise`\n\nExample Use: \n```js\n_rtc.checkRelayPerformance(rtcConfig)\n    .then(()=\u003econsole.log(\"Peer connection works\"))\n    .catch(()=\u003econsole.log(\"Peer connection does not work\"));\n```\nThis function takes [RTCConfiguration](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection#RTCConfiguration_dictionary) as argument. Which is mandatory.It also requires the user to supply at least one TURN server configuration, Against which the performance will be measured.This creates two `RTCPeerConnection` with the provided RTCConfiguration and creates a data channel between those two. Then transfers a relatively large random data between the two over the relay server, measures how much time it took to transfer the data. And returns the results. \n\nSample Output:\n\n```js\n{\n    elapsed : 305, // ms\n    speed   : 5.8  // mbps\n}\n```\n\u003e If you are willing to run this test, you can `checkPeerConnection`. Also it shows an estimated result of what was observed at that time. \n\n### 4. `checkInternetSpeed` and `checkInternetSpeedSilent`:\n\u003e `checkInternetSpeed(\"probe/file.url\", [verbose]) // Returns Promise`\n\nExample use: \n```js\n_rtc.checkInternetSpeed(\"https://example-file.com/file.jpg\")\n    .then(speed=\u003econsole.log(`Your speed is ${speed}mbps`))\n    .catch(()=\u003econsole.log(\"could not test Internet Speed\"))\n```\nThis function takes a file URL (Give at least \u003e1mb for better results), somewhere in the web (better if it's in the same server as your TURN server), downloads the file and observes the download speed. This function makes use of the `fetch` API, so won't work with browsers that doesn't have `fetch` support (you can use a polyfill). This function returns the internet speed in `mbps`.\n\n One might Argue, Internet speed is not part of WebRTC. Well, If you don't have a decent internet connection WebRTC applications might now work. And it's always good to know if it will work or not. Hence, this function got a place here. \n\n \u003e Make sure the file you supplied isn't too large `\u003e2mb` and also make sure the file is CORS enabled (has `access-control-allow-origin` header);\n\n**Please note:** The users's *actual* internet speed and speed measured here can be different. This measures internet speed between the user's computer and the server the file was in and can be affected by a lot of factors. In my testing roughly `~1mbps` speed was enough for a smooth video call.\n\n\u003e Also, transfer rate over WebRTC can be significantly different from the measured internet speed, as it may or may not involve the server and may use a different protocol.\n\n\u003e This function can only give and estimate of the observed download speed. Upload speed is not measured. \n\n### 5. `countDevies` and `countDeviesSilent`:\n \u003e `countDevies([verbose = false]) // Returns Promise`\n\nExample use:\n```js\n_rtc.countDevices()\n    .then(result=\u003econsole.log(`You have ${result.audio.in} audio input devices`)\n    .catch(()=\u003econsole.log(\"device count failed\"));\n```\n This function counts all the audio video input output devices available(sort of).It returns an object like this: \n```js\n{\n    audio   : {in: 0, out: 0},\n    video   : {in: 0, out: 0},\n    unknown : 0\n}\n```\n\u003e A point to note here: The current API does not give a count of video output devices In some cases doesn't give count for audio output devices too, so these counts will be 0 most of the time. The value is put there just for aesthetics. Besides, if you can see the output on your display, You definitely have at least one video output, so nothing to freak out 🤞🏼\n\n## Utilities\nThese functions are internally used and are exposed to make RTC application development easier.\n\n### 6. `getUserMedia` and `getUserMediaSilent`: \n\n\u003e `getUserMedia(constraints, [verbose]) // Returns Promise`\n\nExample use: \n```js\n_rtc.getUserMedia(MediaTrackConstraints)\n    .then(stream=\u003e{\n        document.querySelector(\".video\").srcObject = stream;\n    })\n    .catch(()=\u003econsole.log(\"could not get media stream\"));\n```\nIf you are tired of handling different versions of `getUserMedia`, `webkitGetUserMedia` and the latest `mediaDevices.getUserMedia`, this function handles it for you. No matter what version of the API your browser supports, this function will call that version of the API and returns a promise with your media stream (or error). \n\nthis function takes [MediaTrackConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints) as argument.\n### 7. `createRTCPeerConnection`: \n\u003e `createRTCPeerConnection(peerConfiguration)`\n\nThis function creates a new RTCPeerConnection instance. It handles the API variations of `RTCPeerConnection`, `webkitRTCPeerConnection` and `mozRTCPeerConnection`. Returns `null` if none are supported.\n\n## Misc Utility Functions:\nThis tool also comes with some utility functions for the app developer's convenience. The functions were made for internal use of the tool and then provided for the end user. \n\n### The `utils` object: \nSmaller utilities are in the utils object. Mostly related to webRTC.\n\n#### 1. `utils.flat`: \n\u003e Returns Promise\n\nthis function takes a **promise as argument** and returns **another promise**. If the source promise is resolved, this functions's promise resolves with the result. If the source promise is rejected. This function's promise resoves with `null`. If you are working with `async-await` this will save you a lot of `try-catch` block. This works with any types of promises. This function is used to generate all the `silent` versions of this tool.\n\n#### 2. `utils.dom`: \nThis consists of two functions. Both are used to attach and detatch media stream to a dom element (`video` or `audio` tag). Why you may ask, because, new implementation has the `srcObject` property, older browsers had to use `createObjectURI` function to convert the stream into a Object URI. this will handle the variation for you.\nBoth functions return the DOM element.\n##### 1. `utils.dom.addStreamToDOM(domElement, stream)`: \nAdds a media stream to a DOM element. Example use: \n```js\n// Let's assume we got a media stream called `stream`\nlet domElement = document.querySelector(\"video.test\");\n_rtc.utils.dom.addStreamToDOM(domElement,stream);\n```\n##### 2. `utils.dom.addStreamToDOM(domElement, stream)`: \nRemoves any media astream from DOM element. Example use: \n```js\n// Let's assume we got a media stream called `stream`\nlet domElement = document.querySelector(\"video.test\");\n_rtc.utils.dom.removeStreamToDOM(domElement);\n```\n\n#### 3. `utils.stream`:\nthis object only contains one utility function now. This namespace is kept to add more functions later. \n\n##### 1. `utils.stream.stopMediaStream` and `utils.stream.stopMediaStreamSilent`:\nThis function takes a media Stream and stops all the tracks associated with it. This also releases the input devices. This is the IDEAL way to stop a media stream once you are done with it.\n\n\u003e this does not return a promise but the silent version is there to automatically handle any errors that may appear (since they are mostly non important)\n\nExample use: \n```js\n// For example, if we have a media stream named `stream`.\n_rtc.utils.stream.stopMediaStreamSilent(stream);\n```\n\n*** \nThis package is released under the MIT license, feel free to contribute.\n\nmade with 🖤 and JavaScript by Anam Ahmed.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheanam%2Fwebrtc-test-suite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheanam%2Fwebrtc-test-suite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheanam%2Fwebrtc-test-suite/lists"}