[英]WebRTC: How to add stream after offer and answer?
I am working on webRTC video calling. 我正在进行webRTC视频通话。 I got datachannel successfully implemented. 我已成功实施datachannel。 Now I would like to add video stream to the same peer connection. 现在我想将视频流添加到同一个对等连接。
I have read that stream should be added before answer and offer. 我已经读过应该在回答和提供之前添加流。 Is there a way to add stream after answer or offer? 有没有办法在回答或提供后添加流?
In case I have added stream before offer or answer, how could I stop streaming and start it again when needed? 如果我在提供或回答之前添加了流,我怎么能停止流式传输并在需要时再次启动它?
Could there be any issues in maintaining so many streams? 维护这么多流可能有任何问题吗?
To add stream after creating complete signalling, the Peer connection should renegotiate with stream. 要在创建完整信令后添加流,Peer连接应与流重新协商 。
pc1.addstream(stream)
Then once again create offer and send it to other Peer. 然后再次创建优惠并将其发送给其他同行。
Remote peer will add stream and send answer SDP. 远程对等体将添加流并发送应答SDP。
To stop streams: 要阻止流:
stream.stop();
pc1.removeStream(stream);
In my experience, what Konga Raju advised didn't work. 根据我的经验,Konga Raju建议不起作用。 I couldn't send an "updated offer" and have the video streaming actually happen. 我无法发送“更新的优惠”并且实际上发生了视频流。
I found that this sequence of events works for my case, in which I wish to stream video from peer 1 to peer 2. 我发现这个事件序列适用于我的情况,我希望将视频从对等体1流式传输到对等体2。
addIceCandidate
with it 从另一方发送的冰候选人==>用它调用addIceCandidate
SetRemoteDescription
& make an answer & send it 要约消息==> SetRemoteDescription
并回答并发送 SetRemoteDescription
答案消息===> SetRemoteDescription
getUserMedia
call) 当两个对等体都存在且所有处理程序都到位时,对等体1获得某种触发消息以开始视频捕获( getUserMedia
调用) getUserMedia
succeeds, we have a stream. 一旦getUserMedia
成功,我们就有了一个流。 Call addStream
on the peer connection object. 在对等连接对象上调用addStream
。 I haven't found a way to add video after step 9. When I want to change something, I go back to step 3. 我还没有找到在步骤9之后添加视频的方法。当我想要改变某些内容时,我会回到第3步。
MediaStream should be added to peerconnection first only then exchange of offer, answer ,candidates should be done. 首先应该将MediaStream添加到peerconnection,然后才能进行提议,答案,候选人的交换。 If the onAddStream() is called ,that mean you are receiving the remote video. 如果调用onAddStream(),则表示您正在接收远程视频。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.