2016-11-07 145 views
0

我使用的WebRTC + janusgateway + streamCapture建设流媒体服务WebRTC111错误:抛出:DOMException [InternalError该:“无法创建本地没有轨道的报价,没有offerToReceiveAudio /视频,并没有DataChannel

此,启动流媒体视频:

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] 

同样的报价创建(不带流参数)适用于网络摄像机,但不适用于视频流。

我发现的主要区别是,网络摄像头使用:LocalMediaStream,而我的streamCapture使用MediaStream。

对此有何意见?

回答

0

当调用video.captureStream()时,getTracks()返回空数组,但在1.5秒后,它会按预期返回曲目。如果没有添加曲目生产

错误:WebRTC111 error: DOMException [InternalError: "Cannot create an offer with no local tracks, no offerToReceiveAudio/Video, and no DataChannel

添加此为文档的目的,因为别人可能会觉得迷惑。

解决方案:

setInterval(function(){ 
// We wait till the mediaTracks are added to mediaStream 
console.log(stream.getTracks()); 
// Further actions with the mediaStream 
}, 1000); 

谢谢!

参考:https://github.com/w3c/webrtc-pc/issues/923