I'm using puppeteer-stream to get a stream of a browser controlled by Node, running on a server. I am able to write this stream out to a file with no issues.
I wanted to stream this stream via WebRTC to a browser (basically to see what the browser is running in realtime). For webrtc, I'm trying to use simple-peer since it has ready bindings for Node as well as the browser-side.
However, when I try to pass this stream to simple-peer, I get the following error:
/Users/my_user/my_project/node_modules/simple-peer/index.js:286
stream.getTracks().forEach(track => {
^
TypeError: stream.getTracks is not a function
at Peer.addStream (/Users/my_user/my_project/node_modules/simple-peer/index.js:286:12)
This is because the Stream I have is a ReadableStream, but simple-peer (or most webrtc libs) expects a MediaStream.
How can I convert a realtime ReadableStream into a MediaStream that can be used with WebRTC? I found examples to convert MediaStreams into ReadableStreams such as here but not vice versa.
Am I missing something here?