2

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.

  • Vardan, it looks like the server code that is writing data out to the client is failing; add some log statements where the server code writes data out to the socket to see if it is working as you expect. – Rob Kielty Apr 25 '12 at 20:13

1 Answers1

1

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

VLC client Play RTSP stream

Robert Rowntree
  • 6,230
  • 2
  • 24
  • 43
  • Thanks for response. Now VLC not write `live555 warning: no data received in 10s. Switching to TCP`. One question related with ports: I should send data to client ports right? Also, when I'm using jlibrtp it gives some errors and I couldn't understand what is the issue. So, now I'm thinking about not using that jlibrtp. That means that I need to create RTP packet manually and send to client port. I have read about RTP packet structure but in real couldn't understood how to create that in java. Do you know any resource from where I can get info about that? – Vardan Gevorgyan Apr 26 '12 at 14:56
  • Im not sure exactly why you attempt to write your own rtsp server? You might look for an open source implementation ( java i guess ). Wowza is one that people use ( http://www.wowza.com/html/mobile.html ). Note: i would not recommend spending alot of time implementing your own code to create RTP packets as that gets really complex. I would recommend 2 things if you are going to spend a lot of time on the RTSP server and alot of time down in the weeds... – Robert Rowntree Apr 26 '12 at 15:07
  • 1. read the RPT / RTSP / SDP RFC's list is many .. like : http://www.ietf.org/rfc/rfc2198.txt – Robert Rowntree Apr 26 '12 at 15:08
  • 2. review a C++ library where they are packing/unpacking RTP packets. example http://snipplr.com/view/57979/rtp-packet-handler/ example java http://snipplr.com/view/57978/rtp-packet-handler/ – Robert Rowntree Apr 26 '12 at 15:11
  • read this one : http://www.cs.columbia.edu/~hgs/teaching/ais/slides/2003/RTSP.pdf – Robert Rowntree Apr 26 '12 at 15:19
  • Hi Vardan, have you solved "live555 warning: no data received in 10s. " problem? I'm getting the same. – Eljah Sep 15 '13 at 04:35