opentok / cordova-plugin-opentok

Cordova Plugin for OpenTok - add webrtc video to your iOS or Android App
MIT License
30 stars 80 forks source link

audioLevelUpdated not working on more the 2 subscribers #159

Open Shtibel opened 5 years ago

Shtibel commented 5 years ago

bug report

Current behavior If there is 1 publisher and 1 subscriber the audioLevelUpdated event works, But when a new user subscribes to the session it stops working.

Steps to reproduce Create a session publish a video and audio from a device. Then subscribe to the session from a second device with: insertMode: 'append'. Start the audioLevelUpdated event and listen to the publisher and console.log it, see that the event is working 60 times a second with: insertMode: 'append'. Then subscribe to the session from a third device, see that the console.log stops working on second device and it is not working on third device with: insertMode: 'append',

Example Project We tested it with the: opentok-ionic-samples

What is the current bug behavior? The audioLevelUpdated event stops working, no errors just stops working.

What is the expected correct behavior? audioLevelUpdated event must continue working even if there is more than one subscriber.

Relevant logs and/or screenshots See attached screenshot of the console.log imgpsh_fullsize_anim

Hi @msach22, We have a major problem with audioLevelUpdated. On 1 on 1 session with 1 publisher and 1 subscriber the audioLevelUpdated event is working. But when a new user joins the session the audioLevelUpdated stops working. As we see on this issue: 140 You fixed the problem but now when we test it it is not working.

We try to work with the 3.4.2 version and the 3.4.3 version and it is not working. We tested it with the opentok-ionic-samples code and it is not working.

Please can you test to see what is the problem? Thank you!

msach22 commented 5 years ago

@Shtibel Thanks for filing the issue. Can you please share which platform this is happening for? iOS, Android, or both?

msach22 commented 5 years ago

@Shtibel Just following up on this. Can you please share the code that you're using when setting these event listeners? Are you overriding the subscriber or do you have a collection of subscribers with these event listeners set?

Shtibel commented 5 years ago

Hi @msach22 It happens on both

vikaskonsam commented 4 years ago

Yes, there is an issue. I have tested this on iOS and this is what I think the problem is. When there are more the 1 subscribers, the audioLevelUpdated handler for the last connected subscriber is always called even though the audio is coming from the first connected subscriber.

this.subscriber.off('audioLevelUpdated').on('audioLevelUpdated', (event) => {
            if (movingAvg === null || movingAvg <= event.audioLevel) {
              movingAvg = event.audioLevel;
            } else {
              movingAvg = 0.7 * movingAvg + 0.3 * event.audioLevel;
            }
            // 1.5 scaling to map the -30 - 0 dBm range to [0,1]
            let logLevel = (Math.log(movingAvg) / Math.LN10) / 1.5 + 1;
            logLevel = Math.min(Math.max(logLevel, 0), 1);
            if (logLevel > 0.1) {
              console.log(event)
              this.speaking.emit(this.streamIndex);
            } else {
            }
});

When checking the logs, we see the stream details of the last connected subscriber.