quvi.h File Reference

Query video library C API. More...

#include <stdint.h>

Go to the source code of this file.

Defines

#define quvi_lobyte(w)   ((quvi_byte)((uint64_t)(w) & 0xff))
 Return a low byte from a word type variable.
#define quvi_hibyte(w)   ((quvi_byte)((uint64_t)(w) >> 8))
 Return a high byte from a word type variable.
#define quvi_loword(l)   ((quvi_word)((uint64_t)(l) & 0xffff))
 Return a low word from a long type variable.
#define quvi_hiword(l)   ((quvi_word)((uint64_t)(l) >> 16))
 Return a high word from a long type variable.

Typedefs

typedef void * quvi_t
 libquvi session handle
typedef void * quvi_video_t
 Video parsing session handle.
typedef int(* quvi_callback_status )(long param, void *data)
 Status callback function.
typedef uint32_t quvi_word
 Word type.
typedef uint8_t quvi_byte
 Byte type.

Enumerations

enum  QUVIcode {
  QUVI_OK = 0x00, QUVI_MEM, QUVI_BADHANDLE, QUVI_INVARG,
  QUVI_CURLINIT, QUVI_LASTHOST, _QUVI_LAST, QUVI_PCRE = 0xff + 1,
  QUVI_NOSUPPORT, QUVI_CURL, QUVI_ICONV
}
enum  QUVIstatus { QUVIS_FETCH = 0x00, QUVIS_VERIFY }
enum  QUVIstatusType { QUVIST_PAGE = 0x00, QUVIST_CONFIG, QUVIST_PLAYLIST, QUVIST_DONE }
enum  QUVIoption { QUVIOPT_FORMAT = 0x00, QUVIOPT_NOVERIFY, QUVIOPT_STATUSFUNCTION }
enum  QUVIconst {
  QUVIINFO_VOID = 0x100000, QUVIINFO_LONG = 0x200000, QUVIINFO_STRING = 0x300000, QUVIINFO_DOUBLE = 0x400000,
  QUVIINFO_TYPEMASK = 0xf00000, QUVIPROPERTY_STRING = 0x100000, QUVIPROPERTY_LONG = 0x200000, QUVIPROPERTY_DOUBLE = 0x300000,
  QUVIPROPERTY_TYPEMASK = 0xf00000
}
enum  QUVIinfo {
  QUVII_NONE = 0x00, QUVII_CURL = QUVIINFO_VOID + 1, QUVII_CURLCODE = QUVIINFO_LONG + 2, QUVII_HTTPCODE = QUVIINFO_LONG + 3,
  QUVII_LAST = 3
}
enum  QUVIproperty {
  QUVIP_NONE = 0x00, QUVIP_ID = QUVIPROPERTY_STRING + 1, QUVIP_HOSTID = QUVIPROPERTY_STRING + 2, QUVIP_LINK = QUVIPROPERTY_STRING + 3,
  QUVIP_TITLE = QUVIPROPERTY_STRING + 4, QUVIP_LENGTH = QUVIPROPERTY_DOUBLE + 5, QUVIP_PAGELINK = QUVIPROPERTY_STRING + 6, QUVIP_CONTENTTYPE = QUVIPROPERTY_STRING + 7,
  QUVIP_SUFFIX = QUVIPROPERTY_STRING + 8, QUVIP_HTTPCODE = QUVIPROPERTY_LONG + 9, QUVIP_LAST = 9
}

Functions

QUVIcode quvi_init (quvi_t *quvi)
 Start a new libquvi session.
void quvi_close (quvi_t *quvi)
 End a libquvi session.
QUVIcode quvi_parse (quvi_t quvi, char *url, quvi_video_t *video)
 Start a new video parsing session.
void quvi_parse_close (quvi_video_t *video)
 End a video parsing session.
QUVIcode quvi_setopt (quvi_t quvi, QUVIoption opt,...)
 Set options for a libquvi session handle.
QUVIcode quvi_getinfo (quvi_t quvi, QUVIinfo info,...)
 Get information from a libquvi session handle.
QUVIcode quvi_getprop (quvi_video_t video, QUVIproperty prop,...)
 Get video property information from a video session handle.
QUVIcode quvi_iter_host (char **domain, char **formats)
 Return the next video host.
char * quvi_strerror (quvi_t quvi, QUVIcode code)
 Return a string describing the error code.
char * quvi_version (void)
 Return libquvi version.

Detailed Description

Query video library C API.

Author:
Toni Gundogdu
Version:
0.1.0
Date:
2009-09-23

Define Documentation

#define quvi_lobyte (  )     ((quvi_byte)((uint64_t)(w) & 0xff))

Return a low byte from a word type variable.

#define quvi_hibyte (  )     ((quvi_byte)((uint64_t)(w) >> 8))

Return a high byte from a word type variable.

#define quvi_loword (  )     ((quvi_word)((uint64_t)(l) & 0xffff))

Return a low word from a long type variable.

Examples:
quvi.c, and simple.c.
#define quvi_hiword (  )     ((quvi_word)((uint64_t)(l) >> 16))

Return a high word from a long type variable.

Examples:
quvi.c, and simple.c.

Typedef Documentation

typedef void* quvi_t

libquvi session handle

Examples:
quvi.c, and simple.c.
typedef void* quvi_video_t

Video parsing session handle.

Examples:
quvi.c, and simple.c.
typedef int(* quvi_callback_status)(long param, void *data)

Status callback function.

typedef uint32_t quvi_word

Word type.

Examples:
quvi.c, and simple.c.
typedef uint8_t quvi_byte

Byte type.


Enumeration Type Documentation

enum QUVIcode

Return codes

Enumerator:
QUVI_OK 

OK

QUVI_MEM 

Memory allocation failed

QUVI_BADHANDLE 

Bad session handle

QUVI_INVARG 

Invalid function argument

QUVI_CURLINIT 

libcurl initialization failed

QUVI_LASTHOST 

Reached the last host

_QUVI_LAST 

Unused: for libquvi internal use only

QUVI_PCRE 

libpcre error occurred

QUVI_NOSUPPORT 

libquvi does not support the video host

QUVI_CURL 

libcurl error occurred

QUVI_ICONV 

libiconv error occurred

enum QUVIstatus

Status codes

Enumerator:
QUVIS_FETCH 

Status changed to fetch (page, config, etc.)

QUVIS_VERIFY 

Status changed to verify video link

Status type codes

Enumerator:
QUVIST_PAGE 

Fetching video page

QUVIST_CONFIG 

Fetching config

QUVIST_PLAYLIST 

Fetching playlist

QUVIST_DONE 

General purpose "done" status type

enum QUVIoption

Option codes to be used with quvi_setopt()

If you use QUVIOPT_NOVERIFY, the library will return zero for video file length and an empty string for video suffix. Both of them are parsed during the video link verification process from the server returned HTTP header fields content-length and content-type.

Enumerator:
QUVIOPT_FORMAT 

Requested video file format

QUVIOPT_NOVERIFY 

Do not verify video link

QUVIOPT_STATUSFUNCTION 

Callback function for status updates

enum QUVIconst

Misc. constants

Enumerator:
QUVIINFO_VOID 

void type

QUVIINFO_LONG 

long type

QUVIINFO_STRING 

string type

QUVIINFO_DOUBLE 

double type

QUVIINFO_TYPEMASK 

type mask

QUVIPROPERTY_STRING 

string type

QUVIPROPERTY_LONG 

long type

QUVIPROPERTY_DOUBLE 

double type

QUVIPROPERTY_TYPEMASK 

type mask

enum QUVIinfo

Info codes to be used with quvi_getinfo()

The library creates a cURL handle which is used to fetch and verify parsed video details. The cURL handle is initialized with the following libcurl options:

  • CURLOPT_USERAGENT ("Mozilla/5.0")
  • CURLOPT_FOLLOWLOCATION (1)
  • CURLOPT_NOBODY (0)

You can, of course, override those settings in your program. You can even use the cURL handle in your program until quvi_close() is called which will release the handle. See the src/quvi.c for an example of this. Note that libquvi uses the libcurl easy interface and not the multi interface.

Warning:
If you use the libquvi created cURL handle in your program, leave the releasing of the handle for the library to do.
Enumerator:
QUVII_NONE 

Unused

QUVII_CURL 

Session libcurl handle

QUVII_CURLCODE 

Last libcurl returned code

QUVII_HTTPCODE 

Last libcurl returned HTTP code

QUVII_LAST 

A placeholder

Video property codes to be used with quvi_getprop()

Enumerator:
QUVIP_NONE 

Unused

QUVIP_ID 

Video ID

QUVIP_HOSTID 

Host ID

QUVIP_LINK 

Video link

QUVIP_TITLE 

Video title

QUVIP_LENGTH 

Video length in bytes

QUVIP_PAGELINK 

Video page link

QUVIP_CONTENTTYPE 

Video file content-type

QUVIP_SUFFIX 

Video file suffix

QUVIP_HTTPCODE 

Last returned HTTP code

QUVIP_LAST 

Placeholder


Function Documentation

QUVIcode quvi_init ( quvi_t quvi  ) 

Start a new libquvi session.

Parameters:
quvi Pointer to a new handle
Note:
Returns:
Non-zero if an error occurred
See also:
quvi_close
Examples:
quvi.c, and simple.c.
void quvi_close ( quvi_t quvi  ) 

End a libquvi session.

Parameters:
quvi Handle to a session
See also:
quvi_init
Examples:
quvi.c, and simple.c.
QUVIcode quvi_parse ( quvi_t  quvi,
char *  url,
quvi_video_t video 
)

Start a new video parsing session.

Parameters:
quvi Handle to a session
url Null-terminated string to an URL
video Pointer to a new video session handle
Note:
Close each created handle when done and/or before reusing it
Returns:
Non-zero if an error occurred
See also:
quvi_parse_close
Examples:
quvi.c, and simple.c.
void quvi_parse_close ( quvi_video_t video  ) 

End a video parsing session.

Parameters:
video Pointer to a video session
See also:
quvi_parse
Examples:
quvi.c, and simple.c.
QUVIcode quvi_setopt ( quvi_t  quvi,
QUVIoption  opt,
  ... 
)

Set options for a libquvi session handle.

Parameters:
quvi Handle to a libquvi session
opt Option ID
... Parameter
Returns:
Non-zero if an error occurred
See also:
QUVIoption
Examples:
quvi.c, and simple.c.
QUVIcode quvi_getinfo ( quvi_t  quvi,
QUVIinfo  info,
  ... 
)

Get information from a libquvi session handle.

Parameters:
quvi Handle to a libquvi session
info Info ID
... Parameter
Returns:
Non-zero if an error occurred
Warning:
Do not attempt to free the memory returned by this function
See also:
QUVIinfo
Examples:
quvi.c.
QUVIcode quvi_getprop ( quvi_video_t  video,
QUVIproperty  prop,
  ... 
)

Get video property information from a video session handle.

Parameters:
video Handle to a video session
prop Property ID
... Parameter
Returns:
Non-zero if an error occurred
Warning:
Do not attempt to free the memory returned by this function
See also:
QUVIproperty
Examples:
quvi.c, and simple.c.
QUVIcode quvi_iter_host ( char **  domain,
char **  formats 
)

Return the next video host.

Iterates through the list of the supported video hosts returning domain and the supported video formats.

Parameters:
domain Pointer to a null-terminated string
formats Pointer to a null-terminated string (delim. '|')
Note:
  • Set both params to NULL to start (or reset) the iteration
  • Check return code for QUVI_LASTHOST which indicates the end-of-interation
Returns:
Non-zero if reached the last host
Warning:
Do not attempt to free the memory returned by this function
Examples:
quvi.c.
char* quvi_strerror ( quvi_t  quvi,
QUVIcode  code 
)

Return a string describing the error code.

Parameters:
quvi Handle to a libquvi session
code Error code
Returns:
Null-terminated string
Warning:
Do not attempt to free the memory returned by this function
Examples:
quvi.c.
char* quvi_version ( void   ) 

Return libquvi version.

Returns:
Null-terminated string
Warning:
Do not attempt to free the memory returned by this function
Examples:
quvi.c.

Generated on Mon Oct 5 21:22:06 2009 by  doxygen 1.6.1