CURLOPT_RTSP_REQUEST(3)

πŸ’… CURLOPT_RTSP_REQUEST(3) β€” RTSP request, but make it make sense

Okay bestie, so this one's from the Library Functions Manual, and it's literally about telling libcurl which RTSP request you wanna make. RTSP girlies rise πŸŽ€


✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_REQUEST, long request);

🌸 DESCRIPTION 🌸

So basically, you're telling libcurl what kind of RTSP request to make. You pass one of the RTSP enum values below as a long in the request argument, and that's it, that's the whole vibe πŸ’–

Heads up bestie: unless it says otherwise, these commands need the Session ID to be initialized first. No session ID, no party πŸ™ˆ
  • CURL_RTSPREQ_OPTIONS β€” this one grabs the available methods of the server. Your app is the one responsible for parsing and obeying the response, so like, don't @ libcurl for that. Also the session ID is not needed for this method ✨
  • CURL_RTSPREQ_DESCRIBE β€” gets the low level description of a stream. Your app should note what formats it understands in the 'Accept:' header. Unless you set it manually, libcurl automatically adds in 'Accept: application/sdp'. Oh and Time-condition headers get added to Describe requests if you're using the CURLOPT_TIMECONDITION(3) option. (The session ID is not needed for this method 🫢)
  • CURL_RTSPREQ_ANNOUNCE β€” when a client sends this, the method changes the description of the session. Like, say a client is using the server to record a meeting β€” the client can use Announce to inform the server of all the meta-information about the session. ANNOUNCE acts like an HTTP PUT or POST, just like CURL_RTSPREQ_SET_PARAMETER πŸ’…
  • CURL_RTSPREQ_SETUP β€” Setup initializes the transport layer for the session. Your app must set the desired Transport options for a session using the CURLOPT_RTSP_TRANSPORT(3) option prior to calling setup (order matters, bestie, it's giving prerequisites 😭). If no session ID is currently set with CURLOPT_RTSP_SESSION_ID(3), libcurl extracts and uses the session ID in the response to this request. The session ID is not needed for this method.
  • CURL_RTSPREQ_PLAY β€” sends a Play command to the server. Use the CURLOPT_RANGE(3) option to modify the playback time (e.g. npt=10-15) ⭐
  • CURL_RTSPREQ_PAUSE β€” sends a Pause command to the server. Use the CURLOPT_RANGE(3) option with a single value to indicate when the stream should be halted. (e.g. npt=25)
  • CURL_RTSPREQ_TEARDOWN β€” this command terminates an RTSP session. And ngl, simply closing a connection does not terminate the RTSP session, because it is valid to control an RTSP session over different connections. So yeah, you actually gotta send this one πŸ’€
  • CURL_RTSPREQ_GET_PARAMETER β€” retrieves a parameter from the server. By default, libcurl adds a Content-Type: text/parameters header on all non-empty requests unless a custom one is set. GET_PARAMETER acts just like an HTTP PUT or POST (see CURL_RTSPREQ_SET_PARAMETER). Applications wishing to send a heartbeat message (e.g. in the presence of a server-specified timeout) should use an empty GET_PARAMETER request 🩷
  • CURL_RTSPREQ_SET_PARAMETER β€” sets a parameter on the server. By default, libcurl uses a Content-Type: text/parameters header unless a custom one is set. The interaction with SET_PARAMETER is much like an HTTP PUT or POST. An application may either use CURLOPT_UPLOAD(3) with CURLOPT_READDATA(3) like an HTTP PUT, or it may use CURLOPT_POSTFIELDS(3) like an HTTP POST. No chunked transfers are allowed, so the application must set the CURLOPT_INFILESIZE(3) in the former and CURLOPT_POSTFIELDSIZE(3) in the latter. Also, there is no use of multi-part POSTs within RTSP β€” just so we're clear 🧚
  • CURL_RTSPREQ_RECORD β€” tells the server to record a session. Use the CURLOPT_RANGE(3) option to modify the record time πŸ‘‘
  • CURL_RTSPREQ_RECEIVE β€” this one's special because it does not send any data to the server. The application may call this function in order to receive interleaved RTP data. It returns after processing one read buffer of data, so the application gets a chance to run. Main character energy: it hits pause on itself so you can go πŸ¦‹

πŸŽ€ DEFAULT πŸŽ€

(The original page leaves this section empty β€” so like, nothing documented here, no cap.)


🌈 PROTOCOLS 🌈

This functionality affects rtsp only. RTSP exclusive, iykyk πŸ’œ


πŸ”₯ EXAMPLE πŸ”₯

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/");
    /* ask for options */
    curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}

Literal copy-paste-and-slay, bestie ✨


πŸ¦‹ HISTORY πŸ¦‹

CURL_RTSPREQ_* enums became long types in 8.13.0. Prior to this version, a long cast was necessary when passed to curl_easy_setopt(3). So if you're on old curl, cast it, don't fight it πŸ™ˆ


⭐ AVAILABILITY ⭐

Added in curl 7.20.0 πŸ’–


πŸ’œ RETURN VALUE πŸ’œ

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK. Non-zero means an error occurred β€” see libcurl-errors(3) for the whole lore drop 😭


πŸ‘‘ SEE ALSO πŸ‘‘


Okay that's the whole page, go be iconic with your RTSP requests πŸ’…βœ¨ This was libcurl, dated 2026-10-12, signing off β€” mwah πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from