• Main Page
  • Namespaces
  • Classes
  • Files
  • File List

MediaInfoDLL.h

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

Generated on Sat Apr 5 2014 19:00:19 for MediaInfoLib by  doxygen 1.7.1