MediaInfoLib
0.7
|
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 #else 00130 #define MEDIAINFODLL_NAME "libmediainfo.so.0" 00131 #define __stdcall 00132 #include <new> //for size_t 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 #include <dlfcn.h> 00235 static void* MediaInfo_Module = NULL; 00236 #endif 00237 static size_t Module_Count = 0; 00238 00239 #ifdef MEDIAINFO_GLIBC 00240 #define MEDIAINFO_ASSIGN(_Name,_Name2) \ 00241 if (!g_module_symbol (MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfo_##_Name)) \ 00242 Errors++; 00243 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \ 00244 if (!g_module_symbol (MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfoList_##_Name)) \ 00245 Errors++; 00246 #elif defined(_WIN32) || defined(WIN32) 00247 #define MEDIAINFO_ASSIGN(_Name,_Name2) \ 00248 MediaInfo_##_Name=(MEDIAINFO_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \ 00249 if (MediaInfo_##_Name==NULL) Errors++; 00250 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \ 00251 MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \ 00252 if (MediaInfoList_##_Name==NULL) Errors++; 00253 #else 00254 #define MEDIAINFO_ASSIGN(_Name,_Name2) \ 00255 MediaInfo_##_Name=(MEDIAINFO_##_Name)dlsym(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \ 00256 if (MediaInfo_##_Name==NULL) Errors++; 00257 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \ 00258 MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)dlsym(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \ 00259 if (MediaInfoList_##_Name==NULL) Errors++; 00260 #endif 00261 00262 typedef void* (__stdcall *MEDIAINFO_New)(); 00263 static MEDIAINFO_New MediaInfo_New; 00264 typedef void* (__stdcall *MEDIAINFOLIST_New)(); 00265 static MEDIAINFOLIST_New MediaInfoList_New; 00266 typedef void (__stdcall *MEDIAINFO_Delete)(void*); 00267 static MEDIAINFO_Delete MediaInfo_Delete; 00268 typedef void (__stdcall *MEDIAINFOLIST_Delete)(void*); 00269 static MEDIAINFOLIST_Delete MediaInfoList_Delete; 00270 typedef size_t (__stdcall *MEDIAINFO_Open)(void*, const MediaInfo_Char*); 00271 static MEDIAINFO_Open MediaInfo_Open; 00272 typedef size_t (__stdcall *MEDIAINFOLIST_Open)(void*, const MediaInfo_Char*, const MediaInfo_fileoptions_C); 00273 static MEDIAINFOLIST_Open MediaInfoList_Open; 00274 typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Init)(void*, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset); 00275 static MEDIAINFO_Open_Buffer_Init MediaInfo_Open_Buffer_Init; 00276 typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Continue)(void*, MediaInfo_int8u* Buffer, size_t Buffer_Size); 00277 static MEDIAINFO_Open_Buffer_Continue MediaInfo_Open_Buffer_Continue; 00278 typedef MediaInfo_int64u(__stdcall *MEDIAINFO_Open_Buffer_Continue_GoTo_Get)(void*); 00279 static MEDIAINFO_Open_Buffer_Continue_GoTo_Get MediaInfo_Open_Buffer_Continue_GoTo_Get; 00280 typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Finalize)(void*); 00281 static MEDIAINFO_Open_Buffer_Finalize MediaInfo_Open_Buffer_Finalize; 00282 typedef size_t (__stdcall *MEDIAINFO_Open_NextPacket)(void*); 00283 static MEDIAINFO_Open_NextPacket MediaInfo_Open_NextPacket; 00284 typedef void (__stdcall *MEDIAINFO_Close)(void*); 00285 static MEDIAINFO_Close MediaInfo_Close; 00286 typedef void (__stdcall *MEDIAINFOLIST_Close)(void*, size_t); 00287 static MEDIAINFOLIST_Close MediaInfoList_Close; 00288 typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Inform)(void*, size_t Reserved); 00289 static MEDIAINFO_Inform MediaInfo_Inform; 00290 typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Inform)(void*, size_t, size_t Reserved); 00291 static MEDIAINFOLIST_Inform MediaInfoList_Inform; 00292 typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_GetI)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo); 00293 static MEDIAINFO_GetI MediaInfo_GetI; 00294 typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_GetI)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo); 00295 static MEDIAINFOLIST_GetI MediaInfoList_GetI; 00296 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); 00297 static MEDIAINFO_Get MediaInfo_Get; 00298 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); 00299 static MEDIAINFOLIST_Get MediaInfoList_Get; 00300 typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_Get)(void*, const MediaInfo_Char* Parameter); 00301 static MEDIAINFO_Output_Buffer_Get MediaInfo_Output_Buffer_Get; 00302 typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_GetI)(void*, size_t Pos); 00303 static MEDIAINFO_Output_Buffer_GetI MediaInfo_Output_Buffer_GetI; 00304 typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value); 00305 static MEDIAINFO_Option MediaInfo_Option; 00306 typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value); 00307 static MEDIAINFOLIST_Option MediaInfoList_Option; 00308 typedef size_t (__stdcall *MEDIAINFO_State_Get)(void*); 00309 static MEDIAINFO_State_Get MediaInfo_State_Get; 00310 typedef size_t (__stdcall *MEDIAINFOLIST_State_Get)(void*); 00311 static MEDIAINFOLIST_State_Get MediaInfoList_State_Get; 00312 typedef size_t (__stdcall *MEDIAINFO_Count_Get)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber); 00313 static MEDIAINFO_Count_Get MediaInfo_Count_Get; 00314 typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber); 00315 static MEDIAINFOLIST_Count_Get MediaInfoList_Count_Get; 00316 typedef size_t (__stdcall *MEDIAINFO_Count_Get_Files)(void*); 00317 static MEDIAINFO_Count_Get_Files MediaInfo_Count_Get_Files; 00318 typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get_Files)(void*); 00319 static MEDIAINFOLIST_Count_Get_Files MediaInfoList_Count_Get_Files; 00320 00321 static size_t MediaInfoDLL_Load() 00322 { 00323 size_t Errors = 0; 00324 00325 if (Module_Count > 0) { 00326 Module_Count++; 00327 return 1; 00328 } 00329 00330 /* Load library */ 00331 #ifdef MEDIAINFO_GLIBC 00332 MediaInfo_Module = g_module_open(MEDIAINFODLL_NAME, G_MODULE_BIND_LAZY); 00333 #elif defined(_WIN32) || defined(WIN32) 00334 MediaInfo_Module = LoadLibrary(MEDIAINFODLL_NAME); 00335 #else 00336 MediaInfo_Module = dlopen(MEDIAINFODLL_NAME, RTLD_LAZY); 00337 if (!MediaInfo_Module) 00338 MediaInfo_Module = dlopen("./" MEDIAINFODLL_NAME, RTLD_LAZY); 00339 if (!MediaInfo_Module) 00340 MediaInfo_Module = dlopen("/usr/local/lib/" MEDIAINFODLL_NAME, RTLD_LAZY); 00341 if (!MediaInfo_Module) 00342 MediaInfo_Module = dlopen("/usr/local/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY); 00343 if (!MediaInfo_Module) 00344 MediaInfo_Module = dlopen("/usr/lib/" MEDIAINFODLL_NAME, RTLD_LAZY); 00345 if (!MediaInfo_Module) 00346 MediaInfo_Module = dlopen("/usr/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY); 00347 #endif 00348 if (!MediaInfo_Module) 00349 return (size_t) - 1; 00350 00351 /* Load methods */ 00352 MEDIAINFO_ASSIGN(New, "New") 00353 MEDIAINFOLIST_ASSIGN(New, "New") 00354 MEDIAINFO_ASSIGN(Delete, "Delete") 00355 MEDIAINFOLIST_ASSIGN(Delete, "Delete") 00356 MEDIAINFO_ASSIGN(Open, "Open") 00357 MEDIAINFOLIST_ASSIGN(Open, "Open") 00358 MEDIAINFO_ASSIGN(Open_Buffer_Init, "Open_Buffer_Init") 00359 MEDIAINFO_ASSIGN(Open_Buffer_Continue, "Open_Buffer_Continue") 00360 MEDIAINFO_ASSIGN(Open_Buffer_Continue_GoTo_Get, "Open_Buffer_Continue_GoTo_Get") 00361 MEDIAINFO_ASSIGN(Open_Buffer_Finalize, "Open_Buffer_Finalize") 00362 MEDIAINFO_ASSIGN(Open_NextPacket, "Open_NextPacket") 00363 MEDIAINFO_ASSIGN(Close, "Close") 00364 MEDIAINFOLIST_ASSIGN(Close, "Close") 00365 MEDIAINFO_ASSIGN(Inform, "Inform") 00366 MEDIAINFOLIST_ASSIGN(Inform, "Inform") 00367 MEDIAINFO_ASSIGN(GetI, "GetI") 00368 MEDIAINFOLIST_ASSIGN(GetI, "GetI") 00369 MEDIAINFO_ASSIGN(Get, "Get") 00370 MEDIAINFOLIST_ASSIGN(Get, "Get") 00371 MEDIAINFO_ASSIGN(Output_Buffer_Get, "Output_Buffer_Get") 00372 MEDIAINFO_ASSIGN(Output_Buffer_GetI, "Output_Buffer_GetI") 00373 MEDIAINFO_ASSIGN(Option, "Option") 00374 MEDIAINFOLIST_ASSIGN(Option, "Option") 00375 MEDIAINFO_ASSIGN(State_Get, "State_Get") 00376 MEDIAINFOLIST_ASSIGN(State_Get, "State_Get") 00377 MEDIAINFO_ASSIGN(Count_Get, "Count_Get") 00378 MEDIAINFOLIST_ASSIGN(Count_Get, "Count_Get") 00379 MEDIAINFOLIST_ASSIGN(Count_Get_Files, "Count_Get_Files") 00380 if (Errors > 0) { 00381 // Unload DLL with errors 00382 #ifdef MEDIAINFO_GLIBC 00383 g_module_close(MediaInfo_Module); 00384 #elif defined(_WIN32) || defined(WIN32) 00385 FreeLibrary(MediaInfo_Module); 00386 #else 00387 dlclose(MediaInfo_Module); 00388 #endif 00389 MediaInfo_Module = NULL; 00390 return (size_t) - 1; 00391 } 00392 00393 Module_Count++; 00394 return (size_t)1; 00395 } 00396 00397 static size_t MediaInfoDLL_IsLoaded() 00398 { 00399 if (MediaInfo_Module) 00400 return 1; 00401 else 00402 return 0; 00403 } 00404 00405 static void MediaInfoDLL_UnLoad() 00406 { 00407 Module_Count--; 00408 if (Module_Count > 0) 00409 return; 00410 00411 #ifdef MEDIAINFO_GLIBC 00412 g_module_close(MediaInfo_Module); 00413 #elif defined(_WIN32) || defined(WIN32) 00414 FreeLibrary(MediaInfo_Module); 00415 #else 00416 dlclose(MediaInfo_Module); 00417 #endif 00418 MediaInfo_Module = NULL; 00419 } 00420 00421 #ifdef __cplusplus 00422 } 00423 #endif /*__cplusplus*/ 00424 00425 /***************************************************************************/ 00426 /***************************************************************************/ 00427 /***************************************************************************/ 00428 00429 #ifdef __cplusplus 00430 //DLL C++ wrapper for C functions 00431 00432 //--------------------------------------------------------------------------- 00433 #include <string> 00434 #include <sstream> 00435 //--------------------------------------------------------------------------- 00436 00437 namespace MediaInfoDLL 00438 { 00439 00440 //--------------------------------------------------------------------------- 00441 //MediaInfo_Char types 00442 #undef __T 00443 #define __T(__x) __T(__x) 00444 #if defined(UNICODE) || defined(_UNICODE) 00445 typedef wchar_t Char; 00446 #undef __T 00447 #define __T(__x) L ## __x 00448 #else 00449 typedef char Char; 00450 #undef __T 00451 #define __T(__x) __x 00452 #endif 00453 typedef std::basic_string<Char> String; 00454 typedef std::basic_stringstream<Char> StringStream; 00455 typedef std::basic_istringstream<Char> iStringStream; 00456 typedef std::basic_ostringstream<Char> oStringStream; 00457 typedef std::basic_istringstream<Char> tiStringStream; // Legacy 00458 typedef std::basic_ostringstream<Char> toStringStream; //Legacy 00459 const size_t Error = (size_t)(-1); 00460 //--------------------------------------------------------------------------- 00461 00462 //--------------------------------------------------------------------------- 00464 enum stream_t { 00465 Stream_General, 00466 Stream_Video, 00467 Stream_Audio, 00468 Stream_Text, 00469 Stream_Other, 00470 Stream_Image, 00471 Stream_Menu, 00472 Stream_Max 00473 }; 00474 00476 enum info_t { 00477 Info_Name, 00478 Info_Text, 00479 Info_Measure, 00480 Info_Options, 00481 Info_Name_Text, 00482 Info_Measure_Text, 00483 Info_Info, 00484 Info_HowTo, 00485 Info_Max 00486 }; 00487 00492 enum infooptions_t { 00493 InfoOption_ShowInInform, 00494 InfoOption_Reserved, 00495 InfoOption_ShowInSupported, 00496 InfoOption_TypeOfValue, 00497 InfoOption_Max 00498 }; 00499 00501 enum fileoptions_t { 00502 FileOption_Nothing = 0x00, 00503 FileOption_NoRecursive = 0x01, 00504 FileOption_CloseAll = 0x02, 00505 FileOption_Max = 0x04 00506 }; 00507 00508 const String Unable_Load_DLL = __T("Unable to load ")MEDIAINFODLL_NAME; 00509 #define MEDIAINFO_TEST_VOID \ 00510 if (!IsReady()) return 00511 #define MEDIAINFO_TEST_INT \ 00512 if (!IsReady()) return 0 00513 #define MEDIAINFO_TEST_STRING \ 00514 if (!IsReady()) return Unable_Load_DLL 00515 #define MEDIAINFO_TEST_STRING_STATIC \ 00516 if (!MediaInfo_Module) return Unable_Load_DLL 00517 00518 //--------------------------------------------------------------------------- 00519 class MediaInfo 00520 { 00521 public : 00522 MediaInfo() {if (!MediaInfo_Module) MediaInfoDLL_Load(); if (!MediaInfo_Module) {Handle = NULL; return;}; Handle = MediaInfo_New();}; 00523 ~MediaInfo() {MEDIAINFO_TEST_VOID; MediaInfo_Delete(Handle);}; 00524 00525 //File 00526 size_t Open(const String &File) {MEDIAINFO_TEST_INT; return MediaInfo_Open(Handle, File.c_str());}; 00527 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);}; 00528 size_t Open_Buffer_Continue(MediaInfo_int8u* Buffer, size_t Buffer_Size) {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue(Handle, Buffer, Buffer_Size);}; 00529 MediaInfo_int64u Open_Buffer_Continue_GoTo_Get() {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue_GoTo_Get(Handle);}; 00530 size_t Open_Buffer_Finalize() {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Finalize(Handle);}; 00531 size_t Open_NextPacket() {MEDIAINFO_TEST_INT; return MediaInfo_Open_NextPacket(Handle);}; 00532 //size_t Save () {MEDIAINFO_TEST_INT; return MediaInfo_Save(Handle);}; 00533 void Close() {MEDIAINFO_TEST_VOID; return MediaInfo_Close(Handle);}; 00534 00535 //General information 00536 String Inform() {MEDIAINFO_TEST_STRING; return MediaInfo_Inform(Handle, 0);}; 00537 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);}; 00538 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);}; 00539 //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());}; 00540 //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());}; 00541 size_t Output_Buffer_Get(const String &Value) {return MediaInfo_Output_Buffer_Get(Handle, Value.c_str());} 00542 size_t Output_Buffer_Get(size_t Pos) {return MediaInfo_Output_Buffer_GetI(Handle, Pos);} 00543 String Option(const String &Option, const String &Value = __T("")) {MEDIAINFO_TEST_STRING; return MediaInfo_Option(Handle, Option.c_str(), Value.c_str());}; 00544 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());}; 00545 size_t State_Get() {MEDIAINFO_TEST_INT; return MediaInfo_State_Get(Handle);}; 00546 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);}; 00547 00548 bool IsReady() {return (Handle && MediaInfo_Module) ? true : false;} 00549 00550 private : 00551 void* Handle; 00552 }; 00553 00554 class MediaInfoList 00555 { 00556 public : 00557 MediaInfoList() {MediaInfoDLL_Load(); if (!MediaInfoDLL_IsLoaded()) {Handle = NULL; return;}; Handle = MediaInfoList_New();}; 00558 ~MediaInfoList() {MEDIAINFO_TEST_VOID; MediaInfoList_Delete(Handle); MediaInfoDLL_UnLoad();}; 00559 00560 //File 00561 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);}; 00562 //size_t Save (size_t FilePos) {MEDIAINFO_TEST_INT; return MediaInfoList_Save(Handle, FilePos);}; 00563 void Close(size_t FilePos = (size_t) - 1) {MEDIAINFO_TEST_VOID; return MediaInfoList_Close(Handle, FilePos);}; 00564 00565 //General information 00566 String Inform(size_t FilePos = (size_t) - 1) {MEDIAINFO_TEST_STRING; return MediaInfoList_Inform(Handle, FilePos, 0);}; 00567 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);}; 00568 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);}; 00569 //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());}; 00570 //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());}; 00571 String Option(const String &Option, const String &Value = __T("")) {MEDIAINFO_TEST_STRING; return MediaInfoList_Option(Handle, Option.c_str(), Value.c_str());}; 00572 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());}; 00573 size_t State_Get() {MEDIAINFO_TEST_INT; return MediaInfoList_State_Get(Handle);}; 00574 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);}; 00575 size_t Count_Get() {MEDIAINFO_TEST_INT; return MediaInfoList_Count_Get_Files(Handle);}; 00576 00577 bool IsReady() {return (Handle && MediaInfo_Module) ? true : false;} 00578 00579 private : 00580 void* Handle; 00581 }; 00582 00583 } //NameSpace 00584 #endif /*__cplusplus*/ 00585 00586 #endif