webapis-rtc-peer-connection.js 1.0 KB

12345678910111213141516171819202122232425
  1. 'use strict';
  2. /**
  3. * @license Angular v<unknown>
  4. * (c) 2010-2025 Google LLC. https://angular.io/
  5. * License: MIT
  6. */
  7. function patchRtcPeerConnection(Zone) {
  8. Zone.__load_patch('RTCPeerConnection', (global, Zone, api) => {
  9. const RTCPeerConnection = global['RTCPeerConnection'];
  10. if (!RTCPeerConnection) {
  11. return;
  12. }
  13. const addSymbol = api.symbol('addEventListener');
  14. const removeSymbol = api.symbol('removeEventListener');
  15. RTCPeerConnection.prototype.addEventListener = RTCPeerConnection.prototype[addSymbol];
  16. RTCPeerConnection.prototype.removeEventListener = RTCPeerConnection.prototype[removeSymbol];
  17. // RTCPeerConnection extends EventTarget, so we must clear the symbol
  18. // to allow patch RTCPeerConnection.prototype.addEventListener again
  19. RTCPeerConnection.prototype[addSymbol] = null;
  20. RTCPeerConnection.prototype[removeSymbol] = null;
  21. api.patchEventTarget(global, api, [RTCPeerConnection.prototype], { useG: false });
  22. });
  23. }
  24. patchRtcPeerConnection(Zone);