7

If the client wants to watch a stream that is on my RTSP server, it first tries to setup a stream through the UDP protocol. How can I tell it that my server only supports RTP/AVP/TCP and that it should switch transports?

I want to terminate the UDP support on my server, but all the clients first try to SETUP the session over UDP, and later they do so over TCP... and I want to switch them to TCP as soon as possible in RTSP protocol.

How can I do that?

Aliaksandr Belik
  • 12,725
  • 6
  • 64
  • 90
Cipi
  • 11,055
  • 9
  • 47
  • 60

6 Answers6

8

As far as I know, there is no control at server side for transport type preference. Server should be made generic it should support RTP over UDP, RTP over TCP, RTP over RTSP and RTP over RTSP over HTTP(S). And its clients choice which transport to choose. Transport field is first sent in SETUP request

1) UDP

 C->A: SETUP rtsp://audio.example.com/twister/audio.en RTSP/1.0
               CSeq: 1
               Transport: RTP/AVP/UDP;unicast;client_port=3056-3057

2) TCP

    C->A: SETUP rtsp://audio.example.com/twister/audio.en RTSP/1.0
               CSeq: 1
               Transport: RTP/AVP/TCP;unicast;client_port=3056-3057

3) RTP over RTSP and RTP over RTSP over HTTP(S)

S->C: RTSP/1.0 200 OK
           CSeq: 2
           Date: 05 Jun 1997 18:57:18 GMT
           Transport: RTP/AVP/TCP;interleaved=0-1

As we can see "Transport type" request is sent by client side.

If you want to support TCP only server you can send "400 Bad Request" or "461 Unsupported transport" in response to SETUP request as suggested by you or another way is to send 200 OK but do not transmit any RTP packets. Client will timeout and get to know that it is behind proxy and it will send SETUP request again with RTP/AVP/TCP parameter (Not an ideal case).

Alam
  • 1,536
  • 15
  • 26
  • @Alam sir i am using 2 live555 programs "testMpeg2transportstreamer" in test directory of live 555 and proxy server in proxy server directory of live 555,to the proxy server program i am giving the url of "testMpeg2transportstreamer" rtsp server and now can i send the C->A: SETUP rtsp://audio.example.com/twister/audio.en RTSP/1.0 CSeq: 1 Transport: RTP/AVP/TCP;unicast;client_port=3056-3057 to "testMpeg2transportstreamer" from proxy server please guide – Ajinkya Jan 09 '13 at 10:58
  • @Alam i want testMpeg2transportstreamer to stream only TCP packets,as now when i see in wireshark it stream the UDP packet i want it to stream TCP packet which i can see in wireshark – Ajinkya Jan 09 '13 at 11:00
  • @Ajinkya. Make sure you are using -t option on your proxy server? and testMpeg2transportstreamer is not using multicast address – Alam Jan 15 '13 at 02:50
  • @Alam sir please reply on this http://stackoverflow.com/questions/14337755/how-to-create-and-destroy-rtsp-server-again-and-again-live-555 – Ajinkya Jan 15 '13 at 12:30
  • @Alam is there any way to sent the tear down request from proxy server to back end server – Ajinkya Jan 17 '13 at 15:02
  • Example 2 is superficial, should be exactly like example 3 and example 3 needs the http headers and to be base64 encoded for the http variation. – Jay Sep 14 '14 at 13:01
  • @Jay Example 2 is representing RTP over TCP other than HTTP(TCP) connection. For example 3 you are right for HTTP but is not related with the question asked. – Alam Nov 03 '14 at 15:15
  • @Alam incorrect that actually would be rfc4571 and specified in the sdp. There actually is a problem when both rfc4571 and rtsp are used together however the wg has not responded to my errata yet. Rtsp uses the rtsp ports and an interleaved header.. post your reference. – Jay Nov 04 '14 at 21:55
  • Also if it was other than HTTP would not have the RTP profile and would be considered Independent TCP... please update your answer or post your source.... – Jay Dec 28 '14 at 04:08
  • @Alam Furthermore the server only controls this and not the client... the client can ask for foo transport the server will respond with UnsupportedTransport. Just about all of your information is incorrect! – Jay Dec 29 '14 at 09:06
  • @Jay then why don't you post correct answer. Read the question and give a good short and crisp answer. I will gladly upvote you. This community needs good answers and there can be more than one good answer. I still believe with context to question asked my answer is correct. You are free to downvote my answer. – Alam Dec 29 '14 at 19:17
  • That sounds like sounds advice, I just wonder where you are getting your information and why you think it is the way you described. – Jay Dec 29 '14 at 22:45
7

To expand on the answer for android, For Android clients, they will always attempt to establish a UDP connection first.

For both OpenCore and StageFright I can confirm that if I return "461 Unsupported Transport" from my server in response to the first SETUP request for UDP transfer, both of these clients will then IMMEDIATELY attempt to establish a TCP based connection over the RTSP port.

All other responses are detailed here: http://www.ietf.org/rfc/rfc2326.txt

ianhobo
  • 200
  • 2
  • 8
4

If you used ffmpeg, you can force switch rtsp transport layer protocol.

av_dict_set(&format_opts, "rtsp_transport", "tcp", 0);
err = avformat_open_input(&ic, is->filename, is->iformat, &format_opts);
Crossle Song
  • 10,104
  • 2
  • 29
  • 38
4

OK one way is to send "400 Bad Request" as the response to the client's SETUP request... and it automatically switches to TCP protocol. This is for RealOne and QuickTime.

But I am not sure that it will work on all other players since this is a hack.

Any other ideas? =|

Cipi
  • 11,055
  • 9
  • 47
  • 60
  • Is there any documentation on this? BadRequest causes QuickTime to go into a 'configuring' status then never sends another request and displays 'BadRequest' or Connection Failed. UnsupportedTranport just leaves QuickTime displaying 'UnsupportedTransport'. I can get Vlc to switch but not QuickTime or real one. The mailing list seems to indicate its not supported in quicktime http://lists.apple.com/archives/streaming-server-dev/2007/Feb/msg00033.html only http tunneles is supported... – Jay Dec 27 '14 at 23:12
  • When are you sending BadRequest? What protocol does QuickTime try to initiate? – Cipi Jan 14 '15 at 11:39
  • During setup then Http request with x-rtsp-tunneled headed. – Jay Jan 14 '15 at 16:15
  • 1
    There is a special response code just for this case. 461 - Transport Unsupported. http://www.websitepulse.com/kb/rtsp_status_codes.html – LawfulEvil Apr 28 '15 at 17:27
1

What client connects to your server? Some clients can be triggered through the URI method in the URL. For example, you could specify rtspt://myhost/path.sdp.

If you have control over client/servers you could use the Require header on clients and Unsupported on servers to indicate that UDP isn't supported; but most clients I've seen don't use this.

J. Fritz Barnes
  • 858
  • 7
  • 6
  • Multimedia players that support RTSP. Like RealOne, QuickTime, VLC, Media Player Clasic... What method I dont get you? I dont have control over clients, I wrote the server, so its the only control I have. I cant send Unsupported for Transfer header. =\ – Cipi Mar 11 '10 at 08:17
  • Windows Media Player supports the use of rtspt in the URLs and some mobile handset RTSP players also support this as a signalling method to attempt interleaved RTP transport instead of the standard UDP. However, VLC and QT do not support this signalling. – J. Fritz Barnes Mar 12 '10 at 00:04
  • If I get you all I need to do is add the "t" in "rtspt"? =| – Cipi Mar 12 '10 at 10:13
  • Correct. I know that Windows Media Player on Windows supports this and in WinMo. I tried this against QT, but it didn't seem to recognize the rtspt; this seems to be a vendor specific implementation whether to recognize it. – J. Fritz Barnes Mar 20 '10 at 03:34
  • @J.FritzBarnes sir please reply on this http://stackoverflow.com/questions/14337755/how-to-create-and-destroy-rtsp-server-again-and-again-live-555 – Ajinkya Jan 15 '13 at 12:29
  • @J.FritzBarnes is there any way to sent the tear down request from proxy server to back end server – Ajinkya Jan 17 '13 at 15:03
  • btw, to force VLC (seems to uses Live555 library) at the client side to use TCP for such streams see http://www.wowza.com/forums/content.php?64-How-to-configure-VLC-media-player-for-RTSP-RTP-playback-(RTSP-RTP-interleaved-and-tuning) – George Birbilis Nov 03 '15 at 14:17
1

You can try to pass "transport" header in a response to Describe request, and state there that your server only supports RTP/AVP/TCP transport, and the client should know that UDP is unsupported.

Sendro
  • 71
  • 1
  • 2
  • i am using 2 live555 programs "testMpeg2transportstreamer" in test directory of live 555 and proxy server in proxy server directory of live 555,to the proxy server program i am giving the url of "testMpeg2transportstreamer" rtsp server and now can i send the C->A: SETUP rtsp://audio.example.com/twister/audio.en RTSP/1.0 CSeq: 1 Transport: RTP/AVP/TCP;unicast;client_port=3056-3057 to "testMpeg2transportstreamer" from proxy server please guide – Ajinkya Jan 09 '13 at 12:02