curl / Mailing Lists / curl-users / Single Mail

curl-users

Re: libcurl - sample code for multiple out of order range requests from same url

From: Steve Williams <steve_at_advance-software.com>
Date: Thu, 27 Jul 2017 12:57:27 +0100

To reply to my own query - have worked this a little further & figured
out how to determine the range a write callback refers to - by adding a
header callback and pulling the information from the relevant header line.

Current issue is getting http range requests to do what I want. Seems
the spec allows servers to second guess and deliver more than was
requested which is *so* annoying. Almost annoying enough to drop back to
sockets and write my own protocol that delivers what I actually asked for :)

Any insight into how to get range requests to perform more
deterministically would be appreciated.

Had a quick look at http/2 - doesn't seem this has changed but not far
enough into it yet to know for sure. Clarification welcome.

Maybe rtsp would act more deterministically. Active R&D on my part but
quite possibly all solved problems for those with more experience.

Thanks for the API. Much appreciated.

Reason I need to perform range requests : streaming some mp4 files
requires seeks throughout the file prior to being able to play and I
want to be able to do this as efficiently as possible.

Best regards,
Steve.

On 25/07/17 19:45, Steve Williams wrote:
> Hi guys,
>
> I'm fairly new to libcurl. I need to be able to make multiple out
> of order http get range requests to a file.
>
> I understand the server won't necessarily deliver ranges as requested,
> but that's what I need.
>
> I took a look at the 10 at a time example.
>
> https://curl.haxx.se/libcurl/c/10-at-a-time.html
>
> What I'd like is something like that but 10 ranges of the same file as
> a test.
>
> First question :
>
> 1. The callback seems to lack sufficient parameters to understand what
> I'm getting.
> *static* size_t*cb*(*char* *d, size_t n, size_t l,*void* *p) { ... }
>
> It contains no offset so I don't know what range this chunk represents.
> The data wasn't requested sequentially and there will be gaps so you won't be able to munge it internally into sequential order.
>
> I dropped in a seek callback and that's not getting hit so I can't figure it out that way.
>
>
> 2. Not sure how to keep session open over multiple requests.
>
> The*init*() function in 10-at-a-time shows how to send off a request and I can extend that to add a range.
>
> I don't want to have to specify a url each time as it's the same session. Do you infer that internally if I give you the same url pointer ?
>
>
> Insight, advice welcome.
>
> Thanks :)
>
>
> Best regards,
> Steve.
>
>
>
>
>
> -----------------------------------------------------------
> Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
> Etiquette: https://curl.haxx.se/mail/etiquette.html

-- 
Best regards,

-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-07-27