CURLOPT_INTERLEAVEDATA(3)

CURLOPT_INTERLEAVEDATA πŸ’…

okay bestie, so this is a page from the libcurl manual β€” the library functions manual, to be exact β€” and it's all about CURLOPT_INTERLEAVEDATA, which is genuinely one of those tiny options that makes the whole RTSP thing work. no cap. let's get into it πŸŽ€


✨ NAME ✨

CURLOPT_INTERLEAVEDATA β€” the pointer that gets passed to the RTSP interleave callback, periodt.


🌸 SYNOPSIS 🌸

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERLEAVEDATA, void *pointer);

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: this is the userdata pointer that gets handed over to CURLOPT_INTERLEAVEFUNCTION(3) whenever interleaved RTP data shows up. like, it's the little bag of stuff you get to carry into your callback. πŸ’–

and lowkey important: if you never set the interleave function callback, this pointer literally isn't used anywhere. it just sits there. main character energy with no scene to be in, honestly. 😭


⭐ DEFAULT ⭐

NULL


🌈 PROTOCOLS 🌈

this functionality affects rtsp only. iykyk. 🫢


πŸ”₯ EXAMPLE πŸ”₯

here's the whole little program, copied exactly so you can steal it:

struct local {
  void *custom;
};
static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *userp)
{
  struct local *l = userp;
  printf("my pointer: %p\n", l->custom);
  /* take care of the packet in 'ptr', then return... */
  return size * nmemb;
}

int main(void)
{
  struct local rtp_data;
  CURL *curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
    curl_easy_setopt(curl, CURLOPT_INTERLEAVEDATA, &rtp_data);

    curl_easy_perform(curl);
  }
}

πŸ’œ AVAILABILITY πŸ’œ

added in curl 7.20.0 β€” vintage, but iconic. πŸ‘‘


✨ RETURN VALUE ✨

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

CURLE_OK (0) means everything was OK β€” slay β€” and non-zero means an error occurred, so go check libcurl-errors(3) for what went wrong. πŸ’€


πŸŽ€ SEE ALSO πŸŽ€


fr fr bestie, don't set CURLOPT_INTERLEAVEDATA without CURLOPT_INTERLEAVEFUNCTION β€” the page says the pointer isn't used anywhere if the callback isn't set. that's just facts. πŸ™ˆ

okay that's the whole page, hope your RTSP journey is cute and your packets are interleaved beautifully πŸŒΈπŸ’…

this libcurl page is dated 2026-10-12 and comes from the libcurl source β€” bye bestie, mwah! πŸ’–πŸ¦‹

πŸ“¦ where this page comes from