mkd156
mkd156

Reputation: 435

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.

Upvotes: 8

Views: 19401

Answers (3)

Gábor Imre
Gábor Imre

Reputation: 6299

Take a look at this Chrome Extension, it has implemented desktop sharing and it's pretty good. https://www.webrtc-experiment.com/Pluginfree-Screen-Sharing/

Upvotes: -1

Sam Dutton
Sam Dutton

Reputation: 15269

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.

Upvotes: 9

tomtheengineer
tomtheengineer

Reputation: 4277

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.

Upvotes: 7

Related Questions