2013-04-19 2 views
1

에 스트리밍하지 플레이어 MP3를 준다 오류 :JMF MP3 파일은 RTP

RTP Handler internal error: javax.media.ControllerErrorEvent[source=com.sun.medi 
[email protected],message=Internal module com.sun.media.BasicRend 
[email protected]: 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 

이 서버 측 코드를입니다

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){ 
    } 
    } 
    } 

이 클라이언트 측 코드

입니다
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(); 
         } 


     } 

제가 할 수있는 모든 일을 도와주세요. 제가 누락되었을 수있는 다른 세부 정보를 알려주십시오. 서버는 잘 실행되지만 플레이어 생성시 클라이언트 블록은 잘 실행됩니다. 내가 사용하는 오디오 포맷은 MPEG_RAW입니다. 열심히 대답을 찾고, 미리 감사드립니다. 오라클 포럼에서 보았을 때이 해결

답변

1

......

은 내가 생각

변화

AudioFormat.MPEG_RTP to AudioFormat.DVI_RTP 

는 MP3 일하러 모든 것을하지 않았다 이유를 묻지 않는다 나는 할 수 있었다.

이전에 작동하지 않는 이유를 알려주십시오.