Search code examples
webrtcweb-worker

Use WebRTC with WebWorker


I am interested in to use webrtc with webworker. Is it possible?

I tried it but it did not work because it did not find the "window"


Solution

  • According to the specifications [1, 2], navigator.mediaDevices and RTCPeerConnection are not defined for web workers, so WebRTC shouldn't be available on web workers for now.

    For [1], navigator.mediaDevices attribute is defined on Navigator interface for window, but not on WorkerNavigator interface for web worker.

    For [2], RTCPeerConnection interface is exposed to window ([Exposed=Window]), but not to web worker ([Exposed=Worker]).