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

rtc-detect

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rtc-detect

rtc-detect

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
341
decreased by-32.34%
Maintainers
2
Weekly downloads
 
Created
Source

rtc-detect

rtc-detect is used to detect whether the current environment is working smoothly in WebRTC application built by TRTC SDK.

NPM version NPM downloads trtc.js Documents Stars

English | 简体中文

Introduction

rtc-detect is used to detect whether the current environment is working smoothly in WebRTC application built by TRTC SDK.

Install

npm install rtc-detect

How to use

import RTCDetect from 'rtc-detect';
// init
const detect = new RTCDetect();
// get detect result
const result = await detect.getReportAsync();
console.log('result is: ' + result);

API

(async) isTRTCSupported()

This API is used to check whether the current environment supports TRTC.

const detect = new RTCDetect();
const data = await detect.isTRTCSupported();

if (data.result) {
  console.log('current browser supports TRTC.')
} else {
  console.log(`current browser does not support TRTC, reason: ${data.reason}.`)
}

getSystem()

This API is used to get the current system environment parameters.

ItemTypeDescription
UAstringuser agent
OSstringsystem
browserobjectbrowser infomation: { name, version }
displayResolutionobjectresulution: { width, height }
getHardwareConcurrencynumbercurrent device CPU core count
const detect = new RTCDetect();
const result = detect.getSystem();

getAPISupported()

This API is used to get the API support of the current environment.

ItemTypeDescription
isUserMediaSupportedbooleanwhether to support getting user media from media device
isWebRTCSupportedbooleanwhether to support WebRTC
isWebSocketSupportedbooleanwhether to support WebSocket
isWebAudioSupportedbooleanwhether to support WebAudio
isScreenCaptureAPISupportedbooleanwhether to support getting media steam from screen
isCanvasCapturingSupportedbooleanwhether to support getting media stream from canvas element
isVideoCapturingSupportedbooleanwhether to support getting media stream from video element
isRTPSenderReplaceTracksSupportedbooleanwhether to support not renegotiating with peerConnection when replacing track
isApplyConstraintsSupportedbooleanwhether to support changing the resolution of the camera without re-calling getUserMedia
const detect = new RTCDetect();
const result = detect.getAPISupported();

(async) getDevicesAsync()

This API is used to get the available devices in the current environment.

ItemTypeDescription
hasWebCamPermissionsbooleanWhether the user camera data can be obtained
hasMicrophonePermissionbooleanWhether the user mic data can be obtained
camerasarrayA list of the user's camera devices, including information on the resolution of supported video streams, maximum aspect and maximum frame rate (maximum frame rate is not supported by some browsers)
microphonesarrayA list of user mics
speakersarrayA list of user speakers

CameraItem

ItemTypeDescription
deviceIdstringDevice ID, which is usually unique and can be used to capture identifying devices
groupIdstringGroup identifier, two devices have the same group identifier if they belong to the same physical device
kindstringCamera device type: 'videoinput'
labelstringLabel describing this device
resolutionobjectInformation about the camera's supported resolutions, maximum width and height, and maximum frame rate, eg: {maxWidth: 1280, maxHeight: 720, maxFrameRate: 30}

DeviceItem

ItemTypeDescription
deviceIdstringDevice ID, which is usually unique and can be used to capture identifying devices
groupIdstringGroup identifier, two devices have the same group identifier if they belong to the same physical device
kindstringPhysical device type, eg: 'audioinput', 'audiooutput'
labelstringLabel describing this device
const detect = new RTCDetect();
const result = await detect.getDevicesAsync();

(async) getCodecAsync()

This API is used to get the codec support of the current environment.

ItemTypeDescription
isH264EncodeSupportedbooleanwhether to support h264 uplink
isH264DecodeSupportedbooleanwhether to support h264 downlink
isVp8EncodeSupportedbooleanwhether to support vp8 uplink
isVp8DecodeSupportedbooleanwhether to support vp8 downlink
const detect = new RTCDetect();
const result = await detect.getCodecAsync();

(async) getReportAsync()

This API is used to get the detection report of the current environment.

ItemTypeDescription
systemobjectsame as getSystem() result
APISupportedobjectsame as getAPISupported() result
codecsSupportedobjectsame as getCodecAsync() result
devicesobjectsame as getDevicesAsync() result
const detect = new RTCDetect();
const result = await detect.getReportAsync();

(async) isHardWareAccelerationEnabled()

This API is used to check whether hardware acceleration is enabled on the Chrome browser.

Note: the implementation of this API depends on the native WebRTC API. We recommend you call this API for check after calling isTRTCSupported. The check can take up to 30 seconds as tested below:

  1. If hardware acceleration is enabled, this API will take about 2 seconds on Windows and 10 seconds on macOS.
  2. If hardware acceleration is disabled, this API will take about 30 seconds on both Windows and macOS.
const detect = new RTCDetect();
const data = await detect.isTRTCSupported();

if (data.result) {
  const result = await detect.isHardWareAccelerationEnabled();
  console.log(`is hardware acceleration enabled: ${result}`);
} else {
  console.log(`hardware acceleration is disabled`)
}

Changelog

Version 1.0.3 @2023.12.28

Improvement

  • Avoid the problem that navigator.mediaDevices has no method in some browsers.

Version 1.0.2 @2023.04.24

Improvement

  • Optimising the performance of certain Android devices.

Version 1.0.1 @2023.04.17

Improvement

  • Optimising performance on Windows.

Version 1.0.0 @2023.03.17

Bug Fixed

  • Fixed resource usage on Safari.

Version 0.0.5 @2022.02.11

Feature

  • The camera object obtained from the getDevicesAsync() method has a new maxFrameRate parameter indicating the maximum frame rate supported by the camera.

Version 0.0.4 @2021.09.06

Improvement

  • Add reasons for detecting when WebRTC is not supported.

Version 0.0.3 @2021.08.09

Feature

  • Added isHardWareAccelerationEnable() method to detect if Chrome has hardware acceleration enabled.

Version 0.0.2 @2021.07.24

Improvement

  • Optimize the naming of some parameters.

Version 0.0.1 @2021.07.13

  • publish rtc-detect@0.0.1.

Keywords

FAQs

Package last updated on 28 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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