我目前正在使用 webRTC 开发视频通话应用程序。我已经使用
- 点对点
- 开放式托克
- 简单的webrtc
我能够实现的组件是:
创造房间
两个或更多用户可以加入这个房间
可以进行实时聊天
视频可以禁用
视频录制
调用完成:
呼叫发起人正在创建房间
参与者正在使用房间名称加入房间
但我想要一种机制,发起者拨打参与者的电话。参与者应该选择或拒绝呼叫。如何使用 simplewebRTC 或 openTok 来完成?或者哪些其他库支持上述功能..请帮助..
<script src="scripts/simplewebrtc/out/simplewebrtc-with-adapter.bundle.js"></script>
// We got access to local camera
webrtc.on('localStream', () => {
console.log("hello");
localVideo.show();
});
function action(data) {
username = $('#username').val();
const roomName = $('#roomName').val().toLowerCase();
reject.hide();
if (data === 'create-btn') {
createRoom(roomName);
}else if(data === 'reject'){
console.log("reject");
}
else {
joinRoom(roomName);
}
return false;
};
// Join existing Chat Room
const joinRoom = (roomName) => {
console.log(`Joining Room: ${roomName}`);
webrtc.joinRoom(roomName);
showChatRoom(roomName);
postMessage(`${username} joined chatroom`);
};
// Remote video was added
webrtc.on('videoAdded', function (video, peer) {
console.log('video added', peer);
let remotes = document.getElementById('remote-videos');
if (remotes) {
let d = document.createElement('div');
d.className = 'videoContainer';
d.id = 'container_' + webrtc.getDomId(peer);
d.appendChild(video);
remotes.appendChild(d);
}
//VIDEO REMOVED
webrtc.on('videoRemoved', function (video, peer) {
console.log('video removed ', peer);
let remotes = document.getElementById('remote-videos');
let el = document.getElementById('container_' + webrtc.getDomId(peer));
if (remotes && el) {
remotes.removeChild(el);
}
});
});