Streaming voice over UDP

I want to transfer voice via sockets using UDP protocol.

I capture voice with DirectSound to SecondaryBuffer.
Because UdpClient doesn't have streams, I can't stream this buffer.

what can I do How to send voice



Answer this question

Streaming voice over UDP

  • onderkoksal

    If you want to build a VoIP softphone then a better choice would be to use sipXtapi's .NET wrapper (search on sourceforge.net). If you are trying to do something else then please ignore this message..

  • Andy Pham

    UDP is a connection-less protocol that doesn't correct transmission errors like TCP does. That makes it very fast but unreliable, greatly depending on the quality of the Internet connection. Most typically, if there are problems with the routers, they'll drop packets. Datagrams may also take different routes through the network and you may receive them out-of-order.

    You need a way to detect this so you don't playback completely garbled data. You can correct for out-of-order reception to some extent by buffering the received data, trying to patch the holes left by late packets. This of course causes latency on the transmission, it depends how much latency you can allow before it gets noticeable. IP-phones can't have much, streaming audio can have a lot. Handling lost packets without destroying the audio data completely or causing loud 'pops' at the receiving end should concern you too...


  • Nilesh Ingale

    nobugz,

    Thanks for the answer.
    Can you please re-explain:
     nobugz wrote:

    You'll need to add a header to the byte[] so you can detect UDP datagrams getting dropped or getting received out of order. A simple block counter should do the trick.


    P.S.
    My captured voice data is already stored in  byte[] so this is helpful for sending.

  • Leaf.

    So what you are telling me is that for every packet I send, I should add a header that contains packet's order
    And as you said, because this is for voip I can't allow latency.

    And what are chances for problems with the transfer anyway
    Maybe all detections don't worth it In voip I need to play all incoming data and can't skip any data even if it's "garbled".

    What can you suggest for this




  • RajLakamana

    Yes, I want to do something else. Thanks anyway.

  • mrayyan

    any ideas

  • connect2sandeep

    Just split up the data in SecondaryBuffer into chunks of byte[] suitable for sending with UdpClient.Send(). Put your buffer together again at the receiving end to play it back. You'll need to add a header to the byte[] so you can detect UDP datagrams getting dropped or getting received out of order. A simple block counter should do the trick. Test your code, and the effect it has on playback quality, by randomly dropping datagrams.


  • Streaming voice over UDP