我正在使用 webrtc+janusgateway+streamCapture 构建流服务。
这,开始流式传输视频:
public streamVideo() {
var video = $('#video1').get(0);
var stream;
video.onplay = () => {
if (video.captureStream) {
stream = video.captureStream();
} else if (video.mozCaptureStream) {
stream = video.mozCaptureStream();
} else {
alert('captureStream() not supported');
}
console.log(stream);
$("#secondvideoforll").get(0).srcObject = stream;
this.sfutest.createOffer(
{
media: { audioRecv: 0, videoRecv: 0, audioSend: 1, videoSend: 1}, // Publishers are sendonly
stream: stream,
success: (jsep) => {
Janus.debug("Got publisher SDP!");
Janus.debug(jsep);
var publish = { "request": "configure", "audio": 1, "video": 1 };
this.sfutest.send({"message": publish, "jsep": jsep});
},
error: (error) => {
Janus.error("WebRTC111 error:", error);
}
});
}
}
视频播放效果很好,但是当我尝试创建报价(以及进一步的 addStream)时。我收到此错误:
WebRTC111 error: DOMException [InternalError: "Cannot create an offer with no local tracks, no offerToReceiveAudio/Video, and no DataChannel."
code: 0
nsresult: 0x0]
相同的报价创建(不带 stream 参数)适用于网络摄像头流式传输,但不适用于视频流。
我发现的主要区别是网络摄像头使用:LocalMediaStream
,而我streamCapture
使用 MediaStream。
关于这个有什么想法吗?