我一直在尝试使用 制作一个简单的视频通话界面JsSIP
,到目前为止,我只设法启动了一个视频通话,并且接收者获取了我的音频和视频流,但是当我尝试添加流时(本地或远程) 到<video>
我页面中的一个元素,我得到了错误"Bad Media Description"
。
我的代码是这样的:
const address = "my.address.com";
const pass = "pass";
const callee = "id2";
const user = "id1";
const sockets = [];
const localStream = new MediaStream();
const config = {
sockets: sockets,
uri: `sip:${user}@${address}`,
password: pass
};
const agent = new JsSIP.UA(config);
const servers = {
iceServers: [
{urls:"stun:stun.l.google.com:19302"}
]
};
const options = {
pcConfig: servers,
mediaConstraints: {
audio: true,
video: true
}
};
document.getElementById("localVideo").srcObject = localStream;
document.getElementById("buttonCall").addEventListener("click", call);
sockets.push(
new JsSIP
.WebSocketInterface(`wss://${address}:443/ws`)
);
agent.start();
agent.on("newRTCSession", function(data){
let dataSession = data.session;
dataSession.on("confirmed",function(e){
let localTracks = dataSession.connection.getSenders();
localStream.addTrack(localTracks[0].track);
localStream.addTrack(localTracks[1].track);
console.log(e);
document.getElementById("localVideo").play();
});
});
function call() {
agent
.call(
`sip:${callee}@${address}`,
options
);
}
如果有人能指出使这成为可能的正确方法,我将不胜感激。