4
votes

I have an IP camera which can give me media-data by RTSP.

I develop an application for getting media-data.

I use C++ and Qt3.

I create socket. connect it to my device IP on port=554.

I do first query

SETUP rtsp://192.168.4.160/ufirststream RTSP/1.0\r\n
CSeq: 1\r\n
Transport: RTP/AVP; client_port=554\r\n\r\n

And get an answer:

RTSP/1.0 200 OK
CSeq: 1
Date: Sat, Mar 24 2012 17:24:59 GMT
Transport: RTP/AVP;unicast;destination=192.168.4.186;source=192.168.4.160;client_port=0-1;server_port=2000-2001
Session: 413F4DDB

I parse it for gettin session value, and do next query:

PLAY rtsp://192.168.4.160/ufirststream RTSP/1.0
CSeq: 1
Session: 413F4DDB

And server says:

RTSP/1.0 200 OK
CSeq: 1
Date: Sat, Mar 24 2012 17:25:02 GMT
Session: 413F4DDB
RTP-Info: url=rtsp://192.168.4.160/ufirststream/track1;seq=6716;rtptime=406936711

And how I can get media-data??? I thought that PLAY-method makes server to give me a stream, but it only gives me an url to rtsp and other info...

I need an binary stream from camera, can you give an advise for my next step??

1

1 Answers

6
votes

The Transport header of the SETUP request indicates which protocol will be used to send the stream, and the client_port the ports on which your client will be listening.

Try opening 2 consecutive UDP ports and pass that range as client_port=port1-port2 instead of 554. These two ports will be used for the RTP and the RTCP streams (video and control data).

In addition, the RTP port number should be an even number, and the RTCP port the next odd number (See that question if you want the port range to be random rather than user selected).