0 Replies Latest reply: Aug 30, 2012 1:06 AM by 958671 RSS

    ULAW support in JMF

    958671
      Hi,

      I am developing an JMF application. I am trying to Stream RTP from a ULAW file. I am using following code

      import java.io.IOException;
      import java.net.InetAddress;
      import java.net.UnknownHostException;

      import javax.media.CannotRealizeException;
      import javax.media.Format;
      import javax.media.Manager;
      import javax.media.MediaLocator;
      import javax.media.NoDataSourceException;
      import javax.media.NoProcessorException;
      import javax.media.Processor;
      import javax.media.ProcessorModel;
      import javax.media.format.AudioFormat;
      import javax.media.format.UnsupportedFormatException;
      import javax.media.protocol.ContentDescriptor;
      import javax.media.rtp.InvalidSessionAddressException;
      import javax.media.rtp.RTPManager;
      import javax.media.rtp.SendStream;
      import javax.media.rtp.SessionAddress;

      import com.sun.media.protocol.file.DataSource;

      public class RTPTransmitter {

           private int rtpPort;
           private String rtpServer;
           private String contentType;
           private Format[] FORMATS = new Format[] { new AudioFormat(
                     AudioFormat.ULAW_RTP, 8000, 8, 1) };
           private ContentDescriptor CONTENT_DESCRIPTOR = new ContentDescriptor(
                     ContentDescriptor.RAW);
           private SendStream sendStream;
           private RTPManager rtpManager;
           private SessionAddress localAddress;
           private SessionAddress remoteAddress;
           private ProcessorModel processorModel;
           private Processor processor;
           public RTPTransmitter(String contentType, int rtpPort, String rtpServer) {
                super();
                this.contentType = contentType;
                this.rtpPort = rtpPort;
                this.rtpServer = rtpServer;
           }

           public void startRTP() {
                rtpManager = RTPManager.newInstance();
                try {
                     localAddress = new SessionAddress(InetAddress.getByName("172.19.103.164"), 17886);
                     rtpManager.initialize(localAddress);
                     remoteAddress = new SessionAddress(InetAddress
                               .getByName(rtpServer), rtpPort);
                     rtpManager.addTarget(remoteAddress);

                     DataSource dataInput = (DataSource) Manager
                               .createDataSource(new MediaLocator("file:\\D:\\one.ulaw"));
                     processorModel= new ProcessorModel(dataInput ,FORMATS, CONTENT_DESCRIPTOR);
                     processor = Manager.createRealizedProcessor(processorModel);
                     DataSource dataOutput = (DataSource) processor.getDataOutput();
                     sendStream = rtpManager.createSendStream(dataOutput, 0);
                     sendStream.start();
                     processor.start();

                } catch (UnknownHostException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                } catch (InvalidSessionAddressException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                } catch (IOException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                } catch (NoDataSourceException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                } catch (NoProcessorException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                } catch (CannotRealizeException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                } catch (UnsupportedFormatException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                }
           }
           
           public static void main(String[] args) {
                RTPTransmitter rtpTransmitter=new RTPTransmitter("audio",7098,"172.19.97.14");
                rtpTransmitter.startRTP();
           }
      }


      I am getting following exception

      javax.media.NoProcessorException: Cannot find a Processor for: com.sun.media.protocol.file.DataSource@47858e
           at javax.media.Manager.createProcessorForSource(Manager.java:1766)
           at javax.media.Manager.createProcessor(Manager.java:666)
           at javax.media.Manager.createRealizedProcessor(Manager.java:717)
           at com.RTPTransmitter.startRTP(RTPTransmitter.java:59)
           at com.RTPTransmitter.main(RTPTransmitter.java:91)

      I tried with both cross platform library as well as windows performence pack. I am getting the same exception.

      Please anyone help me to get this issue resolved.

      With Thanks And Regards,
      Huthesh

      Edited by: 955668 on Aug 29, 2012 11:04 PM