Giter Club home page Giter Club logo

webrtc-screen-share's Introduction

webrtc-screen-share

Test page for screen share feature, using WebRTC and node.js web socket transport. A very quick way for you to see how screen capture and share works using webrtc. This demo supports both Chrome and Firefox.

  • Uses node.js and websocket.
  • Only works using Google Chrome, Firefox.
  • Chrome can do screen share only in this demo. (must start Chrome on command line using --enable-usermedia-screen-capturing)
  • Firefox can do both screen share and window share.
  • No need for a Web Server, uses node.js as your server.
  • Tab capture or application share not supported in this demo.
  • Supports Secure HTTP and secure websocket wss.

screen capture uses getUserMedia API

  if (isChrome) {   
    constraints = { 
      video: {
        mandatory: {
          chromeMediaSource: 'screen',
          maxWidth: screen.width,
          maxHeight: screen.height,
          minFrameRate: 1,
          maxFrameRate: 5
        },  
        optional: []
    }}; 
  } else {
    constraints = { 
      video: {
        mediaSource: "screen"
      }   
    };  
  }

  function startMedia() {
    navigator.mediaDevices.getUserMedia(constraints, onstream, onerror);
  }

Setup prerequesites

  • Install Node.js and WebSocket(sudo npm install websocket)

Server Steps (Works on Linux and MacOS so far)

  • Clone this repo to your machine, does which not need to be to a web server.
  • Generate keys unless you have real ones, run these commands in the same folder as app.js.
    • openssl genrsa -out webrtcwwsocket-key.pem 1024
    • openssl req -new -key webrtcwwsocket-key.pem -out webrtcwwsocket-csr.pem
    • openssl x509 -req -in webrtcwwsocket-csr.pem -signkey webrtcwwsocket-key.pem -out webrtcwwsocket-cert.pem
  • Run 'sudo node app.js'
  • You may get errors, if you do then reinstall WebSocket in that folder, e.g. 'sudo npm install websocket'

Client Steps

  • (Only for Chrome) start chrome browser with flag --enable-usermedia-screen-capturing
  • (Only for Firefox) open about:config create media.getusermedia.screensharing.enabled and set to true
  • (Only for Firefox) open about:config in media.getusermedia.screensharing.allowed_domains append the IP address of your node server e.g. "192.168.1.2"
  • Point two browsers to, e.g. https://<your ip address>
    • Or point two tabs on same browser to, e.g. https://<your ip address>
    • To start two instances of Firefox on the same machine run: firefox --profilemanager
  • Accept any local unsecure certificate dialogues that appear on either browser.
  • Start media and share.

NOTE: Google intend on using Chrome extensions for desktop share for security reasons. The way of doing share using Chrome in this demo is for testing purposes only, that is why it is behind a flag. See this demo of share in an extension: https://github.com/emannion/webrtc-application-screen-share

NOTE: Firefox also recommends using an extension for screenshare, the advantage being not requiring the two config items mentioned in the client steps above.

webrtc-screen-share's People

Contributors

viviemxd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webrtc-screen-share's Issues

Unable to run the app on Firefox

Hello There,
I followed the instructions for chrome but still unable to run the app on Firefox. It says "screen capturing is either denied or not supported". How can I troubleshoot this? also my node server is accepts the connection. But I get following errors:

  1. "e no defined" error.

  2. The operation is insecure.
    I am waiting for the reply.

Do not work on multi stream mode

Hello,

This code is good as a start point for the conference screen sharing. I like the command line parameters method which is not depend on plugin.
Is it still maintained? I notice the code is submitted 2 years ago. Has it been tested on recent environment?
I got it merely works on 2 clients. After modify the index.html code, it gets better experience.
I.E. in line 367, modify
pc.addStream(localStream);
to
if(localStream)
pc.addStream(localStream);

But the screen can not share to more than 1 other client.
The receivers' log like:

Received offer...
(index):402 Creating peer connection
(index):460 Adding local stream...
(index):370 Creating remote session description...
(index):375 Sending answer...
(index):469 Added remote stream
(index):313 Sending: SDP
(index):314 RTCSessionDescription {type: "answer", sdp: "v=0
↵o=- 4063776319108917199 2 IN IP4 127.0.0.1
↵s…90000
↵a=rtpmap:96 rtx/90000
↵a=fmtp:96 apt=100
↵"}
(index):382 Received answer...
(index):383 Setting remote session description...
(index):389 Received ICE candidate...
(index):392 RTCIceCandidate {candidate: "candidate:3350409123 1 udp 2113937151 192.168.0.10… typ host generation 0 ufrag fqZc network-cost 50", sdpMid: "video", sdpMLineIndex: 0}
(index):389 Received ICE candidate...
(index):392 RTCIceCandidate {candidate: "candidate:1878309491 1 udp 2122260223 192.168.122.…3935 typ host generation 0 ufrag i04bDKdFdinlpKMW", sdpMid: "video", sdpMLineIndex: 0}
(index):448 Sending ICE candidate...
(index):449 RTCIceCandidate {candidate: "candidate:2131708102 1 udp 2113937151 192.168.0.10… typ host generation 0 ufrag vZ9e network-cost 50", sdpMid: "video", sdpMLineIndex: 0}
(index):1 Uncaught (in promise) DOMException: Failed to set remote answer sdp: Called in wrong state: STATE_INPROGRESS
Promise (async)
onWebSocketMessage @ (index):386
(index):457 End of candidates.
(index):389 Received ICE candidate...
(index):392 RTCIceCandidate {candidate: "candidate:1878309491 2 udp 2122260222 192.168.122.…3936 typ host generation 0 ufrag i04bDKdFdinlpKMW", sdpMid: "video", sdpMLineIndex: 0}
(index):389 Received ICE candidate...
(index):392 RTCIceCandidate {candidate: "candidate:561464963 1 tcp 1518280447 192.168.122.6…cptype active generation 0 ufrag i04bDKdFdinlpKMW", sdpMid: "video", sdpMLineIndex: 0}

And the server console displays:

Mon Jan 08 2018 14:58:26 GMT+0800 (CST) Received Message {"messageType":"iceCandidate","candidate":{"candidate":"candidate:1878309491 1 udp 2122260223 192.168.122.6 3935 typ host generation 0 ufrag i04bDKdFdinlpKMW","sdpMid":"video","sdpMLineIndex":0}}
send() error: Error: This socket has been ended by the other party
send() error: Error: This socket has been ended by the other party
send() error: Error: This socket has been ended by the other party

The sender looks OK. But nothing received on the clients side. Is there any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.