3 * Copyright (C) 2009,2010,2011 Toni Gundogdu <legatvs@gmail.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #include <stdint.h> /* C99 header */
30 * QUVI_VERSION - Version string
31 * QUVI_VERSION_LONG - Version string, build date, etc.
43 * QUVI_MEM - Memory allocation error
44 * QUVI_BADHANDLE - Bad handle
45 * QUVI_INVARG - Invalid function argument
46 * QUVI_CURLINIT - libcurl initialization failure
47 * QUVI_LAST - Last element in list
48 * QUVI_ABORTEDBYCALLBACK - Aborted by callback function
49 * QUVI_LUAINIT - liblua initialization failure
50 * QUVI_NOLUAWEBSITE - Failed to find any webscripts
51 * QUVI_NOLUAUTIL - Failed to find the utility scripts
52 * QUVI_NOSUPPORT - libquvi cannot handle the URL
53 * QUVI_CALLBACK - Network callback error occurred
54 * QUVI_ICONV - libiconv error occurred
55 * QUVI_LUA - liblua (or webscript) error occurred
56 * QUVI_PCRE - Deprecated since 0.2.9, removed in 0.2.20
57 * QUVI_CURL - Deprecated since 0.2.16, removed in 0.2.20,
58 * use <QUVI_CALLBACK> instead
62 /* quvi_strerror returns static strings with these: */
69 QUVI_ABORTEDBYCALLBACK
,
74 /* quvi_strerror returns dynamically created error strings with these: */
75 QUVI_NOSUPPORT
= 0x41,
79 /* Add new ones below */
86 * Enum: Status changes
88 * QUVISTATUS_FETCH - Status changed to 'fetch' from URL
89 * QUVISTATUS_VERIFY - Status changed to 'verify' URL
90 * QUVISTATUS_RESOLVE - Status changed to 'resolve' URL
91 * QUVISTATUS_SHORTENED - Deprecated since 0.2.16, removed in 0.2.20,
92 * use <QUVISTATUS_RESOLVE> instead
96 QUVISTATUS_FETCH
= 0x00,
99 /* Add new ones below */
101 QUVISTATUS_SHORTENED
= 0x2
105 * Enum: Status change types
107 * QUVISTATUSTYPE_PAGE - Status type changed to 'page'
108 * QUVISTATUSTYPE_CONFIG - Status type changed to 'config'
109 * QUVISTATUSTYPE_PLAYLIST - Status type changed to 'playlist'
110 * QUVISTATUSTYPE_DONE - Status type changed to 'done'
114 QUVISTATUSTYPE_PAGE
= 0x00,
115 QUVISTATUSTYPE_CONFIG
,
116 QUVISTATUSTYPE_PLAYLIST
,
118 /* Add new ones below */
124 * QUVIOPT_FORMAT - Requested format
125 * QUVIOPT_NOVERIFY - Do not verify (HTTP) media URLs
126 * QUVIOPT_STATUSFUNCTION - Callback function for status updates
127 * QUVIOPT_NORESOLVE - Do not attempt to resolve URLs to new location
128 * QUVIOPT_CATEGORY - Bit pattern of OR'd webscript categories
129 * QUVIOPT_FETCHFUNCTION - Callback function for fetching URLs
130 * QUVIOPT_RESOLVEFUNCTION - Callback function for resolving URL redirections
131 * QUVIOPT_VERIFYFUNCTION - Callback function for verifying media URLs
132 * QUVIOPT_WRITEFUNCTION - Deprecated since 0.2.17, removed in 0.2.17
133 * QUVIOPT_NOSHORTENED - Deprecated since 0.2.16, removed in 0.2.20,
134 * use <QUVIOPT_NORESOLVE> instead
138 QUVIOPT_FORMAT
= 0x00,
140 QUVIOPT_STATUSFUNCTION
,
141 QUVIOPT_NORESOLVE
= 0x4,
143 QUVIOPT_FETCHFUNCTION
,
144 QUVIOPT_RESOLVEFUNCTION
,
145 QUVIOPT_VERIFYFUNCTION
,
146 /* Add new ones below */
148 QUVIOPT_WRITEFUNCTION
= 0x03,
149 QUVIOPT_NOSHORTENED
= 0x4
153 * Enum: Webscript protocol categories
155 * QUVIPROTO_HTTP - Protocol category HTTP
156 * QUVIPROTO_MMS - Protocol category MMS
157 * QUVIPROTO_RTSP - Protocol category RTSP
158 * QUVIPROTO_RTMP - Protocol category RTMP
159 * QUVIPROTO_ALL - All protocol categories
163 QUVIPROTO_HTTP
= 0x1,
165 QUVIPROTO_RTSP
= 0x4,
166 QUVIPROTO_RTMP
= 0x8,
168 (QUVIPROTO_HTTP
|QUVIPROTO_MMS
|QUVIPROTO_RTSP
|QUVIPROTO_RTMP
)
171 #define QUVIINFO_VOID 0x100000 /**< void type */
172 #define QUVIINFO_LONG 0x200000 /**< long type */
173 #define QUVIINFO_STRING 0x300000 /**< string type */
174 #define QUVIINFO_DOUBLE 0x400000 /**< double type */
175 #define QUVIINFO_TYPEMASK 0xf00000 /**< type mask */
180 * QUVIINFO_CURL - libcurl session handle
181 * QUVIINFO_RESPONSECODE - Last response code returned by server
182 * QUVIINFO_CURLCODE - Deprecated since 0.2.16, removed in 0.2.20
183 * QUVIINFO_HTTPCODE - Deprecated since 0.2.16, removed in 0.2.20
187 QUVIINFO_NONE
= 0x00,
188 QUVIINFO_CURL
= QUVIINFO_VOID
+1,
189 QUVIINFO_RESPONSECODE
= QUVIINFO_LONG
+3,
190 /* Add new ones below */
192 QUVIINFO_CURLCODE
= QUVIINFO_LONG
+2,
193 QUVIINFO_HTTPCODE
= QUVIINFO_LONG
+3,
196 #define QUVIPROPERTY_STRING 0x100000 /**< string type */
197 #define QUVIPROPERTY_LONG 0x200000 /**< long type */
198 #define QUVIPROPERTY_DOUBLE 0x300000 /**< double type */
199 #define QUVIPROPERTY_VOID 0x400000 /**< void type */
200 #define QUVIPROPERTY_TYPEMASK 0xf00000 /**< type mask */
203 * Enum: Media properties
205 * QUVIPROP_HOSTID - Host (or website) ID, typically domain name
206 * QUVIPROP_PAGEURL - Page URL
207 * QUVIPROP_PAGETITLE - Page title
208 * QUVIPROP_MEDIAID - Media ID
209 * QUVIPROP_MEDIAURL - Media URL
210 * QUVIPROP_MEDIACONTENTLENGTH - Media content length in bytes
211 * QUVIPROP_MEDIACONTENTTYPE - Media content-type
212 * QUVIPROP_FILESUFFIX - File suffix, parsed from the content-type
213 * QUVIPROP_RESPONSECODE - Last response code returned by server
214 * QUVIPROP_FORMAT - _Requested_ format, see <QUVIOPT_FORMAT>
215 * QUVIPROP_STARTTIME - Start time for media, if any
216 * QUVIPROP_MEDIATHUMBNAILURL - Media cover/thumbnail URL, if any
217 * QUVIPROP_MEDIADURATION - Media duration in msecs, if any (0)
218 * QUVIPROP_VIDEOID - Deprecated since 0.2.15, use <QUVIPROP_MEDIAID> instead
219 * QUVIPROP_VIDEOURL - Deprecated since 0.2.15, use <QUVIPROP_MEDIAURL> instead
220 * QUVIPROP_VIDEOFILELENGTH - Deprecated since 0.2.15,
221 * use <QUVIPROP_MEDIACONTENTLENGTH> instead
222 * QUVIPROP_VIDEOFILESUFFIX - Deprecated since 0.2.15,
223 * use <QUVIPROP_FILESUFFIX> instead
224 * QUVIPROP_VIDEOFORMAT - Deprecated since 0.2.15,
225 * use <QUVIPROP_FORMAT> instead
226 * QUVIPROP_HTTPCODE - Deprecated since 0.2.16,
227 * use <QUVIPROP_RESPONSECODE> instead
231 QUVIPROP_NONE
= 0x00,
232 QUVIPROP_HOSTID
= QUVIPROPERTY_STRING
+1,
233 QUVIPROP_PAGEURL
= QUVIPROPERTY_STRING
+2,
234 QUVIPROP_PAGETITLE
= QUVIPROPERTY_STRING
+3,
235 QUVIPROP_MEDIAID
= QUVIPROPERTY_STRING
+4,
236 QUVIPROP_MEDIAURL
= QUVIPROPERTY_STRING
+5,
237 QUVIPROP_MEDIACONTENTLENGTH
= QUVIPROPERTY_DOUBLE
+6,
238 QUVIPROP_MEDIACONTENTTYPE
= QUVIPROPERTY_STRING
+7,
239 QUVIPROP_FILESUFFIX
= QUVIPROPERTY_STRING
+8,
240 QUVIPROP_RESPONSECODE
= QUVIPROPERTY_LONG
+9,
241 QUVIPROP_FORMAT
= QUVIPROPERTY_STRING
+10,
242 QUVIPROP_STARTTIME
= QUVIPROPERTY_STRING
+11,
243 QUVIPROP_MEDIATHUMBNAILURL
= QUVIPROPERTY_STRING
+12,
244 QUVIPROP_MEDIADURATION
= QUVIPROPERTY_DOUBLE
+13,
245 /* Add new ones below */
247 QUVIPROP_VIDEOID
= QUVIPROPERTY_STRING
+4,
248 QUVIPROP_VIDEOURL
= QUVIPROPERTY_STRING
+5,
249 QUVIPROP_VIDEOFILELENGTH
= QUVIPROPERTY_DOUBLE
+6,
250 QUVIPROP_VIDEOCONETNTTYPE
= QUVIPROPERTY_STRING
+7,
251 QUVIPROP_VIDEOFILESUFFIX
= QUVIPROPERTY_STRING
+8,
252 QUVIPROP_HTTPCODE
= QUVIPROPERTY_LONG
+9,
253 QUVIPROP_VIDEOFORMAT
= QUVIPROPERTY_STRING
+10
257 * Enum: Ident properties
259 * QUVI_IDENT_PROPERTY_URL - URL
260 * QUVI_IDENT_PROPERTY_DOMAIN - Domain
261 * QUVI_IDENT_PROPERTY_FORMATS - Formats
262 * QUVI_IDENT_PROPERTY_CATEGORIES - Protocol categories
266 QUVI_IDENT_PROPERTY_NONE
= 0x00,
267 QUVI_IDENT_PROPERTY_URL
= QUVIPROPERTY_STRING
+1,
268 QUVI_IDENT_PROPERTY_DOMAIN
= QUVIPROPERTY_STRING
+2,
269 QUVI_IDENT_PROPERTY_FORMATS
= QUVIPROPERTY_STRING
+3,
270 QUVI_IDENT_PROPERTY_CATEGORIES
= QUVIPROPERTY_STRING
+4,
276 * quvi_t - Session handle
277 * quvi_media_t - Media handle
278 * quvi_ident_t - Ident handle
279 * quvi_video_t - Deprecated since 0.2.15, use quvi_media_t instead
281 typedef void *quvi_t
;
282 typedef void *quvi_media_t
;
283 typedef void *quvi_ident_t
;
284 typedef void *quvi_video_t
;
289 * quvi_callback_status - Status callback function
291 typedef int (*quvi_callback_status
) (long, void*);
296 * quvi_word - Word type
297 * quvi_byte - Byte type
299 typedef uint32_t quvi_word
;
300 typedef uint8_t quvi_byte
;
303 * Macro: Support macros
305 * quvi_lobyte - Return a low byte from a word type variable
306 * quvi_hibyte - Return a high byte from a word type variable
307 * quvi_loword - Return a low word from a long type variable
308 * quvi_hiword - Return a high word from a long type variable
310 #define quvi_lobyte(w) ((quvi_byte)((uint64_t)(w) & 0xff))
311 #define quvi_hibyte(w) ((quvi_byte)((uint64_t)(w) >> 8))
312 #define quvi_loword(l) ((quvi_word)((uint64_t)(l) & 0xffff))
313 #define quvi_hiword(l) ((quvi_word)((uint64_t)(l) >> 16))
319 QUVIcode
quvi_init(quvi_t
*);
320 void quvi_close(quvi_t
*);
322 QUVIcode
quvi_setopt(quvi_t
, QUVIoption
, ...);
323 QUVIcode
quvi_getinfo(quvi_t
, QUVIinfo
, ...);
325 QUVIcode
quvi_parse(quvi_t
, char *url
, quvi_media_t
*);
326 void quvi_parse_close(quvi_media_t
*);
328 QUVIcode
quvi_getprop(quvi_media_t
, QUVIproperty
, ...);
330 /* Support functions */
331 QUVIcode
quvi_query_formats(quvi_t
, char *url
, char **formats
);
333 QUVIcode
quvi_next_media_url(quvi_media_t
);
334 QUVIcode
quvi_next_videolink(quvi_video_t
);
336 QUVIcode
quvi_supported(quvi_t
, char *url
);
337 QUVIcode
quvi_supported_ident(quvi_t
, char *url
, quvi_ident_t
*);
338 QUVIcode
quvi_ident_getprop(quvi_ident_t
, QUVIidentProperty
, ...);
339 void quvi_supported_ident_close(quvi_ident_t
*);
341 QUVIcode
quvi_next_supported_website(quvi_t
, char **domain
, char **formats
);
342 QUVIcode
quvi_next_host(char **domain
, char **formats
);
344 char *quvi_strerror(quvi_t
, QUVIcode
);
345 char *quvi_version(QUVIversion
);
346 void quvi_free(void*);
350 #endif /* __cplusplus */
354 /* vim: set ts=2 sw=2 tw=72 expandtab: */