RTP Streaming
I have a question about a small command line application I have written. Here is the code.
import javax.media.*;
import javax.media.control.*;
import javax.media.protocol.*;
import javax.media.format.*;
import java.awt.*;
import java.io.*;
publicclass AudioConvertextends Frame
{
publicstaticvoid main(String args[])
{
MediaConverter mc =new MediaConverter();
}
}
class MediaConverterimplements ControllerListener
{
MediaLocator source;
MediaLocator dest;
Processor input =null;
DataSink output =null;
public MediaConverter()
{
System.out.println("Conversion started...");
source =new MediaLocator("http://localhost/ChatApplet/song.wav");
DataSource songInput =null;
try
{
songInput = Manager.createDataSource(source);
}
catch (IOException e){}
catch (NoDataSourceException e){}
try
{
input = Manager.createProcessor(songInput);
input.addControllerListener(this);
}
catch (IOException e){}
catch (NoProcessorException e){}
input.configure();
}
publicsynchronizedvoid configureCompleted()
{
System.out.println("Processor configured.");
input.setContentDescriptor(new ContentDescriptor(
ContentDescriptor.RAW));
TrackControl tracks[] = input.getTrackControls();
boolean programmable =false;
for (int i = 0; i < tracks.length; i++)
{
if ((tracks[i].setFormat(new AudioFormat(
AudioFormat.GSM_RTP,
8000,
8,
1))) !=null)
{
tracks[i].setEnabled(true);
programmable =true;
}
else
{
tracks[i].setEnabled(false);
}
}
if (programmable)
{
System.out.println("Programmable track found.");
}
input.realize();
}
publicsynchronizedvoid realizeCompleted()
{
input.setRate(10);
System.out.println("Processor realized.");
dest =new MediaLocator("rtp://localhost:5050/audio/1");
try
{
output = Manager.createDataSink(input.getDataOutput(), dest);
}
catch (NoDataSinkException e){}
try
{
output.open();
output.start();
}
catch (IOException e){}
input.start();
}
publicsynchronizedvoid stop()
{
input.stop();
input.close();
try
{
output.stop();
output.close();
}
catch (IOException e){}
}
publicsynchronizedvoid controllerUpdate(ControllerEvent evt)
{
if (evtinstanceof ConfigureCompleteEvent)
{
configureCompleted();
}
elseif (evtinstanceof RealizeCompleteEvent)
{
realizeCompleted();
}
elseif (evtinstanceof EndOfMediaEvent)
{
System.out.println("End of stream.");
stop();
}
}
}
Ok so the EndOfMediaEvent is never fired. Does a Player actually have to access the DataSource (rtp://localhost/audio/1) for the processor to actually be moving through the data? When I change a bit of code to have this output to a file, the program exits after the processor reaches the EndOfMedia. Why doesn't it do this when I'm outputting to an RTP stream? Or is there just something wrong in my code?
Thanks,
Khanathor

