title: How to send and receive desktop capture stream generated via getUsermedia()
body: <p>I am making a Screen sharing app with WebRTC + Socket.io and stuck at a place.
  Connected with two browser using WebRTC + Socket.io and <strong>can send text</strong> </p>
  
  <p>I am taking support from <a href="https://codelabs.developers.google.com/codelabs/webrtc-web/#8" rel="nofollow noreferrer">codelab</a> but it is not for stream.(If solution is based on this link then highly helpful)</p>
  
  <p>How can I send getUserMedia() stream:</p>
  
  <pre><code>dataChannel.send(stream);
  </code></pre>
  
  <p>And receive same stream on channel.onmessage():
  I am getting event.data as '[object MediaStream]' not stream.</p>
  
  <pre><code>channel.onmessage = function(event){
    // unable to get correct stream
    // event.data is "[object MediaStream]"  in string
  }
  
  function createPeerConnection(isInitiator, config) {
      console.log('Creating Peer connection as initiator?', isInitiator, 'config:', config);
      peerConn = new RTCPeerConnection(config);
  
      // send any ice candidates to the other peer
      peerConn.onicecandidate = function (event) {
          console.log('onIceCandidate event:', event);
          if (event.candidate) {
              sendMessage({
                  type: 'candidate',
                  label: event.candidate.sdpMLineIndex,
                  id: event.candidate.sdpMid,
                  candidate: event.candidate.candidate
              });
          } else {
              console.log('End of candidates.');
          }
      };
  
      if (isInitiator) {
          console.log('Creating Data Channel');
          dataChannel = peerConn.createDataChannel("screen");
          onDataChannelCreated(dataChannel);
  
          console.log('Creating an offer');
          peerConn.createOffer(onLocalSessionCreated, logError);
      } else {
          peerConn.ondatachannel = function (event) {
              console.log('ondatachannel:', event.channel);
              dataChannel = event.channel;
              onDataChannelCreated(dataChannel);
          };
      }
  }
  </code></pre>
  
  <p><strong><em>It is working fine for string or json i.e. dataChannel.send('Hello');</em></strong></p>
  
  <p>I have created a wiki page for same: <a href="https://github.com/muaz-khan/WebRTC-Experiment/wiki/Unable-to-receive-correctly-desktop-capture-stream-that-got-by-getUserMedia-but-working-fine-for-string" rel="nofollow noreferrer">wiki</a></p>
  
  <p>Please help.</p>