
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@juphoon/webrtc-room-sdk
Advanced tools
将SDK中的文件放入项目的开发路径下,确保项目可以引用到相关文件。SDK可以通过ES6的 import
关键字, require
或 <script>
标签引入.
// es6
import { JRTCWeb } from 'JRTC_WEBRTC_ROOM_SDK.js';
// require
const JRTCSDK = require('JRTC_WEBRTC_ROOM_SDK.js');
// <script>标签
<script src="xxx/JRTC_WEBRTC_ROOM_SDK.js" type="text/javascript"></script>
使用 JRTCWeb.setConfig 接口设置环境。
可供设置的参数有(具体查看JRTCConfig)
JRTCWeb.setConfig({
address: '',
...
});
通过 JRTCWeb.createClient 接口创建 WebRTCRoom 对象。
const client = JRTCWeb.createClient();
调用 WebRTCRoom.join 接口加入房间
room.join('userId', 'roomId', 'appKey', 'token')
.then(() => {
// 加入房间成功
})
.catch((reason) => {
// 加入房间失败
});
JRTCWeb.createMediaDeviceStream接口会通过采集媒体设备(摄像头/麦克风)的音视频创建一个音视频流对象(IRTCStream).
IRTCStream对象可通过WebRTCRoom.publish发布本地音视频流, 通过IRTCStream.start将画面渲染到页面上.
渲染模式可指定两种渲染模式:
渲染模式可通过IRTCStream.reset设置, 参数请参考IRTCStreamOptions
<div id="local-video" style="width: 400px; height: 300px;"></div>
const {JRTCWeb} = JCCSDK;
const stream = await JRTCWeb.createMediaDeviceStream();
stream.start('local-video'); // 将画面渲染到id为 local-video 的 dom元素中
创建本地音视频流后可调用WebRTCRoom.publish发布本地音视频流.
成功发布后, 远端用户将收到 participant-published
事件回调.
目前只支持发布一路音视频流, 需要切换发布的音视频流时, 需要调用unpublish将已发布的IRTCStream对象取消发布.
await room.publish(stream);
调用WebRTCRoom.unpublish取消发布音视频流, 远端用户将收到 participant-unpublished
事件回调.
await room.unpublish();
目前只有一路远端用户音视频流, 房间中成员的音视频流会在服务器合并, 不支持订阅指定用户的音视频流
加入房间成功后, 即会收到一个特殊用户(虚拟的合流用户)的 participant-published
事件, 该用户的音视频流即是经过服务器合流的画面.
room.addEventListener('participant-published', ({message}) => {
const {participant} = message.data;
room.subscribe(participant)
.then((stream) => stream.start('userId', document));
});
当我们获取到了远端的音视频数据并开始播放时,有可能会收到浏览器的自动播放策略限制。 自动播放限制 是指如果以下任何一项未发生则媒体不允许播放:
<iframe>
授予自动播放权限取消订阅远端用户的媒体流, 将会释放远端用户媒体流并从文档中移除绑定的 HTMLVideoElement, HTMLAudioElement 元素, 音视频播放都将停止.
room.unsubscribe();
调用 WebRTCRoom.leave 接口离开会议
client.leave();
room.addEventListener('connect-state-change', (ev) => {
const {state, oldState} = ev.message;
// todo
});
FAQs
dependency web-room-sdk, implement webrtc
We found that @juphoon/webrtc-room-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.