MediaInfoDLL.h

    00001 /* MediaInfoDLL - All info about media files, for DLL
    00002 // Copyright (C) 2002-2012 Jerome Martinez, Zen@MediaArea.net
    00003 //
    00004 // This library is free software: you can redistribute it and/or modify it
    00005 // under the terms of the GNU Library General Public License as published by
    00006 // the Free Software Foundation, either version 2 of the License, or
    00007 // 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
    00012 // GNU Library General Public License for more details.
    00013 //
    00014 // You should have received a copy of the GNU Library General Public License
    00015 // along with this library. If not, see <http://www.gnu.org/licenses/>.
    00016 //
    00017 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00018 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00019 //
    00020 // Public DLL interface implementation
    00021 // Wrapper for MediaInfo Library
    00022 // See MediaInfo.h for help
    00023 //
    00024 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
    00025
    00026 #ifndef MediaInfoDLLH
    00027 #define MediaInfoDLLH
    00028
    00029 //***************************************************************************
    00030 // Platforms (from libzen)
    00031 //***************************************************************************
    00032
    00033 /*---------------------------------------------------------------------------*/
    00034 /*Win32*/
    00035 #if defined(__NT__) || defined(_WIN32) || defined(WIN32)
    00036     #ifndef WIN32
    00037         #define WIN32
    00038     #endif
    00039     #ifndef _WIN32
    00040         #define _WIN32
    00041     #endif
    00042     #ifndef __WIN32__
    00043         #define __WIN32__ 1
    00044     #endif
    00045 #endif
    00046
    00047 /*---------------------------------------------------------------------------*/
    00048 /*Win64*/
    00049 #if defined(_WIN64) || defined(WIN64)
    00050     #ifndef WIN64
    00051         #define WIN64
    00052     #endif
    00053     #ifndef _WIN64
    00054         #define _WIN64
    00055     #endif
    00056     #ifndef __WIN64__
    00057         #define __WIN64__ 1
    00058     #endif
    00059 #endif
    00060
    00061 /*---------------------------------------------------------------------------*/
    00062 /*Windows*/
    00063 #if defined(WIN32) || defined(WIN64)
    00064     #ifndef WINDOWS
    00065         #define WINDOWS
    00066     #endif
    00067     #ifndef _WINDOWS
    00068         #define _WINDOWS
    00069     #endif
    00070     #ifndef __WINDOWS__
    00071         #define __WINDOWS__ 1
    00072     #endif
    00073 #endif
    00074
    00075 /*---------------------------------------------------------------------------*/
    00076 /*Unix (Linux, HP, Sun, BeOS...)*/
    00077 #if defined(UNIX) || defined(_UNIX) || defined(__UNIX__) \
    00078     || defined(__unix) || defined(__unix__) \
    00079     || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) \
    00080     || defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) \
    00081     || defined(__EMX__) || defined(__VMS) || defined(__BEOS__)
    00082     #ifndef UNIX
    00083         #define UNIX
    00084     #endif
    00085     #ifndef _UNIX
    00086         #define _UNIX
    00087     #endif
    00088     #ifndef __UNIX__
    00089         #define __UNIX__ 1
    00090     #endif
    00091 #endif
    00092
    00093 /*---------------------------------------------------------------------------*/
    00094 /*MacOS Classic*/
    00095 #if defined(macintosh)
    00096     #ifndef MACOS
    00097         #define MACOS
    00098     #endif
    00099     #ifndef _MACOS
    00100         #define _MACOS
    00101     #endif
    00102     #ifndef __MACOS__
    00103         #define __MACOS__ 1
    00104     #endif
    00105 #endif
    00106
    00107 /*---------------------------------------------------------------------------*/
    00108 /*MacOS X*/
    00109 #if defined(__APPLE__) && defined(__MACH__)
    00110     #ifndef MACOSX
    00111         #define MACOSX
    00112     #endif
    00113     #ifndef _MACOSX
    00114         #define _MACOSX
    00115     #endif
    00116     #ifndef __MACOSX__
    00117         #define __MACOSX__ 1
    00118     #endif
    00119 #endif
    00120
    00121 /*Test of targets*/
    00122 #if defined(WINDOWS) && defined(UNIX) && defined(MACOS) && defined(MACOSX)
    00123     #pragma message Multiple platforms???
    00124 #endif
    00125
    00126 #if !defined(WIN32) && !defined(UNIX) && !defined(MACOS) && !defined(MACOSX)
    00127     #pragma message No known platforms, assume default
    00128 #endif
    00129
    00130 /*-------------------------------------------------------------------------*/
    00131 #if defined (_WIN32) || defined (WIN32)
    00132     #ifdef _UNICODE
    00133         #define MEDIAINFODLL_NAME  L"MediaInfo.dll"
    00134     #else //_UNICODE
    00135         #define MEDIAINFODLL_NAME  "MediaInfo.dll"
    00136     #endif //_UNICODE
    00137 #elif defined(__APPLE__) && defined(__MACH__)
    00138     #define MEDIAINFODLL_NAME  "libmediainfo.0.dylib"
    00139     #define __stdcall
    00140 #else
    00141     #define MEDIAINFODLL_NAME  "libmediainfo.so.0"
    00142     #define __stdcall
    00143 #endif //!defined(_WIN32) || defined (WIN32)
    00144
    00145 /*-------------------------------------------------------------------------*/
    00146 /*Char types                                                               */
    00147 #undef  __T
    00148 #define __T(__x)    __T(__x)
    00149 #if defined(UNICODE) || defined (_UNICODE)
    00150     typedef wchar_t MediaInfo_Char;
    00151     #undef  __T
    00152     #define __T(__x) L ## __x
    00153     #define MEDIAINFO_Ansi ""
    00154 #else
    00155     typedef char MediaInfo_Char;
    00156     #undef  __T
    00157     #define __T(__x) __x
    00158     #define MEDIAINFO_Ansi "A"
    00159 #endif
    00160 /*-------------------------------------------------------------------------*/
    00161
    00162 /*-------------------------------------------------------------------------*/
    00163 /*8-bit int                                                                */
    00164 typedef unsigned char       MediaInfo_int8u;
    00165 /*-------------------------------------------------------------------------*/
    00166
    00167 /*-------------------------------------------------------------------------*/
    00168 /*64-bit int                                                               */
    00169 #if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__) || defined(__MACOSX__)
    00170     #undef  MAXTYPE_INT
    00171     #define MAXTYPE_INT 64
    00172     typedef unsigned long long  MediaInfo_int64u;
    00173 #elif defined(__WIN32__) || defined(_WIN32)
    00174     #undef  MAXTYPE_INT
    00175     #define MAXTYPE_INT 64
    00176     typedef unsigned __int64    MediaInfo_int64u;
    00177 #else
    00178     #pragma message This machine has no 64-bit integer type?
    00179 #endif
    00180 /*-------------------------------------------------------------------------*/
    00181
    00182 /*-------------------------------------------------------------------------*/
    00183 /*NULL                                                                     */
    00184 #ifndef NULL
    00185     #define NULL 0
    00186 #endif
    00187 /*-------------------------------------------------------------------------*/
    00188
    00190 typedef enum MediaInfo_stream_t
    00191 {
    00192     MediaInfo_Stream_General,
    00193     MediaInfo_Stream_Video,
    00194     MediaInfo_Stream_Audio,
    00195     MediaInfo_Stream_Text,
    00196     MediaInfo_Stream_Chapters,
    00197     MediaInfo_Stream_Image,
    00198     MediaInfo_Stream_Menu,
    00199     MediaInfo_Stream_Max
    00200 } MediaInfo_stream_C;
    00201
    00203 typedef enum MediaInfo_info_t
    00204 {
    00205     MediaInfo_Info_Name,
    00206     MediaInfo_Info_Text,
    00207     MediaInfo_Info_Measure,
    00208     MediaInfo_Info_Options,
    00209     MediaInfo_Info_Name_Text,
    00210     MediaInfo_Info_Measure_Text,
    00211     MediaInfo_Info_Info,
    00212     MediaInfo_Info_HowTo,
    00213     MediaInfo_Info_Max
    00214 } MediaInfo_info_C;
    00215
    00217 typedef enum MediaInfo_infooptions_t
    00218 {
    00219     MediaInfo_InfoOption_ShowInInform,
    00220     MediaInfo_InfoOption_Reserved,
    00221     MediaInfo_InfoOption_ShowInSupported,
    00222     MediaInfo_InfoOption_TypeOfValue,
    00223     MediaInfo_InfoOption_Max
    00224 } MediaInfo_infooptions_C;
    00225
    00227 typedef enum MediaInfo_fileoptions_t
    00228 {
    00229     MediaInfo_FileOption_Nothing        =0x00,
    00230     MediaInfo_FileOption_NoRecursive    =0x01,
    00231     MediaInfo_FileOption_CloseAll       =0x02,
    00232     MediaInfo_FileOption_Max            =0x04
    00233 } MediaInfo_fileoptions_C;
    00234
    00235
    00236 #ifdef __cplusplus
    00237 extern "C"
    00238 {
    00239 #endif /* __cplusplus */
    00240
    00241 #ifdef MEDIAINFO_GLIBC
    00242     #include <gmodule.h>
    00243     static GModule* MediaInfo_Module=NULL;
    00244 #elif defined (_WIN32) || defined (WIN32)
    00245     #include <windows.h>
    00246     static HMODULE  MediaInfo_Module=NULL;
    00247 #else
    00248     #include <dlfcn.h>
    00249     static void*    MediaInfo_Module=NULL;
    00250 #endif
    00251 static size_t Module_Count=0;
    00252
    00253 #ifdef MEDIAINFO_GLIBC
    00254 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
    00255     if (!g_module_symbol (MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfo_##_Name)) \
    00256         Errors++;
    00257 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
    00258     if (!g_module_symbol (MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfoList_##_Name)) \
    00259         Errors++;
    00260 #elif defined (_WIN32) || defined (WIN32)
    00261 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
    00262     MediaInfo_##_Name=(MEDIAINFO_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \
    00263     if (MediaInfo_##_Name==NULL) Errors++;
    00264 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
    00265     MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \
    00266     if (MediaInfoList_##_Name==NULL) Errors++;
    00267 #else
    00268 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
    00269     MediaInfo_##_Name=(MEDIAINFO_##_Name)dlsym(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \
    00270     if (MediaInfo_##_Name==NULL) Errors++;
    00271 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
    00272     MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)dlsym(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \
    00273     if (MediaInfoList_##_Name==NULL) Errors++;
    00274 #endif
    00275
    00276 typedef void* (__stdcall *MEDIAINFO_New)(); static MEDIAINFO_New MediaInfo_New;
    00277 typedef void* (__stdcall *MEDIAINFOLIST_New)(); static MEDIAINFOLIST_New MediaInfoList_New;
    00278 typedef void (__stdcall *MEDIAINFO_Delete)(void*); static MEDIAINFO_Delete MediaInfo_Delete;
    00279 typedef void (__stdcall *MEDIAINFOLIST_Delete)(void*); static MEDIAINFOLIST_Delete MediaInfoList_Delete;
    00280 typedef size_t (__stdcall *MEDIAINFO_Open)(void*, const MediaInfo_Char*); static MEDIAINFO_Open MediaInfo_Open;
    00281 typedef size_t (__stdcall *MEDIAINFOLIST_Open)(void*, const MediaInfo_Char*, const MediaInfo_fileoptions_C); static MEDIAINFOLIST_Open MediaInfoList_Open;
    00282 typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Init)(void*, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset); static MEDIAINFO_Open_Buffer_Init MediaInfo_Open_Buffer_Init;
    00283 typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Continue)(void*, MediaInfo_int8u* Buffer, size_t Buffer_Size); static MEDIAINFO_Open_Buffer_Continue MediaInfo_Open_Buffer_Continue;
    00284 typedef MediaInfo_int64u (__stdcall *MEDIAINFO_Open_Buffer_Continue_GoTo_Get)(void*); static MEDIAINFO_Open_Buffer_Continue_GoTo_Get MediaInfo_Open_Buffer_Continue_GoTo_Get;
    00285 typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Finalize)(void*); static MEDIAINFO_Open_Buffer_Finalize MediaInfo_Open_Buffer_Finalize;
    00286 typedef size_t (__stdcall *MEDIAINFO_Open_NextPacket)(void*); static MEDIAINFO_Open_NextPacket MediaInfo_Open_NextPacket;
    00287 typedef void (__stdcall *MEDIAINFO_Close)(void*); static MEDIAINFO_Close MediaInfo_Close;
    00288 typedef void (__stdcall *MEDIAINFOLIST_Close)(void*, size_t); static MEDIAINFOLIST_Close MediaInfoList_Close;
    00289 typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Inform)(void*, size_t Reserved); static MEDIAINFO_Inform MediaInfo_Inform;
    00290 typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Inform)(void*, size_t, size_t Reserved); static MEDIAINFOLIST_Inform MediaInfoList_Inform;
    00291 typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_GetI)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo); static MEDIAINFO_GetI MediaInfo_GetI;
    00292 typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_GetI)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo); static MEDIAINFOLIST_GetI MediaInfoList_GetI;
    00293 typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Get)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber, const MediaInfo_Char* Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch); static MEDIAINFO_Get MediaInfo_Get;
    00294 typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Get)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, const MediaInfo_Char* Parameter, MediaInfo_info_C KindOfInfo, MediaInfo_info_C KindOfSearch); static MEDIAINFOLIST_Get MediaInfoList_Get;
    00295 typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_Get)(void*, const MediaInfo_Char* Parameter); static MEDIAINFO_Output_Buffer_Get MediaInfo_Output_Buffer_Get;
    00296 typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_GetI)(void*, size_t Pos); static MEDIAINFO_Output_Buffer_GetI MediaInfo_Output_Buffer_GetI;
    00297 typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value); static MEDIAINFO_Option MediaInfo_Option;
    00298 typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value); static MEDIAINFOLIST_Option MediaInfoList_Option;
    00299 typedef size_t (__stdcall *MEDIAINFO_State_Get)(void*); static MEDIAINFO_State_Get MediaInfo_State_Get;
    00300 typedef size_t (__stdcall *MEDIAINFOLIST_State_Get)(void*); static MEDIAINFOLIST_State_Get MediaInfoList_State_Get;
    00301 typedef size_t (__stdcall *MEDIAINFO_Count_Get)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber); static MEDIAINFO_Count_Get MediaInfo_Count_Get;
    00302 typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber); static MEDIAINFOLIST_Count_Get MediaInfoList_Count_Get;
    00303 typedef size_t (__stdcall *MEDIAINFO_Count_Get_Files)(void*); static MEDIAINFO_Count_Get_Files MediaInfo_Count_Get_Files;
    00304 typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get_Files)(void*); static MEDIAINFOLIST_Count_Get_Files MediaInfoList_Count_Get_Files;
    00305
    00306 static size_t MediaInfoDLL_Load()
    00307 {
    00308     size_t Errors=0;
    00309
    00310     if (Module_Count>0)
    00311     {
    00312         Module_Count++;
    00313         return 1;
    00314     }
    00315
    00316     /* Load library */
    00317     #ifdef MEDIAINFO_GLIBC
    00318         MediaInfo_Module=g_module_open(MEDIAINFODLL_NAME, G_MODULE_BIND_LAZY);
    00319     #elif defined (_WIN32) || defined (WIN32)
    00320         MediaInfo_Module=LoadLibrary(MEDIAINFODLL_NAME);
    00321     #else
    00322         MediaInfo_Module=dlopen(MEDIAINFODLL_NAME, RTLD_LAZY);
    00323         if (!MediaInfo_Module)
    00324             MediaInfo_Module=dlopen("./" MEDIAINFODLL_NAME, RTLD_LAZY);
    00325         if (!MediaInfo_Module)
    00326             MediaInfo_Module=dlopen("/usr/local/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
    00327         if (!MediaInfo_Module)
    00328             MediaInfo_Module=dlopen("/usr/local/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
    00329         if (!MediaInfo_Module)
    00330             MediaInfo_Module=dlopen("/usr/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
    00331         if (!MediaInfo_Module)
    00332             MediaInfo_Module=dlopen("/usr/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
    00333     #endif
    00334     if (!MediaInfo_Module)
    00335         return (size_t)-1;
    00336
    00337     /* Load methods */
    00338     MEDIAINFO_ASSIGN    (New,"New")
    00339     MEDIAINFOLIST_ASSIGN(New,"New")
    00340     MEDIAINFO_ASSIGN    (Delete,"Delete")
    00341     MEDIAINFOLIST_ASSIGN(Delete,"Delete")
    00342     MEDIAINFO_ASSIGN    (Open,"Open")
    00343     MEDIAINFOLIST_ASSIGN(Open,"Open")
    00344     MEDIAINFO_ASSIGN    (Open_Buffer_Init,"Open_Buffer_Init")
    00345     MEDIAINFO_ASSIGN    (Open_Buffer_Continue,"Open_Buffer_Continue")
    00346     MEDIAINFO_ASSIGN    (Open_Buffer_Continue_GoTo_Get,"Open_Buffer_Continue_GoTo_Get")
    00347     MEDIAINFO_ASSIGN    (Open_Buffer_Finalize,"Open_Buffer_Finalize")
    00348     MEDIAINFO_ASSIGN    (Open_NextPacket,"Open_NextPacket")
    00349     MEDIAINFO_ASSIGN    (Close,"Close")
    00350     MEDIAINFOLIST_ASSIGN(Close,"Close")
    00351     MEDIAINFO_ASSIGN    (Inform,"Inform")
    00352     MEDIAINFOLIST_ASSIGN(Inform,"Inform")
    00353     MEDIAINFO_ASSIGN    (GetI,"GetI")
    00354     MEDIAINFOLIST_ASSIGN(GetI,"GetI")
    00355     MEDIAINFO_ASSIGN    (Get,"Get")
    00356     MEDIAINFOLIST_ASSIGN(Get,"Get")
    00357     MEDIAINFO_ASSIGN    (Output_Buffer_Get,"Output_Buffer_Get")
    00358     MEDIAINFO_ASSIGN    (Output_Buffer_GetI,"Output_Buffer_GetI")
    00359     MEDIAINFO_ASSIGN    (Option,"Option")
    00360     MEDIAINFOLIST_ASSIGN(Option,"Option")
    00361     MEDIAINFO_ASSIGN    (State_Get,"State_Get")
    00362     MEDIAINFOLIST_ASSIGN(State_Get,"State_Get")
    00363     MEDIAINFO_ASSIGN    (Count_Get,"Count_Get")
    00364     MEDIAINFOLIST_ASSIGN(Count_Get,"Count_Get")
    00365     MEDIAINFOLIST_ASSIGN(Count_Get_Files,"Count_Get_Files")
    00366     if (Errors>0)
    00367     {
    00368         // Unload DLL with errors
    00369         #ifdef MEDIAINFO_GLIBC
    00370             g_module_close(MediaInfo_Module);
    00371         #elif defined (_WIN32) || defined (WIN32)
    00372             FreeLibrary(MediaInfo_Module);
    00373         #else
    00374             dlclose(MediaInfo_Module);
    00375        #endif
    00376        MediaInfo_Module=NULL;
    00377        return (size_t)-1;
    00378     }
    00379
    00380     Module_Count++;
    00381     return (size_t)1;
    00382 }
    00383
    00384 static size_t MediaInfoDLL_IsLoaded()
    00385 {
    00386     if (MediaInfo_Module)
    00387         return 1;
    00388     else
    00389         return 0;
    00390 }
    00391
    00392 static void MediaInfoDLL_UnLoad()
    00393 {
    00394     Module_Count--;
    00395     if (Module_Count>0)
    00396         return;
    00397
    00398     #ifdef MEDIAINFO_GLIBC
    00399         g_module_close(MediaInfo_Module);
    00400     #elif defined (_WIN32) || defined (WIN32)
    00401         FreeLibrary(MediaInfo_Module);
    00402     #else
    00403         dlclose(MediaInfo_Module);
    00404     #endif
    00405     MediaInfo_Module=NULL;
    00406 }
    00407
    00408 #ifdef __cplusplus
    00409 }
    00410 #endif /*__cplusplus*/
    00411
    00412 /***************************************************************************/
    00413 /***************************************************************************/
    00414 /***************************************************************************/
    00415
    00416 #ifdef __cplusplus
    00417 //DLL C++ wrapper for C functions
    00418
    00419 //---------------------------------------------------------------------------
    00420 #include <string>
    00421 #include <sstream>
    00422 //---------------------------------------------------------------------------
    00423
    00424 namespace MediaInfoDLL
    00425 {
    00426
    00427 //---------------------------------------------------------------------------
    00428 //MediaInfo_Char types
    00429 #undef  __T
    00430 #define __T(__x)    __T(__x)
    00431 #if defined(UNICODE) || defined (_UNICODE)
    00432     typedef wchar_t Char;
    00433     #undef  __T
    00434     #define __T(__x) L ## __x
    00435 #else
    00436     typedef char Char;
    00437     #undef  __T
    00438     #define __T(__x) __x
    00439 #endif
    00440 typedef std::basic_string<Char>        String;
    00441 typedef std::basic_stringstream<Char>  StringStream;
    00442 typedef std::basic_istringstream<Char> iStringStream;
    00443 typedef std::basic_ostringstream<Char> oStringStream;
    00444 typedef std::basic_istringstream<Char> tiStringStream; // Legacy
    00445 typedef std::basic_ostringstream<Char> toStringStream; //Legacy
    00446 const size_t Error=(size_t)(-1);
    00447 //---------------------------------------------------------------------------
    00448
    00449 //---------------------------------------------------------------------------
    00451 enum stream_t
    00452 {
    00453     Stream_General,
    00454     Stream_Video,
    00455     Stream_Audio,
    00456     Stream_Text,
    00457     Stream_Chapters,
    00458     Stream_Image,
    00459     Stream_Menu,
    00460     Stream_Max,
    00461 };
    00462
    00464 enum info_t
    00465 {
    00466     Info_Name,
    00467     Info_Text,
    00468     Info_Measure,
    00469     Info_Options,
    00470     Info_Name_Text,
    00471     Info_Measure_Text,
    00472     Info_Info,
    00473     Info_HowTo,
    00474     Info_Max
    00475 };
    00476
    00481 enum infooptions_t
    00482 {
    00483     InfoOption_ShowInInform,
    00484     InfoOption_Reserved,
    00485     InfoOption_ShowInSupported,
    00486     InfoOption_TypeOfValue,
    00487     InfoOption_Max
    00488 };
    00489
    00491 enum fileoptions_t
    00492 {
    00493     FileOption_Nothing      =0x00,
    00494     FileOption_NoRecursive  =0x01,
    00495     FileOption_CloseAll     =0x02,
    00496     FileOption_Max          =0x04
    00497 };
    00498
    00499 const String Unable_Load_DLL=__T("Unable to load ")MEDIAINFODLL_NAME;
    00500 #define MEDIAINFO_TEST_VOID \
    00501     if (!IsReady()) return
    00502 #define MEDIAINFO_TEST_INT \
    00503     if (!IsReady()) return 0
    00504 #define MEDIAINFO_TEST_STRING \
    00505     if (!IsReady()) return Unable_Load_DLL
    00506 #define MEDIAINFO_TEST_STRING_STATIC \
    00507     if (!MediaInfo_Module) return Unable_Load_DLL
    00508
    00509 //---------------------------------------------------------------------------
    00510 class MediaInfo
    00511 {
    00512 public :
    00513     MediaInfo ()        {if (!MediaInfo_Module) MediaInfoDLL_Load(); if (!MediaInfo_Module) {Handle=NULL; return;}; Handle=MediaInfo_New();};
    00514     ~MediaInfo ()       {MEDIAINFO_TEST_VOID; MediaInfo_Delete(Handle);};
    00515
    00516     //File
    00517     size_t Open (const String &File) {MEDIAINFO_TEST_INT; return MediaInfo_Open(Handle, File.c_str());};
    00518     size_t Open_Buffer_Init (MediaInfo_int64u File_Size=(MediaInfo_int64u)-1, MediaInfo_int64u File_Offset=0) {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Init(Handle, File_Size, File_Offset);};
    00519     size_t Open_Buffer_Continue (MediaInfo_int8u* Buffer, size_t Buffer_Size) {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue(Handle, Buffer, Buffer_Size);};
    00520     MediaInfo_int64u Open_Buffer_Continue_GoTo_Get () {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue_GoTo_Get(Handle);};
    00521     size_t Open_Buffer_Finalize () {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Finalize(Handle);};
    00522     size_t Open_NextPacket () {MEDIAINFO_TEST_INT; return MediaInfo_Open_NextPacket(Handle);};
    00523     //size_t Save () {MEDIAINFO_TEST_INT; return MediaInfo_Save(Handle);};
    00524     void Close () {MEDIAINFO_TEST_VOID; return MediaInfo_Close(Handle);};
    00525
    00526     //General information
    00527     String Inform ()  {MEDIAINFO_TEST_STRING; return MediaInfo_Inform(Handle, 0);};
    00528     String Get (stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind=Info_Text)  {MEDIAINFO_TEST_STRING; return MediaInfo_GetI (Handle, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, (MediaInfo_info_C)InfoKind);};
    00529     String Get (stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind=Info_Text, info_t SearchKind=Info_Name)  {MEDIAINFO_TEST_STRING; return MediaInfo_Get (Handle, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), (MediaInfo_info_C)InfoKind, (MediaInfo_info_C)SearchKind);};
    00530     //size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=__T(""))  {MEDIAINFO_TEST_INT; return MediaInfo_SetI (Handle, ToSet.c_str(), (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, OldValue.c_str());};
    00531     //size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=__T(""))  {MEDIAINFO_TEST_INT; return MediaInfo_Set (Handle, ToSet.c_str(), (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), OldValue.c_str());};
    00532     size_t Output_Buffer_Get (const String &Value) {return MediaInfo_Output_Buffer_Get(Handle, Value.c_str());}
    00533     size_t Output_Buffer_Get (size_t Pos) {return MediaInfo_Output_Buffer_GetI(Handle, Pos);}
    00534     String        Option (const String &Option, const String &Value=__T(""))  {MEDIAINFO_TEST_STRING; return MediaInfo_Option (Handle, Option.c_str(), Value.c_str());};
    00535     static String Option_Static (const String &Option, const String &Value=__T(""))  {if (!MediaInfo_Module) MediaInfoDLL_Load(); MEDIAINFO_TEST_STRING_STATIC; return MediaInfo_Option (NULL, Option.c_str(), Value.c_str());};
    00536     size_t        State_Get () {MEDIAINFO_TEST_INT; return MediaInfo_State_Get(Handle);};
    00537     size_t        Count_Get (stream_t StreamKind, size_t StreamNumber=(size_t)-1)  {MEDIAINFO_TEST_INT; return MediaInfo_Count_Get(Handle, (MediaInfo_stream_C)StreamKind, StreamNumber);};
    00538
    00539     bool IsReady() {return (Handle && MediaInfo_Module)?true:false;}
    00540
    00541 private :
    00542     void* Handle;
    00543 };
    00544
    00545 class MediaInfoList
    00546 {
    00547 public :
    00548     MediaInfoList ()        {MediaInfoDLL_Load(); if (!MediaInfoDLL_IsLoaded()) {Handle=NULL; return;}; Handle=MediaInfoList_New();};
    00549     ~MediaInfoList ()       {MEDIAINFO_TEST_VOID; MediaInfoList_Delete(Handle); MediaInfoDLL_UnLoad();};
    00550
    00551     //File
    00552     size_t Open (const String &File, const fileoptions_t Options=FileOption_Nothing) {MEDIAINFO_TEST_INT; return MediaInfoList_Open(Handle, File.c_str(), (MediaInfo_fileoptions_C)Options);};
    00553     //size_t Save (size_t FilePos) {MEDIAINFO_TEST_INT; return MediaInfoList_Save(Handle, FilePos);};
    00554     void Close (size_t FilePos=(size_t)-1) {MEDIAINFO_TEST_VOID; return MediaInfoList_Close(Handle, FilePos);};
    00555
    00556     //General information
    00557     String Inform (size_t FilePos=(size_t)-1)  {MEDIAINFO_TEST_STRING; return MediaInfoList_Inform(Handle, FilePos, 0);};
    00558     String Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind=Info_Text)  {MEDIAINFO_TEST_STRING; return MediaInfoList_GetI (Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, (MediaInfo_info_C)InfoKind);};
    00559     String Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind=Info_Text, info_t SearchKind=Info_Name)  {MEDIAINFO_TEST_STRING; return MediaInfoList_Get (Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), (MediaInfo_info_C)InfoKind, (MediaInfo_info_C)SearchKind);};
    00560     //size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=__T(""))  {MEDIAINFO_TEST_INT; return MediaInfoList_SetI (Handle, ToSet.c_str(), FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter, OldValue.c_str());};
    00561     //size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=__T(""))  {MEDIAINFO_TEST_INT; return MediaInfoList_Set (Handle, ToSet.c_str(), FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber, Parameter.c_str(), OldValue.c_str());};
    00562     String        Option (const String &Option, const String &Value=__T(""))  {MEDIAINFO_TEST_STRING; return MediaInfoList_Option (Handle, Option.c_str(), Value.c_str());};
    00563     static String Option_Static (const String &Option, const String &Value=__T(""))  {MEDIAINFO_TEST_STRING_STATIC; return MediaInfoList_Option (NULL, Option.c_str(), Value.c_str());};
    00564     size_t        State_Get ()  {MEDIAINFO_TEST_INT; return MediaInfoList_State_Get(Handle);};
    00565     size_t        Count_Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber=(size_t)-1)  {MEDIAINFO_TEST_INT; return MediaInfoList_Count_Get(Handle, FilePos, (MediaInfo_stream_C)StreamKind, StreamNumber);};
    00566     size_t        Count_Get ()  {MEDIAINFO_TEST_INT; return MediaInfoList_Count_Get_Files(Handle);};
    00567
    00568     bool IsReady() {return (Handle && MediaInfo_Module)?true:false;}
    00569
    00570 private :
    00571     void* Handle;
    00572 };
    00573
    00574 } //NameSpace
    00575 #endif /*__cplusplus*/
    00576
    00577 #endif