1CURLOPT_INTERLEAVEFUNCTION(3c)url_easy_setopt optionCsURLOPT_INTERLEAVEFUNCTION(3)
2
3
4
6 CURLOPT_INTERLEAVEFUNCTION - callback for RTSP interleaved data
7
9 #include <curl/curl.h>
10
11 size_t interleave_callback(void *ptr, size_t size, size_t nmemb,
12 void *userdata);
13
14 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERLEAVEFUNCTION,
15 interleave_callback);
16
18 Pass a pointer to your callback function, which should match the proto‐
19 type shown above.
20
21 This callback function gets called by libcurl as soon as it has re‐
22 ceived interleaved RTP data. This function gets called for each $ block
23 and therefore contains exactly one upper-layer protocol unit (e.g. one
24 RTP packet). Curl writes the interleaved header as well as the included
25 data for each call. The first byte is always an ASCII dollar sign. The
26 dollar sign is followed by a one byte channel identifier and then a 2
27 byte integer length in network byte order. See RFC2326 Section 10.12
28 for more information on how RTP interleaving behaves. If unset or set
29 to NULL, curl will use the default write function.
30
31 Interleaved RTP poses some challenges for the client application. Since
32 the stream data is sharing the RTSP control connection, it is critical
33 to service the RTP in a timely fashion. If the RTP data is not handled
34 quickly, subsequent response processing may become unreasonably delayed
35 and the connection may close. The application may use CURL_RTSPREQ_RE‐
36 CEIVE to service RTP data when no requests are desired. If the applica‐
37 tion makes a request, (e.g. CURL_RTSPREQ_PAUSE) then the response han‐
38 dler will process any pending RTP data before marking the request as
39 finished.
40
41 The CURLOPT_INTERLEAVEDATA(3) is passed in the userdata argument in the
42 callback.
43
44 Your callback should return the number of bytes actually taken care of.
45 If that amount differs from the amount passed to your callback func‐
46 tion, it will signal an error condition to the library. This will cause
47 the transfer to get aborted and the libcurl function used will return
48 CURLE_WRITE_ERROR.
49
50 You can also abort the transfer by returning CURL_WRITEFUNC_ERROR.
51 (7.87.0)
52
54 NULL, the interleave data is then passed to the regular write function:
55 CURLOPT_WRITEFUNCTION(3).
56
58 RTSP
59
61 static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *user)
62 {
63 struct local *l = (struct local *)user;
64 /* take care of the packet in 'ptr', then return... */
65 return size * nmemb;
66 }
67 {
68 struct local rtp_data;
69 curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
70 curl_easy_setopt(curl, CURLOPT_INTERLEAVEDATA, &rtp_data);
71 }
72
74 Added in 7.20.0
75
77 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
78 if not.
79
81 CURLOPT_INTERLEAVEDATA(3), CURLOPT_RTSP_REQUEST(3),
82
83
84
85libcurl 8.0.1 January 02, 2023 CURLOPT_INTERLEAVEFUNCTION(3)