problem in transmitting & recieving voice
hello to all!
i am making voice chat app...i have made 2 files
1 for sending voice
and 1 for recieng voice
but the probem is that voice is not heard in reciever side and also no error and no exception comes so what may be the problem..
//code for sending file
import java.io.*;
import java.util.Vector;
import javax.media.*;
import javax.media.format.*;
import javax.media.protocol.*;
import java.net.*;
import javax.media.control.*;
import javax.media.rtp.*;
public class SendVoice1 implements ControllerListener {
private boolean realized = false;
private boolean configured = false;
Processor p;
//InetAddress ip;
CaptureDeviceInfo info;
public static void main(String [] args) {
new SendVoice1();
}
SendVoice1() {
Vector v=CaptureDeviceManager.getDeviceList(new AudioFormat(AudioFormat.LINEAR,8000,8,1));
if (v.size() > 0) {
info = (CaptureDeviceInfo)v.elementAt(0);
// System.out.println(info.getName());
}
else {
System.out.println("No Audio Device Exist");
}
for(int a=0;a<v.size();a++){
//System.out.println(v.elementAt(a));
}
//Player p=Manager.createRealizedPlayer(info.getLocator());
//p.start();
try {
p = Manager.createProcessor(info.getLocator());
} catch (IOException e) {
System.out.println(e);
} catch (NoProcessorException e) {
System.out.println(e);
}
p.addControllerListener(this);
p.configure();
while (! configured) {
try {
Thread.currentThread().sleep(100L);;
} catch (InterruptedException e) {
// ignore
}
}
p.setContentDescriptor(new ContentDescriptor( ContentDescriptor.RAW));
TrackControl track[] = p.getTrackControls();
boolean encodingOk = false;
for (int i = 0; i >< track.length; i++) {
if (!encodingOk && track instanceof FormatControl) {
if (((FormatControl)track).setFormat( new AudioFormat(AudioFormat.ULAW_RTP, 8000,8,1)) == null) {
track.setEnabled(false);
}
else {
encodingOk = true;
}
}
else {
// we could not set this track to gsm, so disable it
track.setEnabled(false);
}
}
if (encodingOk){
p.realize();
while (! realized) {
try {
Thread.currentThread().sleep(100L);;
} catch (InterruptedException e) {
// ignore
}
}
DataSource ds=null;
try {
ds = p.getDataOutput();
} catch (NotRealizedError e) {
System.out.println(e);
}
try {
String url= "rtp://192.168.0.92:1500/audio/1";
MediaLocator m = new MediaLocator(url);
DataSink d = Manager.createDataSink(ds, m);
d.open();
d.start();
} catch (Exception e) {
System.out.println(e);
}
}
}
public synchronized void controllerUpdate(ControllerEvent evt) {
if (evt instanceof RealizeCompleteEvent) {
realized = true;
}
else if (evt instanceof ConfigureCompleteEvent) {
configured = true;
}
else if (evt instanceof EndOfMediaEvent) {
System.exit(0);
}
else {
// System.out.println(evt.toString());
}
}
}
//code for recieving file
public class ReVoice1 implements ControllerListener {
private boolean realized = false;
private boolean configured = false;
Player p;
public static void main(String args[]){
new ReVoice1();
}
ReVoice1(){
String url= "rtp://192.168.0.92:1500/audio/1";
MediaLocator mrl= new MediaLocator(url);
if (mrl == null) {
System.out.println("Can't build MRL for RTP");
}
// Create a player for this rtp session
try {
p = Manager.createPlayer(mrl);
} catch (NoPlayerException e) {
System.out.println("Error:" + e);
} catch (MalformedURLException e) {
System.out.println("Error:" + e);
} catch (IOException e) {
System.out.println("Error:" + e);
}
if (p != null) {
if (this.p == null) {
this.p = p;
p.addControllerListener(this);
p.realize();
}
}
}
public synchronized void controllerUpdate(ControllerEvent evt) {
if (evt instanceof RealizeCompleteEvent) {
realized = true;
}
else if (evt instanceof ConfigureCompleteEvent) {
configured = true;
}
else if (evt instanceof EndOfMediaEvent) {
System.exit(0);
}
else {
// System.out.println(evt.toString());
}
}
}
plz check out the code help me.......

