npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

live-cat

v2.1.4

Published

ray-streaming launcher for 3dcat

Downloads

348

Readme

3DCAT RayStreaming Launcher

RayStreaming Launcher

Quick start

instantiation parameter

type Phase =
  | 'initial'
  | 'signaling-connected'
  | 'node-ready'
  | 'end-candidate'
  | 'peer-connection-connected'
  | 'data-channel-open'
  | 'streaming-ready'
  | 'loaded-metadata'
  | 'streaming-playing'

interface Options {
  minBitrate: number
  maxBitrate: number
  startBitrate: number
  rateLevel: RateLevel

  startType: StartType
  autorunRivatuner: boolean
  enableLogPersistent: boolean
  audioToastDisplay: boolean
  iceTransportPolicy: RTCIceTransportPolicy
  autoLoadingVideo: boolean
  isFullScreen: boolean
  openMicrophone: boolean
  openMultiTouch: boolean

  needLandscape: boolean
  landscapeType: LandscapeType
  settingHoverButton: VirtualControlDisplayType
  keyboardMappingConfig?: VirtualGlobalType
  inputHoverButton: InputHoverButton

  toolbarLogo: string
  toolOption?: ToolOptionType
  eventOption?: eventOptionType
  onError: (reason: ErrorState) => void
  onPhaseChange: (phase: Phase, deltaTime: number) => void
  onPlay: () => void
  onMount: (element: HTMLElement) => void
  onRotate: (rotate: boolean) => void
}
enum RateLevel {
  SD,
  HD,
  FHD,
  UHD4K,
}
enum StartType {
  Normal = 1,
  Screen = 3,
}
enum VirtualControlDisplayType {
  HideAll,
  DisplayMobile,
  DisplayPc,
  DisplayAll,
}
interface VirtualGlobalType {
  showButton: boolean
  landscape: VirtualDataType[]
  portrait: VirtualDataType[]
}
type VirtualDataType = {
  type: ScreenDataType
  value: SolutionValue
  scale?: number
}

enum ScreenDataType {
  Normal = 1,
  UDLR,
  WASD,
  Joystick,
  Mouse,
}
type SolutionValue = {
  pos: number[]
  value: number[]
  width?: number
  height: number
  shape?: SolutionShape
}
enum SolutionShape {
  Rectangle = 1,
  Circle,
}
enum InputHoverButton {
  Hide,
  Display,
}
import { Launcher } from 'live-cat'

// NOTE: signaling,token and iceServers were provided by 3dcat
const signaling = 'wss://xxxxx'
const token = 'xxxxxxxx'
const iceServers = [
  {
    urls: 'turn:xxx.xxx.xxx.xxx',
    username: 'xxxxxx',
    credential: 'xxxxxx',
  },
  {
    urls: 'stun:xxx.xxx.xxx.xxx',
    username: 'xxxxxx',
    credential: 'xxxxx',
  },
]

const bootstrap = () => {
  const container = document.querySelector('body')
  document.querySelector('body').style.width = '100%'
  document.querySelector('body').style.height = '100%'
  const launcher = new Launcher(
    `${signaling}/clientWebsocket/${token}`,
    iceServers,
    container,
    options,
  )
}
window.addEventListener('DOMContentLoaded', () => {
  if (
    navigator.userAgent.includes('miniProgram') ||
    navigator.userAgent.includes('MicroMessenger')
  ) {
    //NOTE: wechat environment started
    document.addEventListener('WeixinJSBridgeReady', bootstrap)
  } else {
    bootstrap()
  }
})

Adjust bandwidth

Launcher.connection().changeBandwidth(
  8000, // start bitrate kbps
  10000, // max bitrate kbps
  5000, // min bitrate kbps
)
Launcher.connection().changeBandwidth(
  10000, // medians bitrate kbps
)

Statistics

window.setInterval(() => {
  const { fps, bitrate, packetLossRate, latency, averageJitterBufferDelay } = launcher.report()
  console.log(`
    FPS: ${fps}
    biterate: ${bitrate}kbps
    latency: ${latency}ms
    averageJitterBufferDelay: ${averageJitterBufferDelay}ms
    packetLossRate: ${(packetLossRate * 100).toFixed(3)}%
  `)
}, 1000)

ToggleFullscreen

/* NOTE: fullscreen need user activation gesture
 * @see https://html.spec.whatwg.org/multipage/interaction.html#user-activation-processing-model
 */
someTriggerElement.addEventListener('click', () => launcher.toggleFullscreen())

Dashboard

// ...
launcher.showDashboard()
launcher.hideDashboard()
// NOTE: export statistics and log data
launcher.exportLog()

Microphone

// start capture audio to node
launcher.openMicrophone()
// stop
launcher.closeMicrophone()

Camera

// start capture video to node
launcher.openCamera()
// stop
launcher.closeCamera()

File Transfer

//Upload file to node

//Note: When dir is empty, it actually points to the "<User>/Downloads" directory in node
launcher.changeUploadDir(dir:string)
launcher.uploadFile(file: File, onStateChange?: FileUploadStateChangeHandler)

//Download file from node
launcher.downloadFileByFullPath(absolutePath:string)

Destroy

launcher.destroy()