1

I'm writing RTSP streaming server and I need some help. I think I've tried everything and read topics:

Receiving video stream from an IP camera on android

Playing RTSP stream in VLC player

Android local RTSP server (spoof), PVPlayer closes TCP socket after DESCRIBE reply sent

and other similiar to them. I also read many pdfs and RFCs of course.

My story: I wrote rtsp server and problem appears when I am sending resposponse to DESCRIBE header:

responseHeader.append(HeaderStates.OK);
responseHeader.append(CRLF);
responseHeader.append(CSeq);
responseHeader.append(CRLF);
responseHeader.append("session: ");
responseHeader.append(Long.valueOf(sessionID));
responseHeader.append(CRLF);
Date date = new Date();
responseHeader.append("Date: ");
responseHeader.append(date.toGMTString());
responseHeader.append(CRLF);
responseHeader.append("Content-Type: application/sdp");
responseHeader.append(CRLF);
responseHeader.append("Content-Base: ");
responseHeader.append(localAddress.getHostAddress());
responseHeader.append(":");
responseHeader.append(Integer.valueOf(localPort));
responseHeader.append(CRLF);
responseHeader.append(CRLF);
responseHeader.append("v=0");
responseHeader.append(CRLF);
responseHeader.append("o=- ");
responseHeader.append(date.getTime());
responseHeader.append(" ");
responseHeader.append(date.getTime());
responseHeader.append(" IN IP4 ");
responseHeader.append(localAddress.getHostAddress());
responseHeader.append(CRLF);
responseHeader.append("a=control:rtsp://192.168.1.143:55555");
responseHeader.append(CRLF);
responseHeader.append("s=RTSPSession");
responseHeader.append(CRLF);
responseHeader.append("m=video 55555 RTP/AVP 26");
responseHeader.append(CRLF);
responseHeader.append("a=rtpmap:26 JPEG/90000");
responseHeader.append(CRLF);
responseHeader.append("a=mimetype:video/JPEG");
responseHeader.append(CRLF);
//responseHeader.append("a=control:trackID=1");
responseHeader.append(CRLF);
responseHeader.append(CRLF);

where HeaderStates.OK is "200 OK", SessionID is System.currentTimeMillis(), CRLF = "\r\n" and responseHeader starts with "RTSP/1.0 "

then VLC (client on my PC throws unhadled exception and crashes), SMPlayer reads header and shows it in log but don't response.

Sometimes I get in SMPlayer log that says about error in SDP but I think cause of this error is too long debuging.

My question: What I've done wrong? Why there is no SETUP header from client?

Community
  • 1
  • 1
adrian
  • 132
  • 8

1 Answers1

0

Your missing the CSeq header in in the RtspResponse and thus it's invalid.

Also in your example you are returning a SDP so you need the Content-Length header!

Check out my server @ http://net7mma.codeplex.com/ to see the code of an existing implementation although it is in C# you should be able to get what you need.

Jay
  • 3,276
  • 1
  • 28
  • 38