问题
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.
- Make a successful peer connection. (A -> B)
- Relay the remote media stream using another peer connection ( B -> C).
- 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