From ddb5475dae592ca0abf6026672716d57cecf10ad Mon Sep 17 00:00:00 2001 From: mekya Date: Sun, 27 Aug 2023 16:04:18 +0300 Subject: [PATCH 1/6] Fix audio/video track adding --- src/main/webapp/js/media_manager.js | 25 +++++++++++++++-------- src/test/js/test/webrtc_adaptor.test.js | 27 ++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/main/webapp/js/media_manager.js b/src/main/webapp/js/media_manager.js index 6d202777..2da338f9 100644 --- a/src/main/webapp/js/media_manager.js +++ b/src/main/webapp/js/media_manager.js @@ -928,11 +928,15 @@ export class MediaManager { updateLocalAudioStream(stream, onEndedCallback) { var newAudioTrack = stream.getAudioTracks()[0]; - if (this.localStream != null && this.localStream.getAudioTracks()[0] != null) { + if (this.localStream != null && this.localStream.getAudioTracks()[0] != null) + { var audioTrack = this.localStream.getAudioTracks()[0]; - this.localStream.removeTrack(audioTrack); - audioTrack.stop(); - this.localStream.addTrack(newAudioTrack); + if (audioTrack != newAudioTrack) + { + this.localStream.removeTrack(audioTrack); + audioTrack.stop(); + this.localStream.addTrack(newAudioTrack); + } } else if (this.localStream != null) { this.localStream.addTrack(newAudioTrack); } else { @@ -972,11 +976,16 @@ export class MediaManager { var newVideoTrack = stream.getVideoTracks()[0]; - if (this.localStream != null && this.localStream.getVideoTracks()[0] != null) { + if (this.localStream != null && this.localStream.getVideoTracks()[0] != null ) + { var videoTrack = this.localStream.getVideoTracks()[0]; - this.localStream.removeTrack(videoTrack); - videoTrack.stop(); - this.localStream.addTrack(newVideoTrack); + + if (videoTrack != newVideoTrack) + { + this.localStream.removeTrack(videoTrack); + videoTrack.stop(); + this.localStream.addTrack(newVideoTrack); + } } else if (this.localStream != null) { this.localStream.addTrack(newVideoTrack); } else { diff --git a/src/test/js/test/webrtc_adaptor.test.js b/src/test/js/test/webrtc_adaptor.test.js index d63dd69b..83346c70 100644 --- a/src/test/js/test/webrtc_adaptor.test.js +++ b/src/test/js/test/webrtc_adaptor.test.js @@ -398,11 +398,36 @@ describe("WebRTCAdaptor", function() { stream.addTrack(audioTrack); await adaptor.updateAudioTrack(stream, null, null); + }); + + it.only("testSoundMeter", function(done) { + + + var adaptor = new WebRTCAdaptor({ + websocketURL: "ws://localhost", + mediaConstraints: { + video: true, + audio: true + }, + initializeComponents: false + }); + adaptor.initialize().then(() => { + audioLevelCalled = false; + audioLevel = 0; + adaptor.enableAudioLevelForLocalStream((level) => { + console.log(level); + if (level > 0) { + done(); + } + }); + + expect(adaptor.mediaManager.localStreamSoundMeter).to.not.be.null; + }) - }); + }) }); From bc1d10c55529e3f8d6ab6c8d68757759506491cf Mon Sep 17 00:00:00 2001 From: mekya Date: Sun, 27 Aug 2023 16:20:58 +0300 Subject: [PATCH 2/6] Update version to 2.6.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2d8c073c..46d8280d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ io.antmedia parent - 2.7.0-SNAPSHOT + 2.6.4 4.0.0 io.antmedia.webrtc From 03ac331998df84cb1cc5ed47a1a98027ee326ee1 Mon Sep 17 00:00:00 2001 From: mekya Date: Sun, 27 Aug 2023 19:52:43 +0300 Subject: [PATCH 3/6] Remove it.only for testSoundMeter --- src/test/js/test/webrtc_adaptor.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/js/test/webrtc_adaptor.test.js b/src/test/js/test/webrtc_adaptor.test.js index 83346c70..a48f44b0 100644 --- a/src/test/js/test/webrtc_adaptor.test.js +++ b/src/test/js/test/webrtc_adaptor.test.js @@ -400,7 +400,7 @@ describe("WebRTCAdaptor", function() { await adaptor.updateAudioTrack(stream, null, null); }); - it.only("testSoundMeter", function(done) { + it("testSoundMeter", function(done) { var adaptor = new WebRTCAdaptor({ From ec08258722a28c5be1a28f93b98ee53036090c59 Mon Sep 17 00:00:00 2001 From: mekya Date: Sun, 27 Aug 2023 20:00:45 +0300 Subject: [PATCH 4/6] Fix test case --- src/test/js/test/webrtc_adaptor.test.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/js/test/webrtc_adaptor.test.js b/src/test/js/test/webrtc_adaptor.test.js index a48f44b0..46efc7a7 100644 --- a/src/test/js/test/webrtc_adaptor.test.js +++ b/src/test/js/test/webrtc_adaptor.test.js @@ -400,8 +400,8 @@ describe("WebRTCAdaptor", function() { await adaptor.updateAudioTrack(stream, null, null); }); - it("testSoundMeter", function(done) { - + it.only("testSoundMeter", function(done) { + this.timeout(5000); var adaptor = new WebRTCAdaptor({ websocketURL: "ws://localhost", @@ -413,8 +413,7 @@ describe("WebRTCAdaptor", function() { }); adaptor.initialize().then(() => { - audioLevelCalled = false; - audioLevel = 0; + adaptor.enableAudioLevelForLocalStream((level) => { console.log(level); if (level > 0) { From ab9e63a9b9fb39d91e7563860d605613ff21b369 Mon Sep 17 00:00:00 2001 From: mekya Date: Sun, 27 Aug 2023 20:01:20 +0300 Subject: [PATCH 5/6] Remove it.only for testSoundMeter --- src/test/js/test/webrtc_adaptor.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/js/test/webrtc_adaptor.test.js b/src/test/js/test/webrtc_adaptor.test.js index 46efc7a7..9dc8800a 100644 --- a/src/test/js/test/webrtc_adaptor.test.js +++ b/src/test/js/test/webrtc_adaptor.test.js @@ -400,7 +400,7 @@ describe("WebRTCAdaptor", function() { await adaptor.updateAudioTrack(stream, null, null); }); - it.only("testSoundMeter", function(done) { + it("testSoundMeter", function(done) { this.timeout(5000); var adaptor = new WebRTCAdaptor({ From 7d2b5dd5290b488eb84fe099d1beb3f29bb73404 Mon Sep 17 00:00:00 2001 From: mekya Date: Sun, 27 Aug 2023 21:15:23 +0300 Subject: [PATCH 6/6] Update version to 2.7.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 46d8280d..2d8c073c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ io.antmedia parent - 2.6.4 + 2.7.0-SNAPSHOT 4.0.0 io.antmedia.webrtc