1 year ago

#256479

test-img

cafer yıldız

How to track the person talking webrtc in android?

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?

detection

peer

speaker

webrtc-android

0 Answers

Your Answer

Accepted video resources