Mercurial > audlegacy-plugins
annotate src/curl/curl.c @ 501:1b06f6690022 trunk
[svn] - ssl support (no idea why, but hey, we can!)
author | nenolod |
---|---|
date | Sun, 21 Jan 2007 21:01:41 -0800 |
parents | 1d81ea250dce |
children | f665e3a6dad7 |
rev | line source |
---|---|
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
1 /* Audacious |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
2 * Copyright (c) 2007 Daniel Barkalow |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
3 * |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
7 * (at your option) any later version. |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
8 * |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
13 * |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
15 * along with this program; if not, write to the Free Software |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
17 */ |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
18 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
19 #include <audacious/vfs.h> |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
20 #include <audacious/plugin.h> |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
21 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
22 #include <curl/curl.h> |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
23 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
24 #include <string.h> |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
25 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
26 #define BUFFER_SIZE 256 * 1024 |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
27 #define REVERSE_SEEK_SIZE 2048 |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
28 |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
29 #define DEBUG_CONNECTION 0 |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
30 #define DEBUG_OPEN_CLOSE 0 |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
31 #define DEBUG_SEEK 0 |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
32 #define DEBUG_READ 0 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
33 #define DEBUG_HEADERS 0 |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
34 #define DEBUG_ICY 0 |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
35 #define DEBUG_ICY_VERBOSE 0 |
485 | 36 #define DEBUG_METADATA_REPORT 0 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
37 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
38 typedef struct _CurlHandle CurlHandle; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
39 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
40 struct _CurlHandle { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
41 CURL *curl; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
42 |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
43 gssize length; // the length of the file |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
44 gsize rd_abs; // the absolute position for reading from the stream |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
45 gsize wr_abs; // the absolute position where the input connection is |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
46 |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
47 gsize icy_left; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
48 gsize icy_interval; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
49 gint in_icy_meta; // 0=no, 1=before size, 2=in data |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
50 gsize meta_abs; // the absolute position where the metadata changes |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
51 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
52 gsize buffer_length; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
53 gchar *buffer; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
54 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
55 gsize rd_index; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
56 gsize wr_index; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
57 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
58 gsize hdr_index; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
59 |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
60 gboolean header; // true if we haven't finished the header yet |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
61 gboolean no_data; // true if we're only looking for length currently |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
62 gboolean cancel; // true if the thread should be cancelled |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
63 gboolean failed; // true if we've tried and failed already |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
64 GThread *thread; // the thread that's reading from the connection |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
65 |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
66 gchar *name; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
67 gchar *title; |
494 | 68 |
69 GSList *charstack; // getc/ungetc emulation --nenolod | |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
70 }; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
71 |
483 | 72 VFSConstructor curl_const; |
73 | |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
74 /* TODO: |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
75 * - Fix hang if the server closes the connection in the middle |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
76 * - Clever buffer stuff when you read a bit of the beginning and a bit of the |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
77 * end of a file |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
78 */ |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
79 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
80 /* The goal here is to have a buffering system which handles the following: |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
81 * 1) open, seek, read (without fetching the beginning of the file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
82 * 2) open, seek END, tell (using HEAD only) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
83 * 3) open, read, seek 0, read (without restarting fetch) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
84 */ |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
85 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
86 static size_t buf_space(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
87 { |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
88 size_t rd_edge = handle->rd_abs - REVERSE_SEEK_SIZE; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
89 size_t buffer_limit; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
90 size_t cont_limit; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
91 if (rd_edge < 0) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
92 rd_edge = 0; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
93 buffer_limit = handle->buffer_length - |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
94 (handle->wr_abs - rd_edge); |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
95 cont_limit = handle->buffer_length - handle->wr_index; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
96 if (cont_limit < buffer_limit) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
97 buffer_limit = cont_limit; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
98 if (handle->icy_interval) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
99 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
100 if (handle->icy_left < buffer_limit) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
101 buffer_limit = handle->icy_left; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
102 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
103 return buffer_limit; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
104 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
105 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
106 static size_t buf_available(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
107 { |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
108 size_t buffer_limit; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
109 size_t cont_limit; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
110 if (handle->header) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
111 return 0; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
112 buffer_limit = handle->wr_abs - handle->rd_abs; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
113 cont_limit = handle->buffer_length - handle->rd_index; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
114 if (buffer_limit <= 0) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
115 return 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
116 return buffer_limit < cont_limit ? buffer_limit : cont_limit; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
117 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
118 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
119 static void check(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
120 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
121 if (!((handle->wr_abs - handle->wr_index) % handle->buffer_length == |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
122 (handle->rd_abs - handle->rd_index) % handle->buffer_length)) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
123 printf("%p Not aligned! wr %d rd %d\n", handle, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
124 (handle->wr_abs - handle->wr_index) % handle->buffer_length, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
125 (handle->rd_abs - handle->rd_index) % handle->buffer_length); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
126 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
127 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
128 static void update_length(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
129 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
130 if (handle->length == -1) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
131 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
132 double value; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
133 int retcode = |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
134 curl_easy_getinfo(handle->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
135 &value); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
136 if (retcode == CURLE_OK) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
137 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
138 handle->length = value; |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
139 if (handle->length == 0) |
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
140 handle->length = -2; |
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
141 //g_print("Length: %d\n", handle->length); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
142 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
143 else |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
144 { |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
145 handle->length = -2; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
146 g_print("getinfo gave error\n"); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
147 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
148 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
149 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
150 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
151 #define PROBE 262140 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
152 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
153 #define ICY_NAME "icy-name:" |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
154 #define ICY_METAINT "icy-metaint:" |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
155 |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
156 static gboolean match_header(CurlHandle *handle, size_t size, |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
157 const char *header) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
158 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
159 if (strlen(header) > size) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
160 return FALSE; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
161 // XXXX wrapped headers |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
162 return !(strncmp(handle->buffer + handle->hdr_index, |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
163 header, strlen(header))); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
164 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
165 |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
166 static gchar *get_value(CurlHandle *handle, size_t size, const char *header) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
167 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
168 // XXXX wrapped headers |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
169 return strdup(handle->buffer + |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
170 (handle->hdr_index + strlen(header)) % handle->buffer_length); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
171 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
172 |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
173 static void got_header(CurlHandle *handle, size_t size) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
174 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
175 if (DEBUG_HEADERS) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
176 g_print("Got header %d bytes\n", size); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
177 if (match_header(handle, size, ICY_NAME)) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
178 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
179 handle->name = get_value(handle, size, ICY_NAME); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
180 if (DEBUG_HEADERS) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
181 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
182 g_print("Stream name: %s\n", handle->name); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
183 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
184 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
185 if (match_header(handle, size, ICY_METAINT)) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
186 { |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
187 gchar *value = get_value(handle, size, ICY_METAINT); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
188 handle->icy_interval = atoi(value); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
189 free(value); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
190 if (DEBUG_HEADERS) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
191 g_print("Metadata interval: %d\n", handle->icy_interval); |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
192 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
193 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
194 |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
195 #define TITLE_INLINE "StreamTitle=" |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
196 |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
197 static gboolean match_inline(CurlHandle *handle, size_t posn, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
198 const char *name) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
199 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
200 // XXXX Wrapped |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
201 return (!strncmp(handle->buffer + posn, name, strlen(name))); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
202 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
203 |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
204 static gchar *get_inline_value(CurlHandle *handle, size_t posn, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
205 const char *name) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
206 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
207 // XXXX Wrapped |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
208 size_t end; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
209 size_t sz; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
210 gchar *ret; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
211 posn += strlen(name); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
212 end = posn + 1; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
213 while (handle->buffer[end] != ';') |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
214 end++; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
215 sz = end - posn - 1; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
216 ret = g_malloc(sz); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
217 memcpy(ret, handle->buffer + posn + 1, sz); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
218 ret[sz - 1] = '\0'; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
219 return ret; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
220 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
221 |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
222 static void got_inline_metadata(CurlHandle *handle) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
223 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
224 size_t i = (handle->hdr_index + 1) % handle->buffer_length; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
225 if (match_inline(handle, i, TITLE_INLINE)) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
226 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
227 handle->title = get_inline_value(handle, i, TITLE_INLINE); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
228 if (DEBUG_ICY) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
229 g_print("Title: '%s'\n", handle->title); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
230 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
231 handle->meta_abs = handle->wr_abs; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
232 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
233 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
234 static size_t curl_writecb(void *ptr, size_t size, size_t nmemb, void *stream) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
235 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
236 CurlHandle *handle = stream; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
237 gint sz = size * nmemb; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
238 gint ret = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
239 gint trans; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
240 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
241 if (!handle->header) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
242 update_length(handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
243 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
244 while (ret < sz) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
245 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
246 while (!(trans = buf_space(handle)) && !handle->cancel) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
247 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
248 g_usleep(10000); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
249 //g_print("Wait for free space\n"); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
250 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
251 if (handle->cancel) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
252 break; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
253 if (trans > sz - ret) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
254 trans = sz - ret; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
255 memcpy(handle->buffer + handle->wr_index, ptr + ret, trans); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
256 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
257 if (!handle->header) |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
258 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
259 if (handle->icy_interval) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
260 handle->icy_left -= trans; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
261 if (!handle->in_icy_meta) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
262 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
263 handle->wr_abs += trans; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
264 // write download here |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
265 if (handle->icy_interval && !handle->icy_left) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
266 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
267 if (DEBUG_ICY) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
268 g_print("Metadata inline after %d\n", handle->wr_abs); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
269 handle->in_icy_meta = 1; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
270 handle->icy_left = 1; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
271 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
272 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
273 else if (handle->in_icy_meta == 1) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
274 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
275 // Track where the header insert starts |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
276 handle->hdr_index = handle->wr_index; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
277 handle->icy_left = |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
278 ((unsigned char)(handle->buffer[handle->wr_index])) * 16; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
279 if (DEBUG_ICY) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
280 g_print("Metadata of size %d\n", handle->icy_left); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
281 if (handle->icy_left) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
282 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
283 handle->in_icy_meta = 2; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
284 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
285 else |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
286 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
287 handle->in_icy_meta = 0; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
288 handle->icy_left = handle->icy_interval; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
289 handle->wr_index--; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
290 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
291 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
292 else |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
293 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
294 if (!handle->icy_left) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
295 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
296 handle->wr_index = (handle->wr_index + trans) % |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
297 handle->buffer_length; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
298 if (DEBUG_ICY_VERBOSE) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
299 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
300 if (handle->wr_index < handle->hdr_index) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
301 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
302 // wrapped |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
303 fwrite(handle->buffer + handle->hdr_index + 1, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
304 handle->buffer_length - handle->hdr_index - 1, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
305 1, stdout); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
306 fwrite(handle->buffer, handle->wr_index, 1, stdout); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
307 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
308 else |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
309 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
310 fwrite(handle->buffer + handle->hdr_index, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
311 handle->wr_index - handle->hdr_index, 1, |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
312 stdout); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
313 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
314 g_print("\n"); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
315 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
316 got_inline_metadata(handle); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
317 |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
318 // Rewind the buffer usage to write over the |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
319 // metadata with content. -trans because we're about |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
320 // to add it. |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
321 handle->wr_index = handle->hdr_index - trans; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
322 handle->in_icy_meta = 0; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
323 handle->icy_left = handle->icy_interval; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
324 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
325 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
326 } |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
327 handle->wr_index = (handle->wr_index + trans) % handle->buffer_length; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
328 ret += trans; |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
329 |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
330 if (handle->header) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
331 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
332 gsize i = handle->hdr_index; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
333 while (1) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
334 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
335 if ((i + 1) % handle->buffer_length == handle->wr_index) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
336 break; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
337 if (handle->buffer[i] == '\r' && |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
338 handle->buffer[(i + 1) % handle->buffer_length] == '\n') |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
339 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
340 gsize size = (handle->buffer_length + i - |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
341 handle->hdr_index) % handle->buffer_length; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
342 handle->buffer[i] = '\0'; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
343 got_header(handle, size); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
344 if (i == handle->hdr_index) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
345 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
346 // Empty header means the end of the headers |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
347 handle->header = 0; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
348 handle->hdr_index = (i + 2) % handle->buffer_length; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
349 // We read from the start of the data in the request |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
350 handle->rd_index = handle->hdr_index; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
351 // We've already written the amount that's after |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
352 // the header. |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
353 handle->wr_abs += |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
354 (handle->wr_index - handle->hdr_index + handle->buffer_length) % handle->buffer_length; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
355 // write download here... |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
356 //handle->icy_interval = 0; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
357 handle->icy_left = handle->icy_interval; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
358 if (handle->icy_interval) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
359 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
360 handle->icy_left -= |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
361 (handle->wr_index - handle->hdr_index + handle->buffer_length) % handle->buffer_length; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
362 } |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
363 if (DEBUG_ICY) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
364 g_print("Left %d\n", handle->icy_left); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
365 handle->in_icy_meta = 0; |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
366 break; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
367 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
368 handle->hdr_index = (i + 2) % handle->buffer_length; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
369 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
370 i = (i + 1) % handle->buffer_length; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
371 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
372 } |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
373 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
374 return ret; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
375 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
376 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
377 static gpointer |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
378 curl_manage_request(gpointer arg) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
379 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
380 CurlHandle *handle = arg; |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
381 CURLcode result; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
382 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
383 g_print("Connect %p\n", handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
384 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
385 if (handle->no_data) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
386 curl_easy_setopt(handle->curl, CURLOPT_NOBODY, 1); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
387 else |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
388 { |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
389 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
390 g_print("Start from %d\n", handle->wr_abs); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
391 curl_easy_setopt(handle->curl, CURLOPT_RESUME_FROM, handle->wr_abs); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
392 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
393 curl_easy_setopt(handle->curl, CURLOPT_NOBODY, 0); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
394 curl_easy_setopt(handle->curl, CURLOPT_HTTPGET, 1); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
395 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
396 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
397 handle->header = 1; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
398 handle->hdr_index = 0; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
399 handle->icy_interval = 0; |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
400 |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
401 result = curl_easy_perform(handle->curl); |
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
402 if (result == CURLE_OK) |
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
403 update_length(handle); |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
404 // We expect to get CURLE_WRITE_ERROR if we cancel. |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
405 // We get CURLE_GOT_NOTHING if we send a HEAD request to a shoutcast server. |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
406 // We get CURLE_HTTP_RANGE_ERROR if we try to use range with shoutcast. |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
407 if (result != CURLE_OK && result != CURLE_WRITE_ERROR && |
498
6779a84fbf10
[svn] - ignore CURLE_PARTIAL_FILE, as this can happen in some cases and is
nenolod
parents:
497
diff
changeset
|
408 result != CURLE_GOT_NOTHING && result != CURLE_HTTP_RANGE_ERROR && |
6779a84fbf10
[svn] - ignore CURLE_PARTIAL_FILE, as this can happen in some cases and is
nenolod
parents:
497
diff
changeset
|
409 result != CURLE_PARTIAL_FILE) |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
410 { |
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
411 g_print("Got curl error %d\n", result); |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
412 handle->failed = 1; |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
413 } |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
414 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
415 g_print("Done %p%s", handle, handle->cancel ? " (aborted)\n" : "\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
416 handle->cancel = 1; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
417 return NULL; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
418 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
419 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
420 static void curl_req_xfer(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
421 { |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
422 if (handle->failed) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
423 { |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
424 handle->cancel = 1; |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
425 return; |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
426 } |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
427 if (!handle->thread) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
428 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
429 handle->cancel = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
430 handle->wr_index = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
431 handle->rd_index = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
432 handle->wr_abs = handle->rd_abs; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
433 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
434 g_print("Starting connection %p at %d\n", handle, handle->wr_abs); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
435 handle->thread = g_thread_create(curl_manage_request, handle, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
436 TRUE, NULL); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
437 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
438 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
439 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
440 static void curl_req_sync_xfer(CurlHandle *handle, size_t old_rd_abs) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
441 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
442 handle->rd_index = (handle->rd_index + handle->rd_abs - old_rd_abs + |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
443 handle->buffer_length) % handle->buffer_length; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
444 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
445 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
446 static void curl_req_no_xfer(CurlHandle *handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
447 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
448 if (handle->thread) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
449 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
450 handle->cancel = 1; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
451 g_thread_join(handle->thread); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
452 handle->thread = NULL; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
453 handle->cancel = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
454 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
455 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
456 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
457 VFSFile * |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
458 curl_vfs_fopen_impl(const gchar * path, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
459 const gchar * mode) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
460 { |
500
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
498
diff
changeset
|
461 gchar *url; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
462 CurlHandle *handle; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
463 VFSFile *file; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
464 if (!path || !mode) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
465 return NULL; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
466 |
500
1d81ea250dce
[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
nenolod
parents:
498
diff
changeset
|
467 url = g_strdup(path); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
468 |
473 | 469 file = g_new0(VFSFile, 1); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
470 |
473 | 471 handle = g_new0(CurlHandle, 1); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
472 handle->curl = curl_easy_init(); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
473 handle->rd_index = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
474 handle->wr_index = 0; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
475 handle->meta_abs = 0; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
476 handle->rd_abs = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
477 handle->wr_abs = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
478 handle->buffer_length = BUFFER_SIZE; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
479 handle->buffer = g_malloc(handle->buffer_length); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
480 handle->thread = NULL; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
481 handle->length = -1; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
482 handle->cancel = 0; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
483 handle->failed = 0; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
484 handle->no_data = 0; |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
485 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
486 curl_easy_setopt(handle->curl, CURLOPT_URL, url); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
487 curl_easy_setopt(handle->curl, CURLOPT_WRITEFUNCTION, curl_writecb); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
488 curl_easy_setopt(handle->curl, CURLOPT_WRITEDATA, handle); |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
489 curl_easy_setopt(handle->curl, CURLOPT_HEADERDATA, handle); |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
490 |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
491 curl_easy_setopt(handle->curl, CURLOPT_CONNECTTIMEOUT, 10); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
492 |
501
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
493 curl_easy_setopt(handle->curl, CURLOPT_SSL_VERIFYPEER, 0); |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
494 curl_easy_setopt(handle->curl, CURLOPT_SSL_VERIFYHOST, 0); |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
495 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
496 //add header icy-metadata:1 (when we're ready for it) |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
497 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
498 struct curl_slist *hdr = NULL; |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
499 hdr = curl_slist_append(hdr, "icy-metadata:1"); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
500 curl_easy_setopt(handle->curl, CURLOPT_HTTPHEADER, hdr); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
501 } |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
502 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
503 file->handle = handle; |
483 | 504 file->base = &curl_const; |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
505 |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
506 if (DEBUG_OPEN_CLOSE) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
507 g_print("Open %s with curl => %p\n", url, handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
508 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
509 return file; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
510 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
511 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
512 gint |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
513 curl_vfs_fclose_impl(VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
514 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
515 gint ret = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
516 if (file == NULL) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
517 return -1; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
518 if (DEBUG_OPEN_CLOSE) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
519 g_print("Close %p\n", file->handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
520 if (file->handle) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
521 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
522 CurlHandle *handle = file->handle; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
523 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
524 g_print("Cancel transfer\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
525 curl_req_no_xfer(handle); |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
526 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
527 g_print("Okay\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
528 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
529 g_free(handle->buffer); |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
530 if (handle->name) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
531 g_free(handle->name); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
532 curl_easy_cleanup(handle->curl); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
533 g_free(handle); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
534 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
535 return ret; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
536 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
537 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
538 size_t |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
539 curl_vfs_fread_impl(gpointer ptr, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
540 size_t size, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
541 size_t nmemb, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
542 VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
543 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
544 CurlHandle *handle = file->handle; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
545 ssize_t sz = size * nmemb; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
546 size_t ret = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
547 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
548 if (sz < 0) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
549 return 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
550 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
551 //g_print("Reading %d*%d=%d from %p\n", size, nmemb, sz, handle); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
552 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
553 curl_req_xfer(handle); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
554 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
555 if (DEBUG_SEEK) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
556 check(handle); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
557 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
558 while (ret < sz) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
559 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
560 size_t available; |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
561 while (!(available = buf_available(handle)) && !handle->cancel) |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
562 g_usleep(10000); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
563 if (available > sz - ret) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
564 available = sz - ret; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
565 memcpy(ptr + ret, handle->buffer + handle->rd_index, available); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
566 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
567 handle->rd_index = |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
568 (handle->rd_index + available) % handle->buffer_length; |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
569 if (handle->rd_abs < handle->meta_abs && |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
570 handle->rd_abs + available >= handle->meta_abs) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
571 { |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
572 if (DEBUG_METADATA_REPORT) |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
573 g_print("New song: '%s'\n", handle->title); |
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
574 } |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
575 handle->rd_abs += available; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
576 ret += available; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
577 if (!available) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
578 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
579 //g_print("EOF reading from %p\n", handle); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
580 break; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
581 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
582 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
583 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
584 //g_print("Read %d from %p\n", ret, handle); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
585 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
586 return ret; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
587 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
588 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
589 size_t |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
590 curl_vfs_fwrite_impl(gconstpointer ptr, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
591 size_t size, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
592 size_t nmemb, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
593 VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
594 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
595 return 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
596 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
597 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
598 gint |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
599 curl_vfs_getc_impl(VFSFile *stream) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
600 { |
494 | 601 CurlHandle *handle = (CurlHandle *) stream->handle; |
495 | 602 guchar c; |
494 | 603 |
604 g_return_val_if_fail(handle != NULL, EOF); | |
605 | |
606 if (handle->charstack != NULL) | |
607 { | |
496 | 608 c = GPOINTER_TO_UINT(handle->charstack->data); |
494 | 609 handle->charstack = g_slist_delete_link(handle->charstack, handle->charstack); |
610 return c; | |
611 } | |
612 | |
495 | 613 if (curl_vfs_fread_impl(&c, 1, 1, stream)) |
614 return c; | |
615 | |
616 return EOF; | |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
617 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
618 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
619 gint |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
620 curl_vfs_ungetc_impl(gint c, VFSFile *stream) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
621 { |
494 | 622 CurlHandle *handle = (CurlHandle *) stream->handle; |
623 | |
624 g_return_val_if_fail(handle != NULL, EOF); | |
625 | |
496 | 626 handle->charstack = g_slist_prepend(handle->charstack, GUINT_TO_POINTER(c)); |
494 | 627 |
628 if (handle->charstack != NULL) | |
497
1da75c7d37a3
[svn] - decrement handle->rd_abs when we do an ungetc.
nenolod
parents:
496
diff
changeset
|
629 { |
1da75c7d37a3
[svn] - decrement handle->rd_abs when we do an ungetc.
nenolod
parents:
496
diff
changeset
|
630 handle->rd_abs--; |
494 | 631 return c; |
497
1da75c7d37a3
[svn] - decrement handle->rd_abs when we do an ungetc.
nenolod
parents:
496
diff
changeset
|
632 } |
494 | 633 |
634 /* only reached if there is an error... */ | |
635 return EOF; | |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
636 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
637 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
638 gint |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
639 curl_vfs_fseek_impl(VFSFile * file, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
640 glong offset, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
641 gint whence) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
642 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
643 size_t posn; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
644 CurlHandle *handle = file->handle; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
645 if (DEBUG_SEEK) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
646 g_print("Seek %p to %d %d\n", handle, offset, whence); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
647 if (whence == SEEK_END && handle->length == -1) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
648 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
649 if (!handle->thread) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
650 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
651 // We need a HEAD to find out the length |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
652 handle->no_data = 1; |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
653 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
654 g_print("Request for head info\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
655 curl_manage_request(handle); |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
656 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
657 g_print("Completed\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
658 handle->no_data = 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
659 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
660 else |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
661 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
662 // Wait a bit? |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
663 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
664 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
665 |
430
ed94145472df
[svn] Support shoutcast (over TCP) with VFS HTTP code. mpg123 has to accept
iabervon
parents:
428
diff
changeset
|
666 if (whence == SEEK_END && handle->length < 0) |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
667 { |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
668 if (DEBUG_SEEK) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
669 g_print("Tried to seek to the end of a file with unknown length\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
670 // don't know how long it is... |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
671 return -1; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
672 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
673 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
674 posn = handle->rd_abs; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
675 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
676 if (whence == SEEK_SET) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
677 handle->rd_abs = offset; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
678 else if (whence == SEEK_END) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
679 handle->rd_abs = handle->length + offset; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
680 else |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
681 handle->rd_abs = handle->rd_abs + offset; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
682 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
683 // XXXX |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
684 // There's a race here between finding available space and |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
685 // allocating it and the check below. |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
686 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
687 if (handle->thread) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
688 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
689 if (handle->rd_abs + handle->buffer_length < handle->wr_abs || |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
690 handle->rd_abs > handle->wr_abs) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
691 { |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
692 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
693 g_print("Stop transfer\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
694 curl_req_no_xfer(handle); |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
695 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
696 g_print("Okay\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
697 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
698 else |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
699 { |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
700 if (DEBUG_CONNECTION) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
701 g_print("Continue transfer\n"); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
702 curl_req_sync_xfer(handle, posn); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
703 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
704 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
705 |
460
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
706 if (DEBUG_SEEK) |
cc7faecc7619
[svn] Time out curl connections eventually, and don't retry them on the same VFSFile.
iabervon
parents:
430
diff
changeset
|
707 g_print("Seeked %p from %d to %d\n", handle, posn, handle->rd_abs); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
708 return 0; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
709 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
710 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
711 void |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
712 curl_vfs_rewind_impl(VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
713 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
714 curl_vfs_fseek_impl(file, 0, SEEK_SET); |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
715 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
716 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
717 glong |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
718 curl_vfs_ftell_impl(VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
719 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
720 CurlHandle *handle = file->handle; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
721 return handle->rd_abs; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
722 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
723 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
724 gboolean |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
725 curl_vfs_feof_impl(VFSFile * file) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
726 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
727 CurlHandle *handle = file->handle; |
497
1da75c7d37a3
[svn] - decrement handle->rd_abs when we do an ungetc.
nenolod
parents:
496
diff
changeset
|
728 return (handle->rd_abs == handle->length); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
729 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
730 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
731 gint |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
732 curl_vfs_truncate_impl(VFSFile * file, glong size) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
733 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
734 return -1; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
735 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
736 |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
737 gchar * |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
738 curl_vfs_metadata_impl(VFSFile * file, const gchar * field) |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
739 { |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
740 CurlHandle *handle = file->handle; |
469 | 741 if (!strcmp(field, "stream-name") && handle->name != NULL) |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
742 return strdup(handle->name); |
469 | 743 if (!strcmp(field, "track-name") && handle->title != NULL) |
466
20657d994de8
[svn] Handle inline metadata. Parsing of tags needs work before it will not crash on
iabervon
parents:
465
diff
changeset
|
744 return strdup(handle->title); |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
745 return NULL; |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
746 } |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
747 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
748 VFSConstructor curl_const = { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
749 "http://", |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
750 curl_vfs_fopen_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
751 curl_vfs_fclose_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
752 curl_vfs_fread_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
753 curl_vfs_fwrite_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
754 curl_vfs_getc_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
755 curl_vfs_ungetc_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
756 curl_vfs_fseek_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
757 curl_vfs_rewind_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
758 curl_vfs_ftell_impl, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
759 curl_vfs_feof_impl, |
465
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
760 curl_vfs_truncate_impl, |
ffa685855003
[svn] Provide "name" metadata when the url is a shoutcast stream.
iabervon
parents:
460
diff
changeset
|
761 curl_vfs_metadata_impl |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
762 }; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
763 |
501
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
764 VFSConstructor curl_https_const = { |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
765 "https://", |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
766 curl_vfs_fopen_impl, |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
767 curl_vfs_fclose_impl, |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
768 curl_vfs_fread_impl, |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
769 curl_vfs_fwrite_impl, |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
770 curl_vfs_getc_impl, |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
771 curl_vfs_ungetc_impl, |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
772 curl_vfs_fseek_impl, |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
773 curl_vfs_rewind_impl, |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
774 curl_vfs_ftell_impl, |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
775 curl_vfs_feof_impl, |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
776 curl_vfs_truncate_impl, |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
777 curl_vfs_metadata_impl |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
778 }; |
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
779 |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
780 static void init(void) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
781 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
782 vfs_register_transport(&curl_const); |
501
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
783 vfs_register_transport(&curl_https_const); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
784 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
785 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
786 static void cleanup(void) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
787 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
788 #if 0 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
789 vfs_unregister_transport(&curl_const); |
501
1b06f6690022
[svn] - ssl support (no idea why, but hey, we can!)
nenolod
parents:
500
diff
changeset
|
790 vfs_unregister_transport(&curl_https_const); |
428
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
791 #endif |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
792 } |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
793 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
794 LowlevelPlugin llp_curl = { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
795 NULL, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
796 NULL, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
797 "http:// URI Transport", |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
798 init, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
799 cleanup, |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
800 }; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
801 |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
802 LowlevelPlugin *get_lplugin_info(void) |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
803 { |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
804 return &llp_curl; |
37b3f45b3a68
[svn] Add code for a plugin to use CURL for http. Needs some build-system
iabervon
parents:
diff
changeset
|
805 } |