title: How to decode RTP packets and save it has .wav file
body: <p>I am trying to develop an application in which a sip call is established and then i am capturing rtp audio packets. As they are encoded so i need to decode them and save it has .wav file. Tried using NAudio but didnt worked. Is there any solution using NAudio or any other source to solve this problem...</p>
  
  <p>the code i used is as follow. data is the byte array in which rtp packet data is.</p>
  
  <pre><code>System.IO.MemoryStream stream = new System.IO.MemoryStream(data);
  
  RawSourceWaveStream rsws = new RawSourceWaveStream(stream, WaveFormat.CreateMuLawFormat(8000,1));
  
  WaveStream conversionStream = WaveFormatConversionStream.CreatePcmStream(rsws);
  
  WaveStream blockAlignedStream = new BlockAlignReductionStream(conversionStream);
  
  byte[] buffer = new byte[udpHeader.Data.Length];
  blockAlignedStream.Read(buffer, 0, udpHeader.Data.Length);
  writer.WriteData(buffer, 0, buffer.Length);
  </code></pre>
  
  <p>Thanks in Advance.</p>