I'm creating an Electron app, and I want to intentially add a delay to the outgoing audio (Up to 10 seconds) in a webrtc call to simulate audio lagg.
I have tried using playoutDelayHint with WebRTC but it's very inconsistent. I want to be able to control the time delay very precisely.
audioReceiver.playoutDelayHint = 1;
audioReceiver.jitterBufferDelayHint = 1;
I have also tried using the AudioDelay node but it's not working, no delay at all.
let audioContext = new AudioContext();
let audioSource = audioContext.createMediaStreamSource(canvasStream);
let audioDestination = audioContext.createMediaStreamDestination();
let delay = audioContext.createDelay(3)
delay.connect(audioContext.destination);
Are there any other options or ways to make the options above work?
My solution was to apply the audio delay to the incoming stream. Not optimal but it works.
var audioContext = new AudioContext();
var source = audioContext.createMediaStreamSource(stream);
let audioDelay = audioContext.createDelay(10); // 10 seconds max delay
audioDelay.delayTime.value = 3 // Seconds delay
source.connect(audioDelay).connect(audioContext.destination)