Softphone, webphone and VoIP server Forum

HomeHomeDiscussionsDiscussionsMizu WebphoneMizu WebphoneHow to convert UDP packets to  a file like wav How to convert UDP packets to  a file like wav
Previous
 
Next
New Post
3/14/2020 4:26 AM
 

How to convert UDP packets to  a file like wav 

I set webphoneobj。

webphoneobj.API_SetParameter("sendmedia_type","0");

webphoneobj.API_SetParameter("sendmediain_to","6666");

I can only play sound use this.

//import required libraries
import java.io.*;
import javax.sound.sampled.*;
//initialize audio
AudioFormat format = new AudioFormat(8000, 16, 1, true, false); //you need to use 8000 for narrowband input or 16000 for wide-band
DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
SourceDataLine line = (SourceDataLine)AudioSystem.getLine(info);
line.open(format);
line.start();
//playback (you can pass the UDP packets as-is as received from JVoIP)
//this is usually called many times from your UDP socket thread or on UDP packet received event
line.write(buffer, 0, length);
//close
line.flush();
line.stop();
line.close();

How to save as   UDP packets a file

 

 
Previous
 
Next
HomeHomeDiscussionsDiscussionsMizu WebphoneMizu WebphoneHow to convert UDP packets to  a file like wav How to convert UDP packets to  a file like wav


You need to register / login to be able to post in the forum