Screen Sharing

I am newbie and sorry if this question sounds dumb. In this web app that i am working, we are using mediasoup for screen sharing. The following are the doubts, don’t know how to implement this.

1.) User should only be able to share the current screen, from which the service has started.

2.) Also want to share only a part of the screen. This screen is divided into 2 parts :- video section and chat section. Do not want viewers to watch the chat section of the person who is sharing the screen.

Both requirements are not related to mediasoup library. it need to implement on client side application. no role of mediasoup.

1.) User should only be able to share the current screen, from which the service has started.
→ User browser’s screen sharing API. it returns audio/video stream of selected window or tab.
Documentation: Using the Screen Capture API - Web APIs | MDN
You can not force user to select any particular window or tab but you can validate which tab or window shared by user after getting stream. here you can validate if user shared current window/tab and then pass stream to mediasoup transporter.

2.) Also want to share only a part of the screen. This screen is divided into 2 parts :- video section and chat section. Do not want viewers to watch the chat section of the person who is sharing the screen.

→ One simple method is before passing stream to mediasoup , modify the stream by adding it into canvas element (Set start and end point coordinates of area which you want to share) In this case you should know the with and height of area.
Second one , if you just want to share video on current webpage then directly stream into mediasoup. no need of screensharing…

1 Like