I am trying to recieve rtsp stream created in android app using libstreaming api. It is encoded in h264 and aac. I tried to watch it in VLC player and on another android device using provided code but it does not seem to work.
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.
Code:
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.");
}
From your Logcat error:
RTSPSource: Server picked invalid RTP/RTCP port pair 39108-49193, RTP port must be even, RTCP port must be one higher
it seems you should modify your libstreaming Server Side ports. The error specifies "RTP port must be even, RTCP port must be one higher" so you could make it 39108, 39109 respectively for instance. Modify your server code and try again?