cURL / Mailing Lists / curl-library / Single Mail

curl-library

libcurl don't write data directly (internal buffering?)

From: Eric Beuque <eric.beuque_at_gmail.com>
Date: Thu, 27 Sep 2012 16:41:38 +0200

Hi,

I have a problem with libcurl.

I'm using libcurl to get video frame from an MJPEG stream given by an IP
camera which is a infinite sequence of JPEG frame within a multipart http
response.

It has the following reponse format:

HTTP/1.0 200
Expires: Thu, 1 Jan 1998 00:00:00 GMT
Content-type: multipart/x-mixed-replace; boundary=myboundary

--myboundary
Content-type: image/jpeg

JPEG IMAGE STREAM GOES HERE
--myboundary
Content-type: image/jpeg

JPEG IMAGE STREAM GOES HERE

--myboundary--

The problem is that the write callback is not called as soon as the data
are received. I saw that sometime around 7 frames can be cached before i i
got the first write function call.
The unexpected effect is that if image processing takes too much time (for
example one second), for the next frame, i will get a cached picture
instead of the current from the device. I that case, if i disconnect my
camera, i will receive frames during 6-7 seconds.
In fact, what i want is to be able to get a frame from libcurl, pause
libcurl during i process the frame, and resume curl to get a new frame,
which will be up-to-date in the MJPEG stream. I want to get the data as
soon are they are transmitted by the device.
Note that one image is around 75 Kb which is bigger that the
CURL_MAX_WRITE_SIZE.

Why libcurl is caching some data? Is it a libcurl or TCP problem? How can I
force to received the data quickly, or tell curl to don't received more
data until i didn't process the previous?

Thank for you help.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-09-27