我读了很多关于 webrtc 的例子,但我不明白如何在 A 和 B 之间聊天视频 p2p,但只需要 A 使用 p2p 连接向 B 发送流视频,如何做到这一点?我试图在 B {video : false} 中禁用本地视频,但它有错误,无法正常工作。
我的剧本
<!DOCTYPE html>
<html>
<head>
<script src="https://simplewebrtc.com/latest-v2.js"></script>
<script type="text/javascript">
var webrtc = new SimpleWebRTC({
// the id/element dom element that will hold "our" video
localVideoEl: 'localVideo',
// the id/element dom element that will hold remote videos
remoteVideosEl: 'remotesVideos',
// immediately ask for camera access
autoRequestMedia: true,
//https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
//https://github.com/andyet/signalmaster/blob/master/README.md
media: {
audio: false,
video: {
//width: 720,
width: {ideal: 640},
// height: 1280,
height: {ideal: 480},
frameRate: {ideal: 15}
}
},
receiveMedia: {
offerToReceiveAudio: 0,
offerToReceiveVideo: 1
}
});
// we have to wait until it's ready
webrtc.on('readyToCall', function () {
// you can name it anything
webrtc.joinRoom('zika ghe vl');
});
</script>
</head>
<body>
<div id="remotesVideos"></div>
</body>
</html>