如何在android中跟踪正在谈论webrtc的人?
我的问题是这样的。 我想跟踪其他人在 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;
.
.
.
我在 RtpReceiver 或 MediaStreamTrack。 我怎样才能获得 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 includeprivate 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论