title: Sending a MediaStream to host Server with WebRTC after it is captured by getUserMedia
body: <p>I am capturing audio data using <code>getUserMedia()</code> and I want to send it to my server so I can save it as a Blob in a MySQL field.</p>
  
  <p>This is all I am trying to do. I have made several attempts to do this using WebRTC, but I don't even know at this point if this is right or even the best way to do this.</p>
  
  <p>Can <em>anybody</em> help me?</p>
  
  <p>Here is the code I am using to capture audio from the microphone:</p>
  
  <pre><code>navigator.getUserMedia({
      video:false,
      audio:true,
  },function(mediaStream){
  
      // output mediaStream to speakers:
      var mediaStreamSource=audioContext.createMediaStreamSource(mediaStream);
      mediaStreamSource.connect(audioContext.destintion);
  
      // send mediaStream to server:
  
      // WebRTC code? not sure about this...
      var RTCconfig={};
      var conn=new RTCPeerConnection(RTCconfig);
  
      // ???
  
  },function(error){
      console.log('getUserMedia() fail.');
      console.log(error);
  });
  </code></pre>
  
  <p>How can I send this <code>mediaStream</code> up to the server?</p>
  
  <p>After Googling around I've been looking into <code>WebRTC</code>, <em>but this seems to be for just peer to peer communication</em> - actually, now I'm looking into this more, I think this is the way to go. It seems to be the way to communicate from the client's browser up to the host webserver, but nothing I try even comes close to working.</p>
  
  <p>I've been going through <a href="http://www.w3.org/TR/webrtc/" rel="noreferrer">the W3C documentation</a> (which I am finding way too abstract), and I've been going thru <a href="http://www.html5rocks.com/en/tutorials/webrtc/basics/" rel="noreferrer">this article on HTML5 Rocks</a> (which is bringing up more questions than answers). Apparently I need a signalling method, can anyone advise which signalling method is best for sending mediaStreams, XHR, XMPP, SIP, Socket.io or something else?</p>
  
  <p>What will I need on the server to support the receiving of WebRTC? My web server is running a basic LAMP stack.</p>
  
  <p>Also, is it best to wait until the <code>mediaStream</code> is finished recording before I send it up to the server, or is it better to send the <code>mediaStream</code> as its being recorded? I want to know if I am going about doing this the right way. I have written file uploaders in javascript and HTML5, but uploading one of these <code>mediaStreams</code> seems hellishly more complicated and I'm not sure if I am approaching it right.</p>
  
  <p>Any help on this would be greatly appreciated.</p>