quvi.h

Go to the documentation of this file.
00001 /* quvi
00002  * Copyright (C) 2009,2010  Toni Gundogdu <legatvs@gmail.com>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301  USA
00018  */
00019 
00032 #ifndef quvi_h
00033 #define quvi_h
00034 
00035 #ifndef DOXY_SKIP
00036 #include <stdlib.h>
00037 #include <stdint.h> /* C99 header */
00038 #endif
00039 
00046 typedef enum {
00047 QUVI_VERSION = 0x00,    
00048 QUVI_VERSION_LONG       
00049 } QUVIversion;
00050 
00052 typedef enum {
00053 /* Static errors */
00054 QUVI_OK  = 0x00,        
00055 QUVI_MEM,               
00056 QUVI_BADHANDLE,         
00057 QUVI_INVARG,            
00058 QUVI_CURLINIT,          
00059 QUVI_LAST,              
00060 QUVI_ABORTEDBYCALLBACK, 
00061 QUVI_LUAINIT,           
00062 QUVI_NOLUAWEBSITE,      
00063 QUVI_NOLUAUTIL,         
00064 _INTERNAL_QUVI_LAST,    
00065 /* Dynamically generated errors */
00066 QUVI_PCRE = 0x40, 
00067 QUVI_NOSUPPORT,   
00068 QUVI_CURL,        
00069 QUVI_ICONV,       
00070 QUVI_LUA          
00071 } QUVIcode;
00072 
00074 typedef enum {
00075 QUVISTATUS_FETCH  = 0x00,   
00076 QUVISTATUS_VERIFY,          
00077 QUVISTATUS_SHORTENED        
00078 } QUVIstatus;
00079 
00081 typedef enum {
00082 /* QUVISTATUS_FETCH: */
00083 QUVISTATUSTYPE_PAGE = 0x00,   
00084 QUVISTATUSTYPE_CONFIG,        
00085 QUVISTATUSTYPE_PLAYLIST,      
00086 /* Generic types: */
00087 QUVISTATUSTYPE_DONE           
00088 } QUVIstatusType;
00089 
00102 typedef enum {
00103 QUVIOPT_FORMAT = 0x00,  
00104 QUVIOPT_NOVERIFY,       
00105 QUVIOPT_STATUSFUNCTION, 
00106 QUVIOPT_WRITEFUNCTION,  
00107 QUVIOPT_NOSHORTENED,    
00108 QUVIOPT_CATEGORY        
00109 } QUVIoption;
00110 
00111 #define QUVIINFO_VOID       0x100000 
00112 #define QUVIINFO_LONG       0x200000 
00113 #define QUVIINFO_STRING     0x300000 
00114 #define QUVIINFO_DOUBLE     0x400000 
00115 #define QUVIINFO_TYPEMASK   0xf00000 
00125 typedef enum {
00126 QUVIPROTO_HTTP = 0x1, 
00127 QUVIPROTO_MMS  = 0x2, 
00128 QUVIPROTO_RTSP = 0x4, 
00129 QUVIPROTO_RTMP = 0x8, 
00130 QUVIPROTO_ALL  =
00131     (QUVIPROTO_HTTP|QUVIPROTO_MMS|QUVIPROTO_RTSP|QUVIPROTO_RTMP)
00133 } QUVIcategory;
00134 
00153 typedef enum {
00154 QUVIINFO_NONE        = 0x00,             
00155 QUVIINFO_CURL        = QUVIINFO_VOID + 1,
00156 QUVIINFO_CURLCODE    = QUVIINFO_LONG + 2,
00157 QUVIINFO_HTTPCODE    = QUVIINFO_LONG + 3,
00158 /* Add new ones below. */
00159 _QUVIINFO_LAST        = 3                 
00160 } QUVIinfo;
00161 
00162 #define QUVIPROPERTY_STRING     0x100000 
00163 #define QUVIPROPERTY_LONG       0x200000 
00164 #define QUVIPROPERTY_DOUBLE     0x300000 
00165 #define QUVIPROPERTY_TYPEMASK   0xf00000 
00168 typedef enum {
00169 QUVIPROP_NONE          = 0x00, 
00170 QUVIPROP_HOSTID        = QUVIPROPERTY_STRING + 1, 
00171 QUVIPROP_PAGEURL       = QUVIPROPERTY_STRING + 2, 
00172 QUVIPROP_PAGETITLE     = QUVIPROPERTY_STRING + 3, 
00173 QUVIPROP_VIDEOID       = QUVIPROPERTY_STRING + 4, 
00174 QUVIPROP_VIDEOURL      = QUVIPROPERTY_STRING + 5, 
00175 QUVIPROP_VIDEOFILELENGTH       = QUVIPROPERTY_DOUBLE + 6, 
00176 QUVIPROP_VIDEOFILECONTENTTYPE  = QUVIPROPERTY_STRING + 7, 
00177 QUVIPROP_VIDEOFILESUFFIX       = QUVIPROPERTY_STRING + 8, 
00178 QUVIPROP_HTTPCODE      = QUVIPROPERTY_LONG   + 9, 
00179 QUVIPROP_VIDEOFORMAT   = QUVIPROPERTY_STRING + 10, 
00180 QUVIPROP_STARTTIME     = QUVIPROPERTY_STRING + 11, 
00181 /* Add new ones below. */
00182 _QUVIPROP_LAST          = 11 
00183 } QUVIproperty;
00184 
00186 typedef void *quvi_t;
00188 typedef void *quvi_video_t;
00189 
00237 typedef int (*quvi_callback_status) (long param, void *data);
00238 
00239 #define QUVI_WRITEFUNC_ABORT 0x10000000 
00249 typedef int (*quvi_callback_write) (char *buffer,
00250                                     size_t size,
00251                                     size_t nitems,
00252                                     void *instream);
00253 
00255 typedef uint32_t quvi_word;
00257 typedef uint8_t  quvi_byte;
00258  /* End of libquvi_types group. */
00260 
00261 
00268 #define quvi_lobyte(w) ((quvi_byte)((uint64_t)(w) & 0xff))
00269 
00270 #define quvi_hibyte(w) ((quvi_byte)((uint64_t)(w) >> 8))
00271 
00273 #define quvi_loword(l) ((quvi_word)((uint64_t)(l) & 0xffff))
00274 
00275 #define quvi_hiword(l) ((quvi_word)((uint64_t)(l) >> 16))
00276  /* End of libquvi_macros group. */
00278 
00279 
00280 #ifdef __cplusplus
00281 extern "C" {
00282 #endif /* __cplusplus */
00283 
00330 QUVIcode quvi_init(quvi_t *quvi);
00331 
00332 
00352 void quvi_close(quvi_t *quvi);
00353  /* End of libquvi_release group. */ /* End of libquvi_init group. */
00356 
00357 
00381 QUVIcode quvi_setopt(quvi_t quvi, QUVIoption opt, ...);
00382 
00391 size_t quvi_write_callback_default(void *ptr, size_t size, size_t nmemb, void *stream);
00392  /* End of libquvi_setup group. */
00394 
00395 
00423 QUVIcode quvi_getinfo(quvi_t quvi, QUVIinfo info, ...);
00424  /* End of libquvi_getinfo group. */
00426 
00453 QUVIcode quvi_parse(quvi_t quvi, char *url, quvi_video_t *video);
00454 
00455 
00482 QUVIcode quvi_getprop(quvi_video_t video, QUVIproperty prop, ...);
00483  /* End of libquvi_getprop group. */
00485 
00486 
00514 QUVIcode quvi_next_videolink(quvi_video_t video);
00515  /* End of libquvi_parse_util group. */
00517 
00518 
00541 void quvi_parse_close(quvi_video_t *video);
00542  /* End of libquvi_parse_release group */ /* End of libquvi_parse group */
00545 
00546 
00577 QUVIcode quvi_supported(quvi_t quvi, char *url);
00578 
00608 QUVIcode quvi_next_supported_website(quvi_t quvi, char **domain, char **formats);
00609 
00622 QUVIcode quvi_next_host(char **domain, char **formats);
00623 
00645 char *quvi_strerror(quvi_t quvi, QUVIcode code);
00646 
00661 char *quvi_version(QUVIversion type);
00662 
00668 void quvi_free(void *ptr);
00669  /* End of libquvi_misc group. */ /* End of libquvi_api group. */
00672 
00673 #ifdef __cplusplus
00674 }
00675 #endif /* __cplusplus */
00676 
00677 #endif /* quvi_h */
00678 /* vim: set ts=2 sw=2 tw=72 expandtab: */
 All Files Functions Typedefs Enumerations Enumerator Defines