Pergunta

The player mp3 gives error:

RTP Handler internal error: javax.media.ControllerErrorEvent[source=com.sun.medi
a.content.unknown.Handler@baf4ae,message=Internal module com.sun.media.BasicRend
ererModule@197f158: failed to handle a data format change!]


i m running 
server as:java MediaConverterExample rtp://rajneesh-pc:49150/audio   Dead_End.mp3

client as:java PlayerExample rtp://rajneesh-pc:49150/audio

this is server side code

    import javax.media.*;
     import java.io.File;
     import java.io.IOException;
          import java.net.URL;
            import java.net.MalformedURLException;
          import javax.media.protocol.*;
          import javax.media.format.AudioFormat;


      import javax.swing.*;
     import java.awt.*;
         import java.awt.event.*;


         class MediaConvertion
      {
         private MediaLocator mediaLocator = null;

       private DataSink dataSink = null;

      private Processor mediaProcessor = null;

      private static final Format[] FORMATS = new Format[]                          {                   new AudioFormat(AudioFormat.MPEG_RTP)};


               private static final ContentDescriptor CONTENT_DESCRIPTOR =new    ContentDescriptor  (ContentDescriptor.RAW_RTP);


           public MediaConvertion(String url)throws IOException,NoProcessorException,   CannotRealizeException, NoDataSinkException, NoDataSinkException
 {
mediaLocator=new MediaLocator(url);

}

            public void setDataSource(DataSource ds) throws      IOException,NoProcessorException,                      CannotRealizeException, NoDataSinkException {

             mediaProcessor = Manager.createRealizedProcessor(new ProcessorModel(ds, FORMATS,                               CONTENT_DESCRIPTOR));
            dataSink = Manager.createDataSink(mediaProcessor.getDataOutput(),mediaLocator);
     }


       public void startTransmitting() throws IOException {
  mediaProcessor.start();
      dataSink.open();
        dataSink.start();
        }


          public void stopTransmitting() throws IOException {
        dataSink.stop();
      dataSink.close();
       mediaProcessor.stop();
        mediaProcessor.close();
         }
                }

    public class MediaConverterExample extends Frame implements ActionListener
      {

Button st_stream;
static MediaConvertion mdcon;

    public static void main(String args[])throws IOException,NoProcessorException, CannotRealizeException, NoDataSinkException,MalformedURLException,NoDataSourceException
     {
   Format input1 = new AudioFormat(AudioFormat.MPEGLAYER3);
         Format input2 = new AudioFormat(AudioFormat.MPEG);
         Format output = new AudioFormat(AudioFormat.LINEAR);
         PlugInManager.addPlugIn(
       "com.sun.media.codec.audio.mp3.JavaDecoder",
       new Format[]{input1, input2},
      new Format[]{output},
      PlugInManager.CODEC
   );
    File mediaFile = new File(args[1]);
    DataSource source = Manager.createDataSource(new MediaLocator(mediaFile.toURL()));
    mdcon=new MediaConvertion(args[0]);
     mdcon.setDataSource(source);
new MediaConverterExample();
    }

public MediaConverterExample()
{
    st_stream=new Button("Start Streaming");
    add(st_stream);
    st_stream.addActionListener(this);
    setVisible(true);
    setSize(200,300);

}
public void actionPerformed(ActionEvent ae)
{   
    try
    {
    mdcon.startTransmitting();
    }
    catch(Exception e){
    }
   }
   }

this is client side code

import javax.media.*;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

import javax.media.format.*;

public class PlayerExample extends JFrame implements ActionListener
{
Button play;
 SimpleAudioPlayer sap;

    PlayerExample(String playFile) throws IOException,NoPlayerException, CannotRealizeException
    {
        sap=new SimpleAudioPlayer(new MediaLocator(playFile));
        setLayout(new BorderLayout());
        //add(sap.VideoComponent(),BorderLayout.CENTER);
        //add(sap.AudioComponent(),BorderLayout.WEST);
        //add(sap.ControlComponent(),BorderLayout.NORTH);
        add(play=new Button("play"),BorderLayout.SOUTH);
        play.addActionListener(this);
        setSize(200,300);
        setVisible(true);       
    }

    public void actionPerformed(ActionEvent ae)
    {

    sap.play();     

    }
     public static void main(String args[])throws IOException,NoPlayerException, CannotRealizeException
    {
        Format input1 = new AudioFormat(AudioFormat.MPEGLAYER3);
                Format input2 = new AudioFormat(AudioFormat.MPEG);
              Format output = new AudioFormat(AudioFormat.LINEAR);
             PlugInManager.addPlugIn(
               "com.sun.media.codec.audio.mp3.JavaDecoder",
              new Format[]{input1, input2},
           new Format[]{output},
             PlugInManager.CODEC
               );

    new PlayerExample(args[0]);
       }
          }

class SimpleAudioPlayer {

private Player videoPlayer = null;

public SimpleAudioPlayer(MediaLocator ml) throws IOException, NoPlayerException, CannotRealizeException  {

                        videoPlayer = Manager.createRealizedPlayer(ml);
                        }


public void play() {
                        //videoPlayer.deallocate();
                        videoPlayer.start();
                        }
public void stop() {
                        videoPlayer.stop();

                        }
       public Component VideoComponent(){
                                return videoPlayer.getVisualComponent();
                        }
     public Component  ControlComponent(){
                        return videoPlayer.getControlPanelComponent();          
                        }
public Component AudioComponent(){
                        return videoPlayer.getGainControl().getControlComponent();
                        }


        }

Please help I did every thing I could. Please advise me of any other details I might be missing, server runs fine, but client blocks at player creation. The audio format I am using is MPEG_RAW. Eagerly looking for an answer, thanks in advance.

Foi útil?

Solução

SOLVED......

i figured when looked at oracle forum

change

  AudioFormat.MPEG_RTP  to AudioFormat.DVI_RTP

don't ask a reason why mp3 didn't work.i did everything i could.

please tell me why previous didn't work.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top