()
| 415 | } |
| 416 | |
| 417 | function startDiagnostics() { |
| 418 | if (!audioPlayback.srcObject) return; |
| 419 | |
| 420 | // Create AudioContext and connect the remote stream to an AnalyserNode |
| 421 | if (!audioCtx) { |
| 422 | audioCtx = new AudioContext(); |
| 423 | const source = audioCtx.createMediaStreamSource(audioPlayback.srcObject); |
| 424 | analyser = audioCtx.createAnalyser(); |
| 425 | analyser.fftSize = 8192; |
| 426 | analyser.smoothingTimeConstant = 0.3; |
| 427 | source.connect(analyser); |
| 428 | |
| 429 | document.getElementById('statSampleRate').textContent = audioCtx.sampleRate + ' Hz'; |
| 430 | } |
| 431 | |
| 432 | // Start rendering loop |
| 433 | if (!diagAnimFrame) { |
| 434 | drawDiagnostics(); |
| 435 | } |
| 436 | |
| 437 | // Start WebRTC stats polling |
| 438 | if (!statsInterval) { |
| 439 | pollWebRTCStats(); |
| 440 | statsInterval = setInterval(pollWebRTCStats, 1000); |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | function stopDiagnostics() { |
| 445 | if (diagAnimFrame) { |
no test coverage detected