quvi.h
Go to the documentation of this file.
00001 /* quvi
00002  * Copyright (C) 2009,2010,2011  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 {
00048   QUVI_VERSION = 0x00,    
00049   QUVI_VERSION_LONG       
00050 } QUVIversion;
00051 
00053 typedef enum
00054 {
00055   /* Static errors */
00056   QUVI_OK  = 0x00,        
00057   QUVI_MEM,               
00058   QUVI_BADHANDLE,         
00059   QUVI_INVARG,            
00060   QUVI_CURLINIT,          
00061   QUVI_LAST,              
00062   QUVI_ABORTEDBYCALLBACK, 
00063   QUVI_LUAINIT,           
00064   QUVI_NOLUAWEBSITE,      
00065   QUVI_NOLUAUTIL,         
00066   _INTERNAL_QUVI_LAST,    
00067   /* Dynamically generated errors */
00068   QUVI_PCRE = 0x40, 
00069   QUVI_NOSUPPORT,   
00070   QUVI_CURL,        
00071   QUVI_ICONV,       
00072   QUVI_LUA          
00073 } QUVIcode;
00074 
00076 typedef enum
00077 {
00078   QUVISTATUS_FETCH  = 0x00,   
00079   QUVISTATUS_VERIFY,          
00080   QUVISTATUS_SHORTENED        
00081 } QUVIstatus;
00082 
00084 typedef enum
00085 {
00086   /* QUVISTATUS_FETCH: */
00087   QUVISTATUSTYPE_PAGE = 0x00,   
00088   QUVISTATUSTYPE_CONFIG,        
00089   QUVISTATUSTYPE_PLAYLIST,      
00090   /* Generic types: */
00091   QUVISTATUSTYPE_DONE           
00092 } QUVIstatusType;
00093 
00105 typedef enum
00106 {
00107   QUVIOPT_FORMAT = 0x00,  
00108   QUVIOPT_NOVERIFY,       
00109   QUVIOPT_STATUSFUNCTION, 
00110   QUVIOPT_WRITEFUNCTION,  
00111   QUVIOPT_NOSHORTENED,    
00112   QUVIOPT_CATEGORY        
00113 } QUVIoption;
00114 
00115 #define QUVIINFO_VOID       0x100000 
00116 #define QUVIINFO_LONG       0x200000 
00117 #define QUVIINFO_STRING     0x300000 
00118 #define QUVIINFO_DOUBLE     0x400000 
00119 #define QUVIINFO_TYPEMASK   0xf00000 
00132 typedef enum
00133 {
00134   QUVIPROTO_HTTP = 0x1, 
00135   QUVIPROTO_MMS  = 0x2, 
00136   QUVIPROTO_RTSP = 0x4, 
00137   QUVIPROTO_RTMP = 0x8, 
00138   QUVIPROTO_ALL  =
00139   (QUVIPROTO_HTTP|QUVIPROTO_MMS|QUVIPROTO_RTSP|QUVIPROTO_RTMP)
00141 } QUVIcategory;
00142 
00161 typedef enum
00162 {
00163   QUVIINFO_NONE        = 0x00,             
00164   QUVIINFO_CURL        = QUVIINFO_VOID + 1,
00165   QUVIINFO_CURLCODE    = QUVIINFO_LONG + 2,
00166   QUVIINFO_HTTPCODE    = QUVIINFO_LONG + 3,
00167   /* Add new ones below. */
00168   _QUVIINFO_LAST        = 3                 
00169 } QUVIinfo;
00170 
00171 #define QUVIPROPERTY_STRING     0x100000 
00172 #define QUVIPROPERTY_LONG       0x200000 
00173 #define QUVIPROPERTY_DOUBLE     0x300000 
00174 #define QUVIPROPERTY_TYPEMASK   0xf00000 
00177 typedef enum
00178 {
00179   QUVIPROP_NONE          = 0x00, 
00180   QUVIPROP_HOSTID        = QUVIPROPERTY_STRING + 1, 
00181   QUVIPROP_PAGEURL       = QUVIPROPERTY_STRING + 2, 
00182   QUVIPROP_PAGETITLE     = QUVIPROPERTY_STRING + 3, 
00183   QUVIPROP_MEDIAID       = QUVIPROPERTY_STRING + 4, 
00184   QUVIPROP_MEDIAURL      = QUVIPROPERTY_STRING + 5, 
00185   QUVIPROP_MEDIACONTENTLENGTH    = QUVIPROPERTY_DOUBLE + 6, 
00186   QUVIPROP_MEDIACONTENTTYPE      = QUVIPROPERTY_STRING + 7, 
00187   QUVIPROP_FILESUFFIX    = QUVIPROPERTY_STRING + 8, 
00188   QUVIPROP_HTTPCODE      = QUVIPROPERTY_LONG   + 9, 
00189   QUVIPROP_FORMAT        = QUVIPROPERTY_STRING + 10, 
00190   QUVIPROP_STARTTIME     = QUVIPROPERTY_STRING + 11, 
00191   QUVIPROP_MEDIATHUMBNAILURL     = QUVIPROPERTY_STRING + 12, 
00192   QUVIPROP_MEDIADURATION         = QUVIPROPERTY_DOUBLE + 13, 
00193   /* Add new ones below. Bump _QUVIPROP_LAST accordingly. */
00194 
00195   /* -- Deprecated as of 0.2.15. Note that these exist only for
00196    * backward-compatibility. This may change in the future. New
00197    * applications should use the appropriate QUVIPROP_MEDIA* enums
00198    * instead. */
00199 
00200   QUVIPROP_VIDEOID         = QUVIPROPERTY_STRING + 4, 
00202   QUVIPROP_VIDEOURL        = QUVIPROPERTY_STRING + 5, 
00204   QUVIPROP_VIDEOFILELENGTH = QUVIPROPERTY_DOUBLE + 6, 
00206   QUVIPROP_VIDEOFILECONTENTTYPE = QUVIPROPERTY_STRING + 7, 
00209   QUVIPROP_VIDEOFILESUFFIX = QUVIPROPERTY_STRING + 8, 
00211   QUVIPROP_VIDEOFORMAT     = QUVIPROPERTY_STRING + 10, 
00215   _QUVIPROP_LAST          = 13 
00216 } QUVIproperty;
00217 
00219 typedef void *quvi_t;
00223 typedef void *quvi_media_t;
00227 typedef void *quvi_video_t;
00228 
00299 typedef int (*quvi_callback_status) (long param, void *data);
00300 
00301 #define QUVI_WRITEFUNC_ABORT 0x10000000 
00311 typedef int (*quvi_callback_write) (char *buffer,
00312                                     size_t size,
00313                                     size_t nitems,
00314                                     void *instream);
00315 
00317 typedef uint32_t quvi_word;
00319 typedef uint8_t  quvi_byte;
00320  /* End of libquvi_types group. */
00322 
00323 
00330 #define quvi_lobyte(w) ((quvi_byte)((uint64_t)(w) & 0xff))
00331 
00332 #define quvi_hibyte(w) ((quvi_byte)((uint64_t)(w) >> 8))
00333 
00335 #define quvi_loword(l) ((quvi_word)((uint64_t)(l) & 0xffff))
00336 
00337 #define quvi_hiword(l) ((quvi_word)((uint64_t)(l) >> 16))
00338  /* End of libquvi_macros group. */
00340 
00341 
00342 #ifdef __cplusplus
00343 extern "C" {
00344 #endif /* __cplusplus */
00345 
00398   QUVIcode quvi_init(quvi_t *quvi);
00399 
00400 
00420   void quvi_close(quvi_t *quvi);
00421  /* End of libquvi_release group. */ /* End of libquvi_init group. */
00424 
00425 
00449   QUVIcode quvi_setopt(quvi_t quvi, QUVIoption opt, ...);
00450 
00459   size_t quvi_write_callback_default(void *ptr, size_t size, size_t nmemb, void *stream);
00460  /* End of libquvi_setup group. */
00462 
00463 
00491   QUVIcode quvi_getinfo(quvi_t quvi, QUVIinfo info, ...);
00492  /* End of libquvi_getinfo group. */
00494 
00521   QUVIcode quvi_parse(quvi_t quvi, char *url, quvi_media_t *media);
00522 
00523 
00550   QUVIcode quvi_getprop(quvi_media_t media, QUVIproperty prop, ...);
00551  /* End of libquvi_getprop group. */
00553 
00554 
00586   QUVIcode quvi_next_media_url(quvi_media_t media);
00587 
00615   QUVIcode quvi_next_videolink(quvi_video_t video);
00616  /* End of libquvi_parse_util group. */
00618 
00619 
00642   void quvi_parse_close(quvi_media_t *media);
00643  /* End of libquvi_parse_release group */ /* End of libquvi_parse group */
00646 
00647 
00679   QUVIcode quvi_supported(quvi_t quvi, char *url);
00680 
00713   QUVIcode quvi_next_supported_website(quvi_t quvi, char **domain, char **formats);
00714 
00727   QUVIcode quvi_next_host(char **domain, char **formats);
00728 
00751   char *quvi_strerror(quvi_t quvi, QUVIcode code);
00752 
00767   char *quvi_version(QUVIversion type);
00768 
00774   void quvi_free(void *ptr);
00775  /* End of libquvi_misc group. */ /* End of libquvi_api group. */
00778 
00779 #ifdef __cplusplus
00780 }
00781 #endif /* __cplusplus */
00782 
00783 #endif /* quvi_h */
00784 /* vim: set ts=2 sw=2 tw=72 expandtab: */
 All Files Functions Typedefs Enumerations Enumerator Defines