我寫RTSP服務器,並有一些問題。 我使用VLC作爲客戶端。RTSP服務器的Java實現的問題:(
服務器收到OPTIONS,DESCRIBE,從客戶端安裝和PLAY命令(VLC播放器)並回答該命令
通過SETUP命令客戶端發送端口號碼,我使用該端口發送數據 當我的服務器接收PLAY命令它發送答案並開始流數據。 DatagramSocket實例與客戶端端口
我想流mp4文件。 我正在使用mp4parse java庫來獲取音頻和視頻軌道數據流。
所以,當我點擊VLC播放器的連接,並開始等待數據,幾秒鐘後,我得到了在VLC消息消息:
live555 warning: no data received in 10s. Switching to TCP
這裏是我的SDP數據:
v=0
o=- 0 0 IN IP4 127.0.0.1
m=video 0 RTP/AVP 96
b=AS:1633
a=rtpmap:96 H264/90000
a=control:trackID=65536
a=fmtp:96 profile-level-id=64001F; packetization-mode=1; sprop-parameter-sets=Z2QAH6zZgFAFuhAAAAMAEAAAAwMg8YMZoA==,aOl7LIs=
a=framesize:96 1280-720
m=audio 0 RTP/AVP 97
b=AS:129
a=rtpmap:97 mpeg4-generic/48000/2
a=control:trackID=65537
a=fmtp:97 profile-level-id=41; config=1190; streamType=5; mode=AAC-hbr; objectType=64; constantDuration=1024; sizeLength=13; indexLength=3; indexDeltaLength=3
另外,我使用jlibrtp來創建RTP數據包併發送它們。
這裏是服務器 - 客戶端通信日誌:
+++++++CLIENT+S++++++++++
OPTIONS rtsp://127.0.0.1:4444/aaa RTSP/1.0
CSeq: 2
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
+++++++CLIENT+E++++++++++
+++++++SERVER+S++++++++++
RTSP/1.0 200 OK
CSeq: 2
Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE
+++++++SERVER+E++++++++++
+++++++CLIENT+S++++++++++
DESCRIBE rtsp://127.0.0.1:4444/aaa RTSP/1.0
CSeq: 3
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Accept: application/sdp
+++++++CLIENT+E++++++++++
+++++++SERVER+S++++++++++
RTSP/1.0 200 OK
CSeq: 3
Content-Type: application/sdp
v=0
o=- 0 0 IN IP4 127.0.0.1
m=video 0 RTP/AVP 96
b=AS:1633
a=rtpmap:96 H264/90000
a=control:trackID=65536
a=fmtp:96 profile-level-id=64001F; packetization-mode=1; sprop-parameter-sets=Z2QAH6zZgFAFuhAAAAMAEAAAAwMg8YMZoA==,aOl7LIs=
a=framesize:96 1280-720
m=audio 0 RTP/AVP 97
b=AS:129
a=rtpmap:97 mpeg4-generic/48000/2
a=control:trackID=65537
a=fmtp:97 profile-level-id=41; config=1190; streamType=5; mode=AAC-hbr; objectType=64; constantDuration=1024; sizeLength=13; indexLength=3; indexDeltaLength=3
+++++++SERVER+E++++++++++
+++++++CLIENT+S++++++++++
SETUP rtsp://127.0.0.1:4444/aaa/trackID=65536 RTSP/1.0
CSeq: 4
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Transport: RTP/AVP;unicast;client_port=59298-59299
+++++++CLIENT+E++++++++++
+++++++SERVER+S++++++++++
RTSP/1.0 200 OK
CSeq: 4
Transport: RTP/AVP;unicast;client_port=59298-59299
Session: 00007689
+++++++SERVER+E++++++++++
+++++++CLIENT+S++++++++++
SETUP rtsp://127.0.0.1:4444/aaa/trackID=65537 RTSP/1.0
CSeq: 5
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Transport: RTP/AVP;unicast;client_port=62520-62521
Session: 00007689
+++++++CLIENT+E++++++++++
+++++++SERVER+S++++++++++
RTSP/1.0 200 OK
CSeq: 5
Transport: RTP/AVP;unicast;client_port=62520-62521
Session: 00007689
+++++++SERVER+E++++++++++
+++++++CLIENT+S++++++++++
PLAY rtsp://127.0.0.1:4444/aaa RTSP/1.0
CSeq: 6
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Session: 00007689
Range: npt=0.000-
+++++++CLIENT+E++++++++++
+++++++SERVER+S++++++++++
RTSP/1.0 200 OK
CSeq: 6
+++++++SERVER+E++++++++++
Streaming...
+++++++CLIENT+S++++++++++
TEARDOWN rtsp://127.0.0.1:4444/aaa RTSP/1.0
CSeq: 7
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Session: 00007689
+++++++CLIENT+E++++++++++
+++++++SERVER+S++++++++++
RTSP/1.0 200 OK
CSeq: 7
+++++++SERVER+E++++++++++
Exception in thread "main" java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at com.vtgsoftwares.ekiz.server.RTSPServer.<init>(RTSPServer.java:71)
at com.vtgsoftwares.ekiz.server.RTSPServer.main(RTSPServer.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
有什麼想法?
謝謝。
瓦爾丹,它看起來就像是寫數據到客戶端失敗的服務器代碼;添加一些日誌語句,其中服務器代碼將數據寫入套接字以查看它是否按預期工作。 – 2012-04-25 20:13:16