Artifactspublic-v0

curl

master
ply4 git calls28 ms288 KiB3 cachedprotocol v2
104 lines3.1 KiBRaw

NAME

CURLOPT_INTERLEAVEFUNCTION - callback for RTSP interleaved data

SYNOPSIS

c
#include <curl/curl.h>

size_t interleave_callback(void *ptr, size_t size, size_t nmemb,
                           void *userdata);

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERLEAVEFUNCTION,
                          interleave_callback);

DESCRIPTION

Pass a pointer to your callback function, which should match the prototype shown above.

This callback function gets called by libcurl as soon as it has received interleaved RTP data. This function gets called for each $ block and therefore contains exactly one upper-layer protocol unit (e.g. one RTP packet). curl writes the interleaved header as well as the included data for each call. The first byte is always an ASCII dollar sign. The dollar sign is followed by a one-byte channel identifier and then a 2-byte integer length in network byte order. See RFC 2326 Section 10.12 for more information on how RTP interleaving behaves. If unset or set to NULL, curl uses the default write function.

Interleaved RTP poses some challenges for the client application. Since the stream data is sharing the RTSP control connection, it is critical to service the RTP in a timely fashion. If the RTP data is not handled quickly, subsequent response processing may become unreasonably delayed and the connection may close. The application may use CURL_RTSPREQ_RECEIVE to service RTP data when no requests are desired. If the application makes a request, (e.g. CURL_RTSPREQ_PAUSE) then the response handler processes any pending RTP data before marking the request as finished.

The CURLOPT_INTERLEAVEDATA(3) is passed in the userdata argument in the callback.

Your callback should return the number of bytes actually taken care of. If that amount differs from the amount passed to your callback function, it signals an error condition to the library. This causes the transfer to abort and the libcurl function used returns CURLE_WRITE_ERROR.

You can also abort the transfer by returning CURL_WRITEFUNC_ERROR. (7.87.0)

DEFAULT

NULL, the interleave data is then passed to the regular write function: CURLOPT_WRITEFUNCTION(3).

%PROTOCOLS%

EXAMPLE

c
struct local {
  void *custom;
};

static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *userp)
{
  struct local *l = userp;
  printf("our ptr: %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);
  }
}

%AVAILABILITY%

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).

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_INTERLEAVEFUNCTION
5Section: 3
6Source: libcurl
7See-also:
8 - CURLOPT_INTERLEAVEDATA (3)
9 - CURLOPT_RTSP_REQUEST (3)
10Protocol:
11 - RTSP
12Added-in: 7.20.0
13---
15# NAME
17CURLOPT_INTERLEAVEFUNCTION - callback for RTSP interleaved data
19# SYNOPSIS
21~~~c
22#include <curl/curl.h>
24size_t interleave_callback(void *ptr, size_t size, size_t nmemb,
25 void *userdata);
27CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERLEAVEFUNCTION,
28 interleave_callback);
29~~~
31# DESCRIPTION
33Pass a pointer to your callback function, which should match the prototype
34shown above.
36This callback function gets called by libcurl as soon as it has received
37interleaved RTP data. This function gets called for each $ block and therefore
38contains exactly one upper-layer protocol unit (e.g. one RTP packet). curl
39writes the interleaved header as well as the included data for each call. The
40first byte is always an ASCII dollar sign. The dollar sign is followed by a
41one-byte channel identifier and then a 2-byte integer length in network byte
42order. See RFC 2326 Section 10.12 for more information on how RTP interleaving
43behaves. If unset or set to NULL, curl uses the default write function.
45Interleaved RTP poses some challenges for the client application. Since the
46stream data is sharing the RTSP control connection, it is critical to service
47the RTP in a timely fashion. If the RTP data is not handled quickly,
48subsequent response processing may become unreasonably delayed and the
49connection may close. The application may use *CURL_RTSPREQ_RECEIVE* to
50service RTP data when no requests are desired. If the application makes a
51request, (e.g. *CURL_RTSPREQ_PAUSE*) then the response handler processes
52any pending RTP data before marking the request as finished.
54The CURLOPT_INTERLEAVEDATA(3) is passed in the *userdata* argument in
55the callback.
57Your callback should return the number of bytes actually taken care of. If
58that amount differs from the amount passed to your callback function, it
59signals an error condition to the library. This causes the transfer to abort
60and the libcurl function used returns *CURLE_WRITE_ERROR*.
62You can also abort the transfer by returning CURL_WRITEFUNC_ERROR. (7.87.0)
64# DEFAULT
66NULL, the interleave data is then passed to the regular write function:
67CURLOPT_WRITEFUNCTION(3).
69# %PROTOCOLS%
71# EXAMPLE
73~~~c
74struct local {
75 void *custom;
76};
78static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *userp)
80 struct local *l = userp;
81 printf("our ptr: %p\n", l->custom);
82 /* take care of the packet in 'ptr', then return... */
83 return size * nmemb;
86int main(void)
88 struct local rtp_data;
89 CURL *curl = curl_easy_init();
90 if(curl) {
91 curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
92 curl_easy_setopt(curl, CURLOPT_INTERLEAVEDATA, &rtp_data);
93 }
95~~~
97# %AVAILABILITY%
99# RETURN VALUE
101curl_easy_setopt(3) returns a CURLcode indicating success or error.
103CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
104libcurl-errors(3).
Diagnostics4 git calls · 28 ms
CallStatusSizeTime028 ms
discover200152 B4 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=20
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2001.6 KiB · hit21 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1618
git.response.cache=HIT
git.response.duration_ms=21
git.fetch.wants=8cfe40406d010e1a482a174a642969341c5ec7f0
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1618
git.pkt.payload.max=1597
git.sideband.band1.bytes=1596
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e3137a4c3e3e6e
Request
d42313b4…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format