curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Missing data fragments when custom headers set

From: Dirk Brinkmeier via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 25 Nov 2019 09:53:36 +0100 (CET)

On 11/24/2019 6:42 AM, Firefox OS via curl-library wrote:
>> Dnia 2019-11-24, o godz. 10:21:07
>> tangram67 via curl-library<curl-library_at_cool.haxx.se> napisał(a):
>>
>>> Hi to all.
>>>
>>> I'm using libcurl as a receiver for MP3 radio streams.
>>> When using custom headers in conjunction with header and body data
>>> callbacks, some data is missing in the data callbacks. This is also
>>> reproducable when using the following command line:
>>>
>>> curl --header "Icy-MetaData: 1" -sD - -o ./ndr1.mp3
>>> http://ndr-edge-2061.dus-lg.cdn.addradio.net/ndr/ndr1niedersachsen/hannover/mp3/128/stream.mp3
>>>
>>> If you play the resulting MP3 file with some kind of media player you
>>> can hear dropdowns caused by missing data. If you remove the custom
>>> header, then the stream is OK. Also this behaviour is independant of the
>>> header value, so any header string will cause the problem.
>>>
>> Hi Dirk,
>>
>> What makes you think the dropdowns are caused by missing data?
>>
>> You requested the server to multiplex metadata with the MP3 stream.
>> You can't send such a stream directly to MP3 decoder. Instead,
>> your client needs to extract "icy-metaint:" response header and demux
>> the stream appropriately (extract the metadata instead of sending
>> them to MP3 decoder). Otherwise you're periodically feeding the decoder
>> with garbage.
>>
>> Please cross-check your results with a client which doesn't use libcurl, e.g.
>> wget -S --header "Icy-MetaData: 1" -O ndr2.mp3http://ndr-edge-2061.dus-lg.cdn.addradio.net/ndr/ndr1niedersachsen/hannover/mp3/128/stream.mp3
>
>For demux explanation check out https://stackoverflow.com/a/44090879 so
>it is possible, but I'd only do it if you have to.
>

Sorry, I've had a problem with the mail alias I used for the mailing list.
So I try to answer with a new mail:

Checking against wget produced the same (wrong) result.

My application parsed out the full "StreamTitle" content, regardless of the "icy-metaint" header value, just by searching each chunk of for the string "StreamTitle", reading the length byte and then cut the data from the stream.

An here lies the problem:
The ICY metadata is stuffed in the MP3 stream regularl basis as given by the “icy-metaint” value. And this is done even if there is no Metadata sent by the server. In this case the length byte is 0. But this single byte has also be extracted from the MP3 stream and then you are good.

Thanks for the hints, even if it was not a problem of cURL ;-)

Regards,
Dirk.

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-11-25