RTSP直播保持活跃

时间:2015-04-21 13:46:05

标签: android vlc rtsp

我正在尝试创建可以查看实时RTSP流的Android RTSP客户端应用程序。问题是当达到服务器超时时,流结束。我检查了wireshark客户端发送RTSP OPTIONS并且服务器响应RTSP OK。在达到设置超时(15秒)后,服务器仍停止通过UDP发送视频,客户端断开连接。所以似乎控制连接仍然存在,但服务器停止流式传输。我不明白客户端获取BYE消息的位置。我能在这做什么想法?

我的测试代码非常简单明了。 以下是我认为最重要的部分:

VideoView video1 = (VideoView) findViewById(R.id.videoView);
Uri videoUri = Uri.parse("rtsp://myip:8552/t");
video1.setVideoURI(videoUri);

video1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
   public void onPrepared(MediaPlayer mediaPlayer) {
      mediaPlayer.start();
   }
});

这是android studio log:

logcat:

04-21 15:13:35.993     115-7361/? I/ARTSPConnection﹕ status: RTSP/1.0 200 OK
04-21 15:13:35.993     115-7361/? I/MyHandler﹕ OPTIONS completed with result 0 (Success)
04-21 15:13:37.483     115-7361/? I/MyHandler﹕ received BYE on track index 0
04-21 15:13:37.483     115-7361/? I/MyHandler﹕ received BYE on track index 1

04-21 15:13:49.523     115-7361/? I/ARTSPConnection﹕ status: RTSP/1.0 200 OK
04-21 15:13:49.523     115-7361/? I/MyHandler﹕ OPTIONS completed with result 0 (Success)

04-21 15:13:52.513     115-7361/? I/MyHandler﹕ stream ended? aborting.
04-21 15:13:52.553     115-7361/? I/ARTSPConnection﹕ status: RTSP/1.0 200 OK
04-21 15:13:52.553     115-7361/? I/MyHandler﹕ TEARDOWN completed with result 0 (Success)

客户端和服务器之间的最后一次通信:

OPTIONS rtsp://myip:8552/t RTSP/1.0
Session: be109033c48c17dc
User-Agent: stagefright/1.1 (Linux;Android 4.2.2)
CSeq: 6

RTSP/1.0 200 OK
Server: VLC/2.2.0
Content-Length: 0
Cseq: 6
Public: DESCRIBE,SETUP,TEARDOWN,PLAY,PAUSE,GET_PARAMETER

TEARDOWN rtsp://myip:8552/t RTSP/1.0
Session: be109033c48c17dc
User-Agent: stagefright/1.1 (Linux;Android 4.2.2)
CSeq: 7

RTSP/1.0 200 OK
Server: VLC/2.2.0
Date: Tue, 21 Apr 2015 13:18:25 GMT
Session: be109033c48c17dc;timeout=15
Content-Length: 0
Cache-Control: no-cache
Cseq: 7

0 个答案:

没有答案