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

rtc-detect

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rtc-detect

rtc-detect

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
341
decreased by-32.34%
Maintainers
1
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()

Determines if 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()

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()

Get the current environment API support.

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()

Get the devices available for the current environment.

ItemTypeDescription
hasCameraPermissionbooleanwhether to have camera permission
hasMicrophonePermissionbooleanwhether to have microphone permission
camerasarrayUser's camera device list with maximum aspect and frame rate of supported video streams
microphonesarraymicrophone list
speakersarrayspeaker list
const detect = new RTCDetect();
const result = await detect.getDevicesAsync();

(async) getCodecAsync()

Get the support of the current environment parameters for encoding and decoding.

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()

Get current environmental monitoring reports.

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()

Detects if Chrome is hardware acceleration enabled.

Note: The implementation of this interface depends on the WebRTC native interface, so it is recommended to call this interface after isTRTCSupported detection support. The maximum detection time is 30 s. As tested:

  1. with hardware acceleration on, the interface takes about 2s for Windows and 10s for Mac.
  2. With hardware acceleration off, the interface takes 30s on both Windows and Mac.

Translated with www.DeepL.com/Translator (free version)

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 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 11 Feb 2022

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