Handling a WebRTC byte[] stream?
<p>I'm basically trying to record audio chunks from a webrtc stream, I've been able to send the binary data with help of this resource <a href="https://subvisual.co/blog/posts/39-tutorial-html-audio-capture-streaming-to-node-js-no-browser-extensions" rel="nofollow">HTML Audio Capture streaming to Node.js</a>.</p>

<p>Im using <a href="https://github.com/mrniko/netty-socketio" rel="nofollow">netty-socketio</a>, as this library plays well with socket-io on the client side.
Here are my server endpoints:</p>

<pre><code>server.addEventListener("audio-blob", byte[].class, (socketIOClient, bytes, ackRequest) -&gt; {
    byteArrayList.add(bytes);
});

server.addEventListener("audio-blob-end", Object.class, (socket, string, ackRequest) -&gt; {
    ByteArrayInputStream in = new ByteArrayInputStream(byteArrayList.getArray());
    AudioInputStream audiIn = new AudioInputStream(in, getAudioFormat(), 48000l);
    AudioFileFormat.Type fileType = AudioFileFormat.Type.WAVE;
    File wavFile = new File("RecordAudio.wav");
    AudioSystem.write(audiIn,fileType,wavFile);
});
</code></pre>

<p>The format settings: </p>

<pre><code>public static AudioFormat getAudioFormat() {
    float sampleRate = 48000;
    int sampleSizeInBits = 8;
    int channels = 2;
    boolean signed = true;
    boolean bigEndian = true;
    AudioFormat format = new AudioFormat(sampleRate, sampleSizeInBits,
            channels, signed, bigEndian);
    return format;
}
</code></pre>

<p>Im using this class to collect the byte arrays (and yes I know the risk with this solution) </p>

<pre><code>class ByteArrayList {
   private List&lt;Byte&gt; bytesList;

   public ByteArrayList() {
       bytesList = new ArrayList&lt;Byte&gt;();
   }

   public void add(byte[] bytes) {
       add(bytes, 0, bytes.length);
   }

   public void add(byte[] bytes, int offset, int length) {
       for (int i = offset; i &lt; (offset + length); i++) {
           bytesList.add(bytes[i]);
       }
   }

   public int size(){
       return bytesList.size();
   }

   public byte[] getArray() {
       byte[] bytes = new byte[bytesList.size()];
       for (int i = 0; i &lt; bytesList.size(); i++) {
           bytes[i] = bytesList.get(i);
       }
       return bytes;
   }
}
</code></pre>

<p>The generated wav file only plays noise though, no recording is present. What am I doing wrong?</p>