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 🙏

© 2025 – Pkg Stats / Ryan Hefner

omnirtc-web

v1.6.0

Published

直播中台WebRTC SDK。如需接入,联系兰龙刚([email protected]) # Omni_WebRTC

Downloads

691

Readme

直播中台WebRTC SDK。如需接入,联系兰龙刚([email protected]

Omni_WebRTC

引入SDK

  • ES Module引入
import { getRTCInstance } from 'omnirtc-web';

加入RTC房间

  /**
   * 获取token,
   * 获取方式参考 https://wiki.zhiyinlou.com/pages/viewpage.action?pageId=30835986
   * 有问题联系周伟伟([email protected])老师 
   **/
  const token = 'token';
  // 获取引擎实例
  // engine API详细 https://dev-webrtc.weclassroom.com/doc/classes/CoreRTC.CoreRTC-1.html
  const engine = getRTCInstance(token);

  // 加入RTC房间
  // client API详细 https://dev-webrtc.weclassroom.com/doc/classes/Client.Client-1.html
  const client = engine.createClient({
    mode: 'live',
    codec: 'h264'
  });

  // 监听会议相关事件
  client.on('user-joined', (user) => {
    console.log('有用户加入房间。', user.uid)
  })
  client.on('user-left', (user, reason) => {
    console.log('用户离开房间了。', user.uid)
  })

  // 有其他用户开始推流了
  client.on('user-published', async (user, mediaKind) => {
    console.log('用户开始推流了。', user.uid, mediaKind)

    // 在这里就可以拉取该用户的流了,也可以先保存user,延后再拉。
    const track = await client.subscribe(user, mediaKind);

    console.log('媒体流已就绪,可以播放。', user.uid, mediaKind);
    if (mediaKind === 'audio') {
      track.play();
    }

    if (mediaKind === 'video') {
      track.play('video-dom');
    }
  })
  client.on('user-unpublished', (user, mediaKind) => {
    console.log('用户停止推流了。', user.uid, mediaKind)
  })

  client.join().then((uid) => {
    console.log('您已经加入房间了。您的用户ID:', uid)
  });
  ...

推送媒体流

  • 推送媒体流必须在调用client.join之后
  // 打开摄像头和麦克风
  const tracks = await engine.createMicrophoneAndCameraTracks();
  // 推送音视频流
  await client.publish(tracks);

拉取远端流

  • 必须在收到远端用户user-published之后再调用client.subsribe
  // 拉取远端用户音频流
  const audioTrack = await client.subscribe(user, 'audio');
  audioTrack.play();

  // 拉取远端用户视频流
  const videoTrack = await  client.subscribe(user, 'video');
  videoTrack.play('video-dom');

注意事项

  • 建议开发者捕获播放失败的事件
  engine.onAudioAutoplayFailed = () => {
    console.log('音频播放失败。')
    // 建议用户和页面交互后再调用track.play()
    // 参考https://www.jianshu.com/p/c3c6944eed5a
  }

AIGC能力使用

AIGC能力是RTC能力的扩展,要正常使用AIGC能力,需要先保证RTC能力正常使用

引入AIGC模块

  • ES Module引入
import { Aigc } from 'omnirtc-web/aigc';

初始化

// 与getRTCInstance使用同一个token  !important
const aigc = new Aigc(token);

查询Aigc默认配置

const configs = aigc.query();
console.log('应用的默认配置:', configs)

开始Aigc

const robotId = Math.random().toString().substring(2,10);

// 可以为空对象{},这样就使用后台配置的默认设置
const aigcConfig = {
  prompt: '你是一个一对一数学老师,协助我完成家庭作业'
}

// 可以不传
const otherConfig = {
  extenParams: {}
}
aigc.start('voicechat', aigcConfig, robotId, otherConfig);

对话中更新配置

import { TaskTypeEnum } from 'omnirtc-web/aigc'
// 更细提示词
const data = {
  prompt: '你是一个一对一英语老师,接下来的对话使用英语回复我,并且纠正我的语法和单词错误'
}
aigc.update(TaskTypeEnum.UPDATE_PROMPT, data)

// 更多功能可以查看TaskTypeEnum的定义

绑定RTCClient与Aigc实例,接收来自rtc房间的aigc消息

import { Events } from 'omnirtc-web/aigc'
aigc.on(Events.MESSAGE, (data) => {
  console.log('receive aigc message: ', data)
})
aigc.bind(client);

停止Aigc

aigc.stop()