2016-05-06 22 views
0

我正在尝试使用Kurento桥接webRTCendpoint到RTPendpoint。 webRTCendpoint客户端是Chrome浏览器。 RTPendpoint客户端是一个SIP服务器(代理/ B2BUA)。这是基本的代码或伪代码,我有(我用Kurento-client.js在我的应用程序服务器):需要澄清在Kurento的API连接webRTCEndpoint到RTPEndpoint

//On receipt of offer from the WebRTC Browser-Peer 
mySignalling.on('sdpOffer', function(sdpOffer) { //Action starts! 

    //Create Mediapipeline so that endpoints can be created 
    kurentoClient.create('MediaPipeline', function(error, pipeline) { 
    pipeline.create('webRtcEndpoint', function(error, myWebrtcEndpoint) { 
     //Get ICE Candidates from webRTC endpoint to send to browser 
     mySignalling.on('candidate', function(candidate) { 
      myWebrtcEndpoint.addIceCandidate(candidate); 
     }); 
     myWebrtcEndpoint.on('OnIceCandidate', function(event) { 
      var candidate = kurento.register.complexTypes.IceCandidate(event.candidate); 
      mySignalling.send(candidate); //Send ICE candidate to webRTC browser peer 
     }); 
     pipeline.create('rtpEndpoint', function(error,myRtpEndpoint) { 
     myWebrtcEndpoint.connect(myrtpEndpoint,function(error){ }); 
     myWebrtcEndpoint.processOffer(sdpOffer, function(error, sdpAnswer) { 
      mySignalling.send(sdpAnswer); //Send answersdp to browser 
     }); 
     myRtpEndpoint.generateOffer(function(error){ 
      myRtpEndpoint.getLocalSessionDescriptor(function(error, sdpRTP) { 
      mySignalling2.send(sdpRTP); //Send SDP to Asterisk as part of SIP INVITE 
      }); 
     }); 
     }); 
    }); 
    }); 
}); 

我有几个问题:

  1. 是整体结构是否正确?
  2. webRTCEndpoint.gatherCandidates有什么用?该文档说它必须在processOffer之后调用。为什么?它如何连接到addIceCandidate方法?
  3. RTPendpoint连接到webrtcEndpoint,但是如何控制RTPEndpoint generateOffer生成的RTP配置文件?我的意思是,我如何从RTPEndpoint获取RTP/AVPF而不是RTP/AVP?如果没有,并且AVPF必须映射到AVP,则Kurento将处理AVPF中的“F”,同时将AVPF桥接到AVP。

我还没有添加,为简单起见,错误处理,OnIceGatheringDone事件处理,提供了多用户/会话等

作为一个方面,我建设我自己的SIP请求的应用服务器并处理SIP响应。如果需要,我将更改由RTPEndpoint.generateOffer生成的SDP(如果需要)。当我克服这个最初的障碍时,会来到这一点!

回答

3

1)看起来很好。如果您愿意,您可以在创建RtpEndpoint之前完成WebRtcEndpoint协商。此外,你错过了gatherCandidates的电话,这是你的下一个问题。

2)gatherCandidates用于发信号通知WebRtcEndpoint开始收获ICE候选者。这是trickle ICE,它是ICE协议的优化:候选发现后发出,并发送给另一个同伴进行探测。这加快了连接时间,因为在收获所有物品之前可以找到合适的人选(可能需要20秒或更长时间)。 WebRtcEndpoint需要将候选者发送给远程对等者,而从远程对等者接收到的候选者则使用addIceCandidate方法进行处理。如果您在处理要约或生成答案之前致电gatherCandidates,那些候选人将被添加到SDP要约或答案中,并且您将使用Vanilla ICE。 3)如果您打算仅使用RtpEndpoint进行发射,我建议您提供一个具有您需要的选项的损坏的SDP,并让它提供该端点进程。例如,如果您要发送给Wowza,您可以修复Wowza Media Server期望RTP流的IP和端口。

+0

谢谢。第2点:您说:“如果您在处理报价或生成答案之前致电collectCandidates,那些候选人将被添加到SDP报价或答案中,并且您将使用Vanilla ICE。”据我所知,在浏览器中,本地ICE候选人在setLocalDescription调用之后被解雇。当浏览器获取信息来生成准确的候选人时,这与“Vanilla”ICE相反是有意义的。因此,在Kurento,候选人不应被解雇,直到处理远程报价并生成答案。应该不需要collectCandidates方法。我错过了什么? – Sam

+0

第3点:我将使用RTPEndpoint和来自两端的媒体流。 “损坏的SDP”,你的意思是手动编码的SDP?由于我必须桥接来自RTPEndpoint的SIP呼叫,并且事先知道SIP电话支持的SDP,因此我可以拥有一个rtpEndpoint。processOffer基于SIP电话的SDP,或者我可以启动一个generateOffer,我认为它会给我“Vanilla”SDP或Kurento中的所有可能的RTP功能,我可以使用我的SIP INVITE请求进行标记。哪个更好? **是否有关于Kurento支持的RTP配置文件的任何文档?**是否支持RTPEndpoint中的AVPF? – Sam

+0

有关rtpEndpoint [此处](https://doc-kurento.readthedocs.io/en/stable/_static/langdoc/jsdoc/kurento-client-js/module-elements.RtpEndpoint.html)的文档缺少许多方法,如generateOffer,getLocalSessionDescriptor,...或者我在错误的地方看? – Sam