Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Enable audio denoise for OWT using a Wasm port of RNNoise Library #399

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion scripts/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function(grunt) {
const sdkOutput = 'dist/sdk/owt.js';

var srcFiles = [
'src/sdk/base/**',
'src/sdk/base/*.js',
'src/sdk/p2p/**',
'src/sdk/conference/**'
];
Expand Down Expand Up @@ -175,6 +175,8 @@ window.L = L;\n\
copy:{
dist:{
files:[
{expand: true,cwd:'src/sdk/base/',src:['*.wasm'],dest:'dist/samples/p2p/js',flatten:false},
{expand: true,cwd:'src/sdk/base/',src:['*.wasm'],dest:'dist/sdk/',flatten:false},
{expand: true,cwd:'src/samples/p2p/',src:['**'],dest:'dist/samples/p2p/',flatten:false},
{expand: true,cwd:'src/samples/conference/',src:['**'],dest:'dist/samples/conference/',flatten:false},
{expand: true,cwd:'src/samples/conference/',src:['initcert.js'],dest:'dist/samples/conference/',flatten:false,mode:true},
Expand Down
61 changes: 44 additions & 17 deletions src/samples/p2p/js/peercall.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const getTargetId = function() {
return $('#remote-uid').val();
};

function denoiseCheckboxChanged() {
document.getElementById("denoise-message").innerHTML=": Click 'Stop Camera' and 'share camera' if video sharing is already in progress."
}

$(document).ready(function() {
$('#set-remote-uid').click(function() {
p2p.allowedRemoteIds = [getTargetId()];
Expand Down Expand Up @@ -94,6 +98,8 @@ $(document).ready(function() {
localStream = undefined;
});

let denoiseCheckbox = document.getElementById('apply-denoise-checkbox');

$('#target-video-publish').click(function() {
$('#target-video-unpublish').prop('disabled', false);
$('#target-video-publish').prop('disabled', true);
Expand All @@ -109,23 +115,44 @@ $(document).ready(function() {
const videoConstraintsForCamera = new Owt.Base
.VideoTrackConstraints(Owt.Base.VideoSourceInfo.CAMERA);
let mediaStream;
Owt.Base.MediaStreamFactory.createMediaStream(new Owt.Base
.StreamConstraints(audioConstraintsForMic,
videoConstraintsForCamera)).then((stream) => {
mediaStream = stream;
localStream = new Owt.Base.LocalStream(mediaStream, new Owt
.Base.StreamSourceInfo('mic', 'camera'));
$('#local').children('video').get(0).srcObject = localStream
.mediaStream;
p2p.publish(getTargetId(), localStream).then(
(publication) => {
publicationForCamera = publication;
}, (error) => {
console.log('Failed to share video.');
});
}, (err) => {
console.error('Failed to create MediaStream, ' + err);
});
if(denoiseCheckbox.checked){
Owt.Base.MediaStreamFactory.createMediaStreamDenoised(new Owt.Base
.StreamConstraints(audioConstraintsForMic,
videoConstraintsForCamera)).then((stream) => {
mediaStream = stream;
localStream = new Owt.Base.LocalStream(mediaStream, new Owt
.Base.StreamSourceInfo('mic', 'camera'));
$('#local').children('video').get(0).srcObject = localStream
.mediaStream;
p2p.publish(getTargetId(), localStream).then(
(publication) => {
publicationForCamera = publication;
}, (error) => {
console.log('Failed to share video.');
});
}, (err) => {
console.error('Failed to create MediaStream, ' + err);
});
}
else {
Owt.Base.MediaStreamFactory.createMediaStream(new Owt.Base
.StreamConstraints(audioConstraintsForMic,
videoConstraintsForCamera)).then((stream) => {
mediaStream = stream;
localStream = new Owt.Base.LocalStream(mediaStream, new Owt
.Base.StreamSourceInfo('mic', 'camera'));
$('#local').children('video').get(0).srcObject = localStream
.mediaStream;
p2p.publish(getTargetId(), localStream).then(
(publication) => {
publicationForCamera = publication;
}, (error) => {
console.log('Failed to share video.');
});
}, (err) => {
console.error('Failed to create MediaStream, ' + err);
});
}
}
});

Expand Down
6 changes: 6 additions & 0 deletions src/samples/p2p/peercall.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ <h2>P2P Sample</h2>
<input id="remote-uid" type="text" />
<button id="set-remote-uid">Set Remote ID</button>
</p>
<p>
<input id="apply-denoise-checkbox" type="checkbox" onclick="denoiseCheckboxChanged()">
<label for="apply-denoise-checkbox"> Enable noise reduction</label>
<mark><label id="denoise-message"> </label></mark>
</p>

<p>
<button id="target-video-publish">Share Camera</button>
<button id="target-video-unpublish">Stop Camera Sharing</button>
Expand Down
Loading