{ libQUVI
------------------------------------------------------------------------
* Copyright (C) 2009-2011 Toni Gundogdu <legatvs@gmail.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
------------------------------------------------------------------------
* FreePascal translation provided by J. Aldo G. de F. Junior with *
* help of h2pas *
------------------------------------------------------------------------
}
Unit QUVI;
Interface
{$IFDEF FPC}
{$PACKRECORDS C}
{$ENDIF}
{$LINKLIB quvi}
Uses
CTypes;
Const
QUVIINFO_VOID = $100000; {*< void type }
QUVIINFO_LONG = $200000; {*< long type }
QUVIINFO_STRING = $300000; {*< string type }
QUVIINFO_DOUBLE = $400000; {*< double type }
QUVIINFO_TYPEMASK = $f00000; {*< type mask }
QUVIPROPERTY_STRING = $100000; {*< string type }
QUVIPROPERTY_LONG = $200000; {*< long type }
QUVIPROPERTY_DOUBLE = $300000; {*< double type }
QUVIPROPERTY_VOID = $400000; {*< void type }
QUVIPROPERTY_TYPEMASK = $f00000; {*< type mask }
Type
{
* Typedef: Handles
*
* QUVI_t - Session handle
* QUVI_media_t - Media handle
* QUVI_ident_t - Ident handle
* QUVI_video_t - Deprecated since 0.2.15, use QUVI_media_t instead
}
QUVI_T = Pointer;
QUVI_MEDIA_T = Pointer;
QUVI_IDENT_T = Pointer;
PQUVI_IDENT_T = ^QUVI_IDENT_T;
PQUVI_MEDIA_T = ^QUVI_MEDIA_T;
PQUVI_T = ^QUVI_T;
{
* Enum: Version
*
* QUVI_VERSION - Version string
* QUVI_VERSION_LONG - Version string, build date, etc.
* QUVI_VERSION_SCRIPTS - libQUVI-scripts version
}
QUVIversion = (
QUVI_VERSION := $00,
QUVI_VERSION_LONG,
QUVI_VERSION_SCRIPTS
);
{
* Enum: Return codes
*
* QUVI_OK - No error
* QUVI_MEM - Memory allocation error
* QUVI_BADHANDLE - Bad handle
* QUVI_INVARG - Invalid Function argument
* QUVI_CURLINIT - libcurl initialization failure
* QUVI_LAST - Last element in list
* QUVI_ABORTEDBYCALLBACK - Aborted by callback Function
* QUVI_LUAINIT - liblua initialization failure
* QUVI_NOLUAWEBSITE - Failed to find any webscripts
* QUVI_NOLUAUTIL - Failed to find the utility scripts
* QUVI_NOSUPPORT - libQUVI cannot handle the URL
* QUVI_CALLBACK - Network callback error occurred
* QUVI_ICONV - libiconv error occurred
* QUVI_LUA - liblua (or webscript) error occurred
* QUVI_PCRE - Deprecated since 0.2.9, removed in 0.4.0
* QUVI_CURL - Deprecated since 0.2.16, removed in 0.4.0,
* use <QUVI_CALLBACK> instead
}
QUVIcode = (
{ QUVI_strerror returns static strings with these: }
QUVI_OK := $00,
QUVI_MEM,
QUVI_BADHANDLE,
QUVI_INVARG,
QUVI_CURLINIT,
QUVI_LAST,
QUVI_ABORTEDBYCALLBACK,
QUVI_LUAINIT,
QUVI_NOLUAWEBSITE,
QUVI_NOLUAUTIL,
_INTERNAL_QUVI_LAST,
{ QUVI_strerror returns dynamically created error strings with these: }
QUVI_NOSUPPORT := $41,
QUVI_CALLBACK,
QUVI_ICONV,
QUVI_LUA
);
{
* Enum: Status changes
*
* QUVISTATUS_FETCH - Status changed to 'fetch' from URL
* QUVISTATUS_VERIFY - Status changed to 'verify' URL
* QUVISTATUS_RESOLVE - Status changed to 'resolve' URL
* QUVISTATUS_SHORTENED - Deprecated since 0.2.16, removed in 0.4.0,
* use <QUVISTATUS_RESOLVE> instead
}
QUVIstatus = (
QUVISTATUS_FETCH := $00,
QUVISTATUS_VERIFY,
QUVISTATUS_RESOLVE
);
{
* Enum: Status change types
*
* QUVISTATUSTYPE_PAGE - Status type changed to 'page'
* QUVISTATUSTYPE_CONFIG - Status type changed to 'config'
* QUVISTATUSTYPE_PLAYLIST - Status type changed to 'playlist'
* QUVISTATUSTYPE_DONE - Status type changed to 'done'
}
QUVIstatusType = (
QUVISTATUSTYPE_PAGE := $00,
QUVISTATUSTYPE_CONFIG,
QUVISTATUSTYPE_PLAYLIST,
QUVISTATUSTYPE_DONE
);
{
* Enum: Options
*
* QUVIOPT_FORMAT - Requested format
* QUVIOPT_NOVERIFY - Do not verify (HTTP) media URLs
* QUVIOPT_STATUSFunction - Callback Function for status updates
* QUVIOPT_NORESOLVE - Do not attempt to resolve URLs to new location
* QUVIOPT_CATEGORY - Bit pattern of OR'd webscript categories
* QUVIOPT_FETCHFunction - Callback Function for fetching URLs
* QUVIOPT_RESOLVEFunction - Callback Function for resolving URL redirections
* QUVIOPT_VERIFYFunction - Callback Function for verifying media URLs
* QUVIOPT_WRITEFunction - Deprecated since 0.2.17, removed in 0.4.0
* QUVIOPT_NOSHORTENED - Deprecated since 0.2.16, removed in 0.4.0,
* use <QUVIOPT_NORESOLVE> instead
}
QUVIoption = (
QUVIOPT_FORMAT := $00,
QUVIOPT_NOVERIFY,
QUVIOPT_STATUSFunction,
QUVIOPT_NORESOLVE := $4,
QUVIOPT_CATEGORY,
QUVIOPT_FETCHFunction,
QUVIOPT_RESOLVEFunction,
QUVIOPT_VERIFYFunction
);
{
* Enum: Webscript protocol categories
*
* QUVIPROTO_HTTP - Protocol category HTTP
* QUVIPROTO_MMS - Protocol category MMS
* QUVIPROTO_RTSP - Protocol category RTSP
* QUVIPROTO_RTMP - Protocol category RTMP
* QUVIPROTO_ALL - All protocol categories
}
QUVIcategory = (
QUVIPROTO_HTTP := $1,
QUVIPROTO_MMS := $2,
QUVIPROTO_RTSP := $4,
QUVIPROTO_RTMP := $8,
QUVIPROTO_ALL := QUVIPROTO_HTTP + QUVIPROTO_MMS + QUVIPROTO_RTSP + QUVIPROTO_RTMP
);
{
* Enum: Info types
*
* QUVIINFO_CURL - libcurl session handle
* QUVIINFO_RESPONSECODE - Last response code returned by server
* QUVIINFO_CURLCODE - Deprecated since 0.2.16, removed in 0.4.0
* QUVIINFO_HTTPCODE - Deprecated since 0.2.16, removed in 0.4.0
}
QUVIinfo = (
QUVIINFO_NONE := $00,
QUVIINFO_CURL := QUVIINFO_VOID + 1,
QUVIINFO_RESPONSECODE := QUVIINFO_LONG + 3
);
{
* Enum: Media properties
*
* QUVIPROP_HOSTID - Host (or website) ID, typically domain name
* QUVIPROP_PAGEURL - Page URL
* QUVIPROP_PAGETITLE - Page title
* QUVIPROP_MEDIAID - Media ID
* QUVIPROP_MEDIAURL - Media URL
* QUVIPROP_MEDIACONTENTLENGTH - Media content length in bytes
* QUVIPROP_MEDIACONTENTTYPE - Media content-type
* QUVIPROP_FILESUFFIX - File suffix, parsed from the content-type
* QUVIPROP_RESPONSECODE - Last response code returned by server
* QUVIPROP_FORMAT - _Requested_ format, see <QUVIOPT_FORMAT>
* QUVIPROP_STARTTIME - Start time for media, if any
* QUVIPROP_MEDIATHUMBNAILURL - Media cover/thumbnail URL, if any
* QUVIPROP_MEDIADURATION - Media duration in msecs, if any (0)
* QUVIPROP_VIDEOID - Deprecated since 0.2.15, use <QUVIPROP_MEDIAID> instead
* QUVIPROP_VIDEOURL - Deprecated since 0.2.15, use <QUVIPROP_MEDIAURL> instead
* QUVIPROP_VIDEOFILELENGTH - Deprecated since 0.2.15,
* use <QUVIPROP_MEDIACONTENTLENGTH> instead
* QUVIPROP_VIDEOFILESUFFIX - Deprecated since 0.2.15,
* use <QUVIPROP_FILESUFFIX> instead
* QUVIPROP_VIDEOFORMAT - Deprecated since 0.2.15,
* use <QUVIPROP_FORMAT> instead
* QUVIPROP_HTTPCODE - Deprecated since 0.2.16,
* use <QUVIPROP_RESPONSECODE> instead
}
QUVIproperty = (
QUVIPROP_NONE := $00,
QUVIPROP_HOSTID := QUVIPROPERTY_STRING + 1,
QUVIPROP_PAGEURL := QUVIPROPERTY_STRING + 2,
QUVIPROP_PAGETITLE := QUVIPROPERTY_STRING + 3,
QUVIPROP_MEDIAID := QUVIPROPERTY_STRING + 4,
QUVIPROP_MEDIAURL := QUVIPROPERTY_STRING + 5,
QUVIPROP_MEDIACONTENTLENGTH := QUVIPROPERTY_DOUBLE + 6,
QUVIPROP_MEDIACONTENTTYPE := QUVIPROPERTY_STRING + 7,
QUVIPROP_FILESUFFIX := QUVIPROPERTY_STRING + 8,
QUVIPROP_RESPONSECODE := QUVIPROPERTY_LONG + 9,
QUVIPROP_FORMAT := QUVIPROPERTY_STRING + 10,
QUVIPROP_STARTTIME := QUVIPROPERTY_STRING + 11,
QUVIPROP_MEDIATHUMBNAILURL := QUVIPROPERTY_STRING + 12,
QUVIPROP_MEDIADURATION := QUVIPROPERTY_DOUBLE + 13
);
{
* Enum: Ident properties
*
* QUVI_IDENT_PROPERTY_URL - URL
* QUVI_IDENT_PROPERTY_DOMAIN - Domain
* QUVI_IDENT_PROPERTY_FORMATS - Formats
* QUVI_IDENT_PROPERTY_CATEGORIES - Protocol categories
}
QUVIidentProperty = (
QUVI_IDENT_PROPERTY_NONE := $00,
QUVI_IDENT_PROPERTY_URL := QUVIPROPERTY_STRING + 1,
QUVI_IDENT_PROPERTY_DOMAIN := QUVIPROPERTY_STRING + 2,
QUVI_IDENT_PROPERTY_FORMATS := QUVIPROPERTY_STRING + 3,
QUVI_IDENT_PROPERTY_CATEGORIES := QUVIPROPERTY_STRING + 4
);
{
* Typedef: Callbacks
*
* QUVI_callback_status - Status callback Function
}
QUVI_Callback_Status = Function (_para1 : LongInt; _para2 : Pointer): LongInt; cdecl;
{
* Typedef: Other
*
* QUVI_word - Word type
* QUVI_byte - Byte type
}
QUVI_Word = cuint32;
QUVI_Byte = cuint8;
Function QUVIInit(_para1 : PQUVI_T): QUVIcode; External;
Procedure QUVIClose(_para1 : PQUVI_T); External;
Function QUVISetOpt(_para1 : QUVI_t; _para2 : QUVIoption; args : Array of Const): QUVIcode; External;
Function QUVIGetInfo(_para1 : QUVI_t; _para2 : QUVIinfo; args : Array of Const): QUVIcode; External;
Function QUVIParse(_para1 : QUVI_t; url : PChar; _para3 : PQUVI_MEDIA_T): QUVIcode; External;
Procedure QUVIParseClose(_para1 : PQUVI_MEDIA_T); External;
Function QUVIGetProp(_para1 : QUVI_media_t; _para2 : QUVIproperty; args : Array of Const): QUVIcode; External;
Function QUVIQueryFormats(_para1 : QUVI_t; url : PChar; formats : PPChar): QUVIcode; External;
Function QUVINextMediaURL(_para1 : QUVI_media_t): QUVIcode; External;
Function QUVISupported(_para1 : QUVI_t; url : Pchar): QUVIcode; External;
Function QUVISupportedIdent(_para1 : QUVI_t; url : PChar; _para3 : PQUVI_IDENT_T): QUVIcode; External;
Function QUVIIdentGetProp(_para1 : QUVI_ident_t; _para2 : QUVIidentProperty; args : Array of Const): QUVIcode; External;
Procedure QUVISupportedIdentClose(_para1 : PQUVI_IDENT_T); External;
Function QUVINextSupportedWebsite(_para1 : QUVI_t; domain : PPChar; formats : PPChar): QUVIcode; External;
Function QUVINextHost(domain : PPChar; formats : PPChar): QUVIcode; External;
Function QUVIStrError(_para1 : QUVI_t; _para2 : QUVIcode): PChar; External;
Function QUVIVersionStr(_para1 : QUVIversion): PChar; External;
Procedure QUVIFree(_para1 : Pointer); External 'quvi';
implementation
End.
This is a small, h2pas helped, translation of lubquvi headers for freepascal. libquvi allows extracting correct urls for videos served on various media pages. What its lacking ? Declare the external name of the functions (because pascal case rules creates name collisions with the standard names) and solve a small compiler warning that c style sets must be ordered ascending.
I am puting the code here because my hard disk is doing clicks and i fear losing it.