0

I was implementing rtsp with libcurl(sample code https://curl.haxx.se/libcurl/c/rtsp.html) I received RTP data after sending PLAY option. But the connection broke about ten minutes. I thought it might send heartbeat message to rtsp sever to keep session alive.

How to keep connection alive with libcurl ?

Code Flow :

// Set Option

// Set Describe

// Set Setup

// PLAY

/* Receive RTP DATA*/

while(1)

{

curl_easy_set_opt(curl, CURLOPT_WRITEFUNCTION, rtsp_write);

curl_easy_set_opt(curl, CURLOPT_WRITEDATA, NULL);

.....

}
2Cubed
  • 3,401
  • 7
  • 23
  • 40
BY.H
  • 3
  • 5

2 Answers2

0

You need to send CURL_RTSPREQ_OPTIONS again. I send it every 30 seconds.

ts1690
  • 11
  • 2
  • This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. – Rohan Khude Aug 23 '16 at 16:42
0

The RTSP connection indeed requires the heartbeat. It is specified in RCF 2326, section 12.37 and ONVIF streaming specification, section 5.2.1.1.1.

Basically you do:

  1. Optionally set the timeout parameter (in seconds), the usual default is 60sec.
  2. The RTSP SETUP response should contain timeout and client should use it to keep-alive the connection.
  3. Client should call the RTSP server using any RTSP method or send RTCP RR. The recommended meethod is to send RTSP SET_PARAMETER request.
jr.root.cs
  • 185
  • 1
  • 15