WebRTC Adding remote stream to PeerConnection

柔情痞子 提交于 2019-12-11 05:23:59

问题


I'm working on WebRTC for Android. And successful create and establish Conference. Using single MediaStream and several PeerConnection.

Now I want to find a better way, and one of them it's relay connection. My question is, crating relay as described on Chromium Report. And I supposed to do same thing, but there several issues. So lets start.

  1. Make a successful peer connection. (A -> B)
  2. Relay the remote media stream using another peer connection ( B -> C).
  3. The relayed media stream (A ->-> C) should be played on the final endpoint.

So for User B, we should take remote stream from PeerConnection of User A, and add stream to the PeerConnection of User C. And how it make with Java library?

// Local Media Stream, just as example for this question
// Local stream of current User B
MediaStream mediaStream = new MediaStream(...);

PeerConnection peerA = new PeerConnection(...);
PeerConnection peerC = new PeerConnection(...);

peerA.addStream(mediaStream);
peerB.addStream(mediaStream);

// Now this User (User B) can here User A and B
// Connection successful establish. 

// Here is question, how I can fetch remote 
// MediaStream object from PeerConnection A?

How I can fetch remote MediaStream objects from PeerConnection A and adding them to the other PeerConnection C?


What I also tried to do, its fetching RTPSender and RTPReceiver from PeerConnection. After that I can access to the MediaStreamTrack of remote site. But I cannot put this object to the other PeerConnection.


回答1:


You take the stream you normally get from pc.onaddstream which you fed to a video element, and instead pc.addStream it to a new peer connection.

The WebRTC samples have an example that covers using multiple relays like this.



来源:https://stackoverflow.com/questions/40266190/webrtc-adding-remote-stream-to-peerconnection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!