WebRTC 将远程流添加到 PeerConnection [英] WebRTC Adding remote stream to PeerConnection

查看:47
本文介绍了WebRTC 将远程流添加到 PeerConnection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发适用于 Android 的 WebRTC.并成功创建和建立会议.使用单个 MediaStream 和多个 PeerConnection.

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

现在我想找到一种更好的方法,其中之一是中继连接.我的问题是,按照 Chromium 报告 中所述的板条箱中继.我应该做同样的事情,但有几个问题.那么让我们开始吧.

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. 建立成功的对等连接.(A -> B)
  2. 使用另一个对等连接 (B -> C) 中继远程媒体流.
  3. 中继媒体流 (A ->-> C) 应在最终端点上播放.

那么对于用户B,我们应该从用户A的PeerConnection中获取远程流,并将流添加到用户C的PeerConnection中.它是如何用Java库制作的?

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?

如何从 PeerConnection A 获取远程 MediaStream 对象并将它们添加到另一个 PeerConnection C?

我也尝试过,从 PeerConnection 获取 RTPSender 和 RTPReceiver.之后,我可以访问远程站点的 MediaStreamTrack.但是我不能把这个对象放到另一个 PeerConnection 上.

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.

推荐答案

您将通常从 pc.onaddstream 获得的流送入视频元素,而不是 pc.addStream 到一个新的对等连接.

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.

WebRTC 示例有一个示例,涵盖了使用像这样的多个继电器.

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

这篇关于WebRTC 将远程流添加到 PeerConnection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆