Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accomplish screen sharing using WebRTC

I need to implement screen sharing using WebRTC. I know that WebRTC supports sharing of tab content but I need to share the whole screen. A solution I am thinking of is to frequently take screenshots and using WebRTC data channel transfer the image to other party. The other party will then update the image each time a new image is received.

Is this possible to accomplish? Particularly I am wondering if it is possible to transfer image using WebRTC data channel?

Thank you in advance.

like image 585
mkd156 Avatar asked Jul 09 '13 07:07

mkd156


People also ask

What is WebRTC desktop sharing?

WebRTC to share your screenAnd as a developer, you work with the screen's stream the same way as you work with the web camera or microphone. And use WebRTC to transmit screen sharing the same way as usual media streams.

How do I stop a screen share in WebRTC?

If you want to stop a MediaStream you should stop and close it's tracks. Thwn doing this the "Chrome bar" you mention will disapear once all tracks bound to the shared screen are stopped.


2 Answers

getUserMedia supports screensharing of the whole screen, not just the tab content.

I've done a screen capture demo (using the mandatory constraint chromeMediaSource: 'screen') which pipes the stream into an RTCPeerConnection: https://simpl.info/screencapture.

The chrome.tabCapture API gets tab content, but of course that's not what you want: example here (though the code is now broken).

EDIT: added HTTPS to links: this is required for screencapture.

like image 58
Sam Dutton Avatar answered Oct 30 '22 13:10

Sam Dutton


Screensharing is available via an experimental getUserMedia constraint in Chrome (not yet available in Firefox).

You'll need to first enable the flag called Enable screen capture support in getUserMedia() in chrome://flags.

There's a nice example of how to capture the screen here: https://html5-demos.appspot.com/static/getusermedia/screenshare.html.

like image 26
tomtheengineer Avatar answered Oct 30 '22 12:10

tomtheengineer