1

我目前正在使用 webRTC 开发视频通话应用程序。我已经使用

  1. 点对点
  2. 开放式托克
  3. 简单的webrtc

我能够实现的组件是:

  1. 创造房间

  2. 两个或更多用户可以加入这个房间

  3. 可以进行实时聊天

  4. 视频可以禁用

  5. 视频录制

    调用完成:

  6. 呼叫发起人正在创建房间

  7. 参与者正在使用房间名称加入房间

但我想要一种机制,发起者拨打参与者的电话。参与者应该选择或拒绝呼叫。如何使用 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);
        }
    });
});

4

0 回答 0