From 8b59a52436dee000bedbef5454f0ea99437b6000 Mon Sep 17 00:00:00 2001 From: andrei Date: Thu, 8 Feb 2024 12:05:07 +0200 Subject: [PATCH] destroy() should not unrap getUserMedia if wrapGetUserMedia was not passed initially --- src/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index a474bb3..c88c8e2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -335,8 +335,11 @@ export class WebRTCStats extends EventEmitter { localTracks = [] - // put back the original gUM native method - navigator.mediaDevices.getUserMedia = origGetUserMedia + // if we wrapped gUM initially + if (this.shouldWrapGetUserMedia && origGetUserMedia) { + // put back the original + navigator.mediaDevices.getUserMedia = origGetUserMedia + } } /**