7

I am writing a RTSP client in Android. I am able to receive the Responses for all the requests i.e.,

  1. DESCRIBE it sends back the 200 OK
  2. SETUP with transport: RTP/AVP:unicast:client_port=4568:4569 got the 200 OK Message back
  3. Sent PLAY, and got the OK Message

After that how to get the audio and video frames?

I have searched on blogs, but all say to listen at client_port but I am not receiving any packets.

Please let me know am I doing correctly.

Vinay
  • 4,743
  • 7
  • 33
  • 43

4 Answers4

4

You may or may not know this, but Android has built in support for RTSP using the VideoView.

http://developer.android.com/reference/android/widget/VideoView.html

This may cut down on your development time...or it may be totally useless if you're trying to roll your own RTSP stack.

haseman
  • 11,213
  • 8
  • 41
  • 38
  • It does not work with both device and emulator. It fails in PLAYER_INIT with PVMFFailure. – Vinay Jul 30 '09 at 14:53
  • 1
    I've found it not work with the emulator, but to work on all the devices I've gotten my hands on. Some of them require that you have the wake lock permission set in your manifest (figure that one out) – haseman Dec 07 '09 at 17:38
  • I have set wake lock permission in manifest file. It still fails with PVMFFailure. – Emre Köse Apr 28 '10 at 07:54
3

RTSP is only used to start the streaming. It gives you an SDP description of the real streams. You have to manage an RTCP connection and a RTP connection per channel (audio / video). The ports to use are the "client_port" ones.

It is pretty complex to code a RTSP/RTCP/RTP stack from scratch. You can have a look at the live555 library that implement such a stack in c++.

neuro
  • 14,948
  • 3
  • 36
  • 59
1

Put a sniffer on the network, you should see UDP packet with destination port 4568 targeted at your IP address.

With a decent sniffer, you will be able to see the rtsp dialog. Maybe you are missing something in the answers

You should also check the content of the SETUP response, to see if the port you requested were accepted.

Things to check :

  • Listening in UDP.
  • Firewall rules.
  • Range of the play request : Don't specify any to be sure the server will be playing something.

If you are behind a router or firewall, you probably won't receive anything, because your router / firewall don't know what to do with incoming UDP packets

shodanex
  • 14,975
  • 11
  • 57
  • 91
  • The SETUP response is proper i.e., it succeeds with 200 OK. How to use the sniffer? Is there any documentation to use it on Android platform? – Vinay Oct 08 '09 at 15:12
  • "If you are behind a router or firewall, you probably won't receive anything, because your router / firewall don't know what to do with incoming UDP packets" --- how to handle this case? presently I am behind a firewall – Vinay Oct 14 '09 at 15:43
1

Try first with a local Darwin Streaming server installed within your LAN.that way Firewall wont matter.Streaming will work.

If you want to try from external server then:

1) Check the client_ports mentioned in the SERVER response,some servers suggest different ports from the one requested.you have to use the ports suggested by server.

2) If the ports are correct, then you can send 64byte empty packets from each of the UDP ports to the server(called "door openers").

3) If the above two don't fix it, check the server side logs.The server might be closing the UDP ports.

Shreesh
  • 677
  • 5
  • 15