Commit Graph

19 Commits

Author SHA1 Message Date
Max Kellermann
a8f69429b0 input_curl: don't fail when seek to EOF is requested
HTTP servers respond with "416 Requested Range Not Satisfiable" when a
client attempts to seek to the end of the file.  Catch this special
case in input_curl_seek().  This fixes a glitch in the ogg vorbis
decoder plugin.
2008-11-20 12:45:17 +01:00
Max Kellermann
a0dd5b7f2f curl: don't check running_handles for EOF
Since we are using curl_multi_info_read() / CURLMSG_DONE for detecting
end-of-response, we can remove all running_handles==0 checks.  For
some reason, that has never worked correctly.
2008-11-20 12:42:42 +01:00
Max Kellermann
f61904db33 input_curl: always set eof=true on CURLMSG_DONE
curl_multi_info_read() is the authoritative source of the
"end-of-response" information.  Always set c->eof when a CURLMSG_DONE
message is received, and check the result (success/failure) after
that.
2008-11-20 12:41:59 +01:00
Max Kellermann
7591403566 input_stream: size==-1 means unknown size
Define the special value "-1" as "unknown size".  Previously, there
was no indicator for streams with unknown size, which might confuse
some decoders.
2008-11-16 20:42:08 +01:00
Max Kellermann
dcfb205c46 input_curl: retrieve error message from ERRORBUFFER
libcurl provides better error messages than curl_multi_strerror() when
you set the ERRORBUFFER option.
2008-11-06 06:48:30 +01:00
Max Kellermann
e2d7318a18 input_curl: return 0 on error from read()
The read() method must not return a negative value.  Make it return 0
on error, just like the file input stream.  Also set the "error"
attribute to -1.
2008-11-06 06:44:19 +01:00
Max Kellermann
a8e81326d0 input_curl: enable FAILONERROR
I had this option enabled during development, but at some point, it
must have gotten lost.  FAILONERROR makes the curl stream fail when
the server returns a status code 400 or higher.  We are not interested
in the server's error document.
2008-11-06 06:36:25 +01:00
Max Kellermann
75d2a39768 input_curl: use curl_multi_info_read()
The function curl_multi_info_read() provides access to errors from the
curl easy interface.
2008-11-03 21:49:43 +01:00
Max Kellermann
460b15d29c input_curl: buffered rewinding
During codec detection, the beginning of the stream is consumed.  This
is a common operation, which takes a lot of time when handling remote
resources.  To optimize this, remember the first 64 kB of a stream.
This way, we can rewind the stream without actually fetching the start
of the stream again.
2008-11-02 17:06:15 +01:00
Max Kellermann
0a61877702 input_stream: convert offset and size to the off_t data type
size_t and long aren't 64 bit safe (i.e. files larger than 2 GB on a
32 bit OS).  Use off_t instead, which is a 64 bit integer if compiled
with large file support.
2008-10-28 20:39:09 +01:00
Max Kellermann
0d30d51f07 input_file, input_curl: check URL type before attempting to open
Don't attempt to open a HTTP URL as a local file, and don't send a
local path to libcurl.
2008-10-27 10:10:24 +01:00
Max Kellermann
5f2384001e curl: read stream name from HTTP response headers
If the server sends the headers "icy-name", "ice-name",
"x-audiocast-name", set the stream title.
2008-10-26 21:20:02 +01:00
Max Kellermann
5d9ef0cd83 input_curl: set input_stream.mime from Content-Type response header 2008-10-26 21:19:32 +01:00
Max Kellermann
1437a56a11 input_curl: added local variable "value"
Replaced the local variable "colon" (which had only temporary meaning)
with the variable "value".  It is a pointer to the first byte of the
header value.
2008-10-26 21:12:56 +01:00
Max Kellermann
5c19776f2f input_stream: use "bool" instead of "int"
For boolean values and success flags, use bool instead of integer (1/0
for true/false, 0/-1 for success/failure).
2008-10-26 20:56:46 +01:00
Max Kellermann
464b611772 input_stream: input_stream_close() returns void
close() shouldn't fail with read-only streams.
2008-10-26 20:54:52 +01:00
Max Kellermann
f08041f0eb input_stream: added struct input_plugin
Instead of managing a set of method pointers in each input_stream
struct, move these into the new input_plugin struct.  Each
input_stream has only a pointer to the plugin struct.  Pointers to all
implementations are kept in the array "input_plugins".
2008-10-26 20:38:44 +01:00
Max Kellermann
bbaedb17d5 input_stream: renamed sources, no CamelCase
Renamed inputStream.c and inputStream_file.c.
2008-10-26 19:38:50 +01:00
Max Kellermann
3609de8685 http: use libcurl
MPD's HTTP client code has always been broken, no matter how effort
was put into fixing it.  Replace it with libcurl, which is known to be
quite stable.  This adds a fat library dependency, but only for people
who need streaming.
2008-10-26 19:32:43 +01:00