Browse Source

e2ee: generate silence in case of audio decryption errors

This handles decryption errors for audio differently than the
current version. Instead of forwarding horrible noise to the decoder,
replace the bytes with magic opus bytes for silence:
  0xd8fffe

Those bytes were captured on a modified version of
  https://webrtc.github.io/samples/src/content/peerconnection/endtoend-encryption/
with more dumping and after disabling the track.
master
Philipp Hancke 5 years ago
parent
commit
6502bc6782
1 changed files with 7 additions and 0 deletions
  1. 7
    0
      modules/e2ee/E2EEContext.js

+ 7
- 0
modules/e2ee/E2EEContext.js View File

314
                 return controller.enqueue(encodedFrame);
314
                 return controller.enqueue(encodedFrame);
315
             }, e => {
315
             }, e => {
316
                 logger.error(e);
316
                 logger.error(e);
317
+                if (encodedFrameType === undefined) { // audio, replace with silence.
318
+                    const newData = new ArrayBuffer(3);
319
+                    const newUint8 = new Uint8Array(newData);
320
+
321
+                    newUint8.set([ 0xd8, 0xff, 0xfe ]); // opus silence frame.
322
+                    encodedFrame.data = newData;
323
+                }
317
 
324
 
318
                 // Just feed the (potentially encrypted) frame in case of error.
325
                 // Just feed the (potentially encrypted) frame in case of error.
319
                 // Worst case it is garbage.
326
                 // Worst case it is garbage.

Loading…
Cancel
Save