cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Help required to understand CURL for read data

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, 31 Jul 2013 09:06:02 +0200

On Wed, Jul 31, 2013 at 10:50:56AM +0530, Santhosh Kumar wrote:
> I am very new to curl. I am using ffmpeg custom IO Call backs for playing AV
> Streams, in those IO Callbacks, I need to fetch data based on ffmpeg request(
> Like size and memory will provide by ffmpeg).
>
> From examples and Apis of curl, i couldnt see any CURL function or API does
> this functionality(I might have over looked also).
> So if any one knows, can you help me?

There are a few techniques you could use. The one in docs/examples/fopen.c
might be the most straightforward one to adapt for this. That example is
a wrapper around curl that provides a stdio-like interface to network
resources. You would use url_fopen() to start the transfer, then have ffmpeg
call url_fread() every time it needs more data.

> Assume: connection with server established already.

That makes things trickier. If ffmpeg is already opening the socket, you'll
have to use the CURLOPT_OPENSOCKETFUNCTION callback to pass that socket into
libcurl. But if ffmpeg already does some operations on that socket it might be
difficult, as libcurl assumes that the socket it's provided hasn't had any
protocol traffic over it already.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-07-31