VoIP RTP Streaming from/to server (in Java) to/from android -


my target have push-to-talk chat app in gsm/umts/lte networks; wanted use multicast addresses , peer-to-peer without overload server; unfortunatly, after deep investigation, discovered multicast not allowed in gsm/umts/lte networks, therefore have use server in order bounce voip packets. i' don't solution because have overload server, didn't find better solution. if have alternative solution apprieciated...

therefore have send voip android client server (pc), , viceversa. server in java, has receive voip packets , send voip packets other n clients; server bouncer of voip packets.

i developped code, doesn't work; don't have error, had bad voip service: loose lot of pieces , hear noised... error? suppose should in server code; server packet , resend them, without know voip on rtp.

please find below

  • the code use send voip packets server. works because don't have problems when use individual call sending voip packets directly android android; code receive in android packets server similar, don't recopy it. can see use android.net.rtp .
  • the code use on java server bounce voip packets

thank in advance, fausto

// android code used send voip server

//attribute definition private static final audiocodec myaudiocodec_costante = audiocodec.pcmu ;  private static final int myaudiogrouptx_costante = audiogroup.mode_normal ;  private static final int myaudiogrouprx_costante = audiogroup.mode_normal ; private static final int myrtpstreamtx_costante = rtpstream.mode_send_only ; private static final int myrtpstreamrx_costante = rtpstream.mode_receive_only ;  private static final int myaudiomanagertx_costante = audiomanager.mode_in_communication; private static final int myaudiomanagerrx_costante = audiomanager.mode_in_communication;   //method called voip trasmission myaudiostream = new audiostream(localclientip); myaudiogroup = new audiogroup(); myaudiomanager =  (audiomanager) mycontext.getsystemservice(context.audio_service);  myaudiogroup.setmode(myaudiogrouptx_costante); myaudiostream.join(null);  myaudiostream.setcodec(myaudiocodec_costante); myaudiostream.setmode(myrtpstreamtx_costante); myaudiostream.associate(ipaddress_server, port_server)     myaudiostream.join(myaudiogroup);  myaudiomanager.setmode(myaudiomanagertx_costante); myaudiomanager.setspeakerphoneon(false); myaudiomanager.setmicrophonemute(false); 

//java server code used receive voip android , resend server

datagramsocket datagramsocket_rx_voip= new datagramsocket(); datagramsocket datagramsocket_tx_voip= new datagramsocket(); int unicast_port_tx_voip = 5000 ; string unicast_ip_tx_voip = "192.168.0.3";      thread t = new thread(new runnable() {     public void run() {     try {         datagrampacket mypacket;         while (true) {             mypacket = managepacket.initializepacket(); //function prepare packe ; problem not here!!!             datagramsocket_rx_voip.receive(mypacket);              inetaddress ppp =  inetaddress.getbyname(unicast_ip_tx_voip);             mypacket.setaddress(ppp);             mypacket.setport( unicast_port_tx_voip ) ;             datagramsocket_tx_voip.send(mypacket);         }      }  catch (exception ex) {         log.debug("exception: " + ex.getmessage(), ex);     }     }     });     t.start();                                         

you don't give enough detail application. udp streaming application need address following issues:

  • network jitter , buffering: when packet arrives, cannot play audio after receive because next packet might later expected , have gap in audio playback. variance in arrival rate called network jitter. need buffer amount of data before try play back. use sort of ring buffer.

  • packet loss: there packet losses udp. need "deal" this. if send 10 packets , packet #4 missing, can't play packet #3 packet #5. sound bad. ways deal this:

    • loss concealment: try minimize bad effect off packet lost. can play silence (although doesn't sound best unless fade silence). can "estimate" lost audio generating missing audio examining surrounding packets.
    • forward error correction: send packets more once. there numerous ways , schemes. tradeoff higher latency , more network utilization
  • out of order arrivals: packets may arrive out of order. use rtp sequence numbers deal this.

audio streaming not trivial task. can't open socket, send data, , play on other end , expect work. biggest concern udp streaming network jitter , packet loss. if don't want deal losses , can have latency, use tcp sure buffer enough audio before start playing.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -