'RTSP SETUP does not return a Session ID or corresponding client or server ports

I am trying to create a python code that subscribes to an RTSP URL of a device and get it's video stream. I create a socket object in python to interface with RTSP Port.

With IP address and RTSP URL as follows:

ip="192.168.75.51"
adr="rtsp://192.168.75.51:8554/live/all"

I set up DESCRIBE, SETUP and OPTIONS for RTSP as follows:

dest=("DESCRIBE "+adr+" RTSP/1.0\r\nCSeq: 0\r\nUser-Agent: python\r\nAccept: application/sdp\r\n\r\n").encode()
setu=("SETUP "+adr+" RTSP/1.0\r\nCSeq: 1\r\nUser-Agent: python\r\nTransport: RTP/AVP;unicast;client_port="+str(clientports[0])+"-"+str(clientports[1])+"\r\n\r\n").encode()
optio=("OPTIONS "+adr+" RTSP/1.0\r\nCSeq: 2\r\nUser-Agent: python\r\n\r\n").encode()

The clientports list in the SETUP description is as follows:

clientports=[60784,60785]

The DESCRIBE and OPTIONS work as intended. However, the SETUP command does not give out a Session ID or the corresponding client or server ports required for executing the PLAY functionality of RTSP protocol.

The output I get when the SETUP command is sent is:

RTSP/1.0 200 OK
CSeq: 2
Public: OPTIONS, DESCRIBE, ANNOUNCE, GET_PARAMETER, PAUSE, PLAY, RECORD, SETUP, SET_PARAMETER, TEARDOWN
Server: GStreamer RTSP server
Date: Thu, 14 Feb 2019 11:19:21 GMT

An example of what I was expecting is the following (This was taken from a different stack overflow post):

RTSP/1.0 200 OK
CSeq: 3
Session:       1117448817;timeout=60
Transport: RTP/AVP;unicast;client_port=60784-60785;server_port=8214-8215;ssrc=40d35c30;mode="play"
Date:  Mon, Jan 19 2015 11:10:08 GMT

As you can see the above output has the Session and client and server port identification.

I am fairly new to RTSP functionality with python and any help as to why I am unable to work with the SETUP function will be helpful.

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source