2017-05-08 134 views
0

我正嘗試使用libstreaming api接收在android應用中創建的rtsp流。它以h264和aac編碼。我試圖在VLC播放器和另一個使用提供的代碼的Android設備上觀看它,但它似乎不起作用。從libstreaming播放rtsp流

的logcat:

05-08 15:10:43.266 5631-5631/net.majorkernelpanic.example1 E/WIFIIP: Unable to get host address. 
05-08 15:10:43.992 1311-5663/? E/RTSPSource: Server picked invalid RTP/RTCP port pair 39108-49193, RTP port must be even, RTCP port must be one higher. 

代碼:

String url2 = "rtsp://ip address:port"; 

SurfaceView mSurfaceView = (SurfaceView)findViewById(R.id.surface_video); 
SurfaceHolder holder = mSurfaceView.getHolder(); 
MediaPlayer mediaPlayer = new MediaPlayer(); 
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 
try { 
    mediaPlayer.setDataSource(url2); 
    mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 
     @Override 
     public void onPrepared(MediaPlayer mp) { 
      mediaPlayer.setDisplay(holder); 
      mediaPlayer.start(); 
     } 
    }); 
    mediaPlayer.prepareAsync(); // prepare async to not block main thread 
} catch (IOException ex) { 
    System.out.println(ex.toString()); 
    System.out.println("Unable to connect."); 
} 

回答

0

從您的logcat的錯誤:

RTSPSource: Server picked invalid RTP/RTCP port pair 39108-49193, RTP port must be even, RTCP port must be one higher

看來你應該修改libstreaming服務器端端口。錯誤指定「RTP端口必須是偶數,RTCP端口必須高一個」,例如你可以分別使它成爲39108,39109。修改你的服務器代碼並重試?

相關問題