I'm writing RTSP server and have some problems. I'm using VLC as client.
Server receive OPTIONS, DESCRIBE, SETUP and PLAY commands from client (VLC player) and answers to that commands.
By SETUP command client send ports numbers and I'm using that ports to send data. When my server receive PLAY command it's sending the answer and starting to stream data. I'm creating two DatagramSocket instances with the client ports.
I'm trying to stream mp4 files. I'm using mp4parse java library to get audio and video tracks data to stream.
So, when I click play on VLC it's connecting and starting waiting the data, after some seconds I got this message in VLC messages:
live555 warning: no data received in 10s. Switching to TCP
Here is my SDP data:
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
Also, I'm using jlibrtp for creating RTP packets and sending them.
Here is Server-Client communication log:
+++++++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)
Any thoughts?
Thanks.
The RTSP peers in the server log, should be agreeing on 'transport' as part of the protocol after the RTSP SETUP request is sent by the client...
Received 360 new bytes of response data.
Received a complete SETUP response:
RTSP/1.0 200 OK
Session: 70cd7f38;timeout=90
Transport: RTP/AVP;unicast;mode=play;client_port=64498-64499;server_port=10580-10581;source=74.125.212.247;ssrc=50DF166F
Your server logs should show the peers agreeing to sets of ports ( C / S ) for the RTCP and data portions of the protocol.
A guess is that your VLC client does not know where to find the data stream to read... ie what port should i wait on for ( data available to be read ).
Logs from some successful RTSP sessions:
Play Youtube RTSP : client openrtsp