如何在android中跟踪正在谈论webrtc的人?

发布于 2025-01-11 20:00:15 字数 1698 浏览 1 评论 0原文

我的问题是这样的。 我想跟踪其他人在 webrtc 上谈论的时间。

例如: PeerA、PeerB 和 PeerC 在一间房间内。 当peerA开始说话时,我想对PeerB和PeerC中的UI进行任何更改(例如,更改PeerA的边框颜色)。

我可以在 js 中执行此操作,如下所示。

this.interval = setInterval(() => {
 const peers = [...this.state.peers];
 this.state.peers.forEach(p => {
   const receiver = p.peerConnection
     .getReceivers()
     .find(r => r.track.kind === 'audio');
   if (!p.levels || !p.levels.length) {
     p.levels = [];
   }

   if (receiver && receiver.getSynchronizationSources) {
     const source = receiver.getSynchronizationSources()[0];
     if (source) {
       console.log(source.audioLevel);
       p.levels.push(source.audioLevel);
     }
     if (p.levels.length > 5) {
       p.levels.shift();
     } 
   }

   const sum = p.levels.reduce((prev, curr) => curr + prev, 0);
   p.isSpeaking = SPEAK_THRESHOLD < sum / 5;
 });

在 Android PeerConnection 对象中包括 私有列表接收器; 和 RtpReceiver 包括

 public class RtpReceiver {
 private long nativeRtpReceiver;
 private long nativeObserver;
 @Nullable
 private MediaStreamTrack cachedTrack;
         .
         .
         .

我在 RtpReceiverMediaStreamTrack。 我怎样才能获得 getSynchronizationSources 或者有其他方法可以满足这种需求?

如果没有办法直接通过RtpReceiver接收。做到这一点的最佳方法是什么?

My problem is this.
I want to keep track of the time other people are talking on webrtc.

For example:
PeerA, PeerB and PeerC is in one room.
When peerA starts talking, I want to make any changes to the UI in PeerB and PeerC (for example, change border color of PeerA).

I can do this in js as follows.

this.interval = setInterval(() => {
 const peers = [...this.state.peers];
 this.state.peers.forEach(p => {
   const receiver = p.peerConnection
     .getReceivers()
     .find(r => r.track.kind === 'audio');
   if (!p.levels || !p.levels.length) {
     p.levels = [];
   }

   if (receiver && receiver.getSynchronizationSources) {
     const source = receiver.getSynchronizationSources()[0];
     if (source) {
       console.log(source.audioLevel);
       p.levels.push(source.audioLevel);
     }
     if (p.levels.length > 5) {
       p.levels.shift();
     } 
   }

   const sum = p.levels.reduce((prev, curr) => curr + prev, 0);
   p.isSpeaking = SPEAK_THRESHOLD < sum / 5;
 });

in Android PeerConnection object include
private List<RtpReceiver> receivers;
and RtpReceiver iclude

 public class RtpReceiver {
 private long nativeRtpReceiver;
 private long nativeObserver;
 @Nullable
 private MediaStreamTrack cachedTrack;
         .
         .
         .

I cant find getSynchronizationSources() on RtpReceiver or on MediaStreamTrack.
How can I get to getSynchronizationSources or is there any other way to meet this need?

If there is no way to receive directly via RtpReceiver. What is the best way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文