MediaInfoLib  0.7
MediaInfoDLL.h
1 /* MediaInfoDLL - All info about media files, for DLL
2 // Copyright (C) 2002-2012 MediaArea.net SARL, Info@MediaArea.net
3 //
4 // This library is free software: you can redistribute it and/or modify it
5 // under the terms of the GNU Library General Public License as published by
6 // the Free Software Foundation, either version 2 of the License, or
7 // any later version.
8 //
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Library General Public License for more details.
13 //
14 // You should have received a copy of the GNU Library General Public License
15 // along with this library. If not, see <http://www.gnu.org/licenses/>.
16 //
17 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
18 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19 //
20 // Public DLL interface implementation
21 // Wrapper for MediaInfo Library
22 // See MediaInfo.h for help
23 //
24 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
25 
26 #ifndef MediaInfoDLLH
27 #define MediaInfoDLLH
28 
29 //***************************************************************************
30 // Platforms (from libzen)
31 //***************************************************************************
32 
33 /*---------------------------------------------------------------------------*/
34 /*Win32*/
35 #if defined(__NT__) || defined(_WIN32) || defined(WIN32)
36  #ifndef WIN32
37  #define WIN32
38  #endif
39  #ifndef _WIN32
40  #define _WIN32
41  #endif
42  #ifndef __WIN32__
43  #define __WIN32__ 1
44  #endif
45 #endif
46 
47 /*---------------------------------------------------------------------------*/
48 /*Win64*/
49 #if defined(_WIN64) || defined(WIN64)
50  #ifndef WIN64
51  #define WIN64
52  #endif
53  #ifndef _WIN64
54  #define _WIN64
55  #endif
56  #ifndef __WIN64__
57  #define __WIN64__ 1
58  #endif
59 #endif
60 
61 /*---------------------------------------------------------------------------*/
62 /*Windows*/
63 #if defined(WIN32) || defined(WIN64)
64  #ifndef WINDOWS
65  #define WINDOWS
66  #endif
67  #ifndef _WINDOWS
68  #define _WINDOWS
69  #endif
70  #ifndef __WINDOWS__
71  #define __WINDOWS__ 1
72  #endif
73 #endif
74 
75 /*---------------------------------------------------------------------------*/
76 /*Unix (Linux, HP, Sun, BeOS...)*/
77 #if defined(UNIX) || defined(_UNIX) || defined(__UNIX__) \
78  || defined(__unix) || defined(__unix__) \
79  || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) \
80  || defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) \
81  || defined(__EMX__) || defined(__VMS) || defined(__BEOS__)
82  #ifndef UNIX
83  #define UNIX
84  #endif
85  #ifndef _UNIX
86  #define _UNIX
87  #endif
88  #ifndef __UNIX__
89  #define __UNIX__ 1
90  #endif
91 #endif
92 
93 /*---------------------------------------------------------------------------*/
94 /*MacOS Classic*/
95 #if defined(macintosh)
96  #ifndef MACOS
97  #define MACOS
98  #endif
99  #ifndef _MACOS
100  #define _MACOS
101  #endif
102  #ifndef __MACOS__
103  #define __MACOS__ 1
104  #endif
105 #endif
106 
107 /*---------------------------------------------------------------------------*/
108 /*MacOS X*/
109 #if defined(__APPLE__) && defined(__MACH__)
110  #ifndef MACOSX
111  #define MACOSX
112  #endif
113  #ifndef _MACOSX
114  #define _MACOSX
115  #endif
116  #ifndef __MACOSX__
117  #define __MACOSX__ 1
118  #endif
119 #endif
120 
121 /*Test of targets*/
122 #if defined(WINDOWS) && defined(UNIX) && defined(MACOS) && defined(MACOSX)
123  #pragma message Multiple platforms???
124 #endif
125 
126 #if !defined(WIN32) && !defined(UNIX) && !defined(MACOS) && !defined(MACOSX)
127  #pragma message No known platforms, assume default
128 #endif
129 
130 /*-------------------------------------------------------------------------*/
131 #if defined (_WIN32) || defined (WIN32)
132  #ifdef _UNICODE
133  #define MEDIAINFODLL_NAME L"MediaInfo.dll"
134  #else //_UNICODE
135  #define MEDIAINFODLL_NAME "MediaInfo.dll"
136  #endif //_UNICODE
137 #elif defined(__APPLE__) && defined(__MACH__)
138  #define MEDIAINFODLL_NAME "libmediainfo.0.dylib"
139  #define __stdcall
140 #else
141  #define MEDIAINFODLL_NAME "libmediainfo.so.0"
142  #define __stdcall
143 #endif
144 
145 /*-------------------------------------------------------------------------*/
146 /*Char types */
147 #undef __T
148 #define __T(__x) __T(__x)
149 #if defined(UNICODE) || defined (_UNICODE)
150  typedef wchar_t MediaInfo_Char;
151  #undef __T
152  #define __T(__x) L ## __x
153  #define MEDIAINFO_Ansi ""
154 #else
155  typedef char MediaInfo_Char;
156  #undef __T
157  #define __T(__x) __x
158  #define MEDIAINFO_Ansi "A"
159 #endif
160 /*-------------------------------------------------------------------------*/
161 
162 /*-------------------------------------------------------------------------*/
163 /*8-bit int */
164 typedef unsigned char MediaInfo_int8u;
165 /*-------------------------------------------------------------------------*/
166 
167 /*-------------------------------------------------------------------------*/
168 /*64-bit int */
169 #if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__) || defined(__MACOSX__)
170  #undef MAXTYPE_INT
171  #define MAXTYPE_INT 64
172  typedef unsigned long long MediaInfo_int64u;
173 #elif defined(__WIN32__) || defined(_WIN32)
174  #undef MAXTYPE_INT
175  #define MAXTYPE_INT 64
176  typedef unsigned __int64 MediaInfo_int64u;
177 #else
178  #pragma message This machine has no 64-bit integer type?
179 #endif
180 /*-------------------------------------------------------------------------*/
181 
182 /*-------------------------------------------------------------------------*/
183 /*NULL */
184 #ifndef NULL
185  #define NULL 0
186 #endif
187 /*-------------------------------------------------------------------------*/
188 
190 typedef enum MediaInfo_stream_t {
191  MediaInfo_Stream_General,
192  MediaInfo_Stream_Video,
193  MediaInfo_Stream_Audio,
194  MediaInfo_Stream_Text,
195  MediaInfo_Stream_Other,
196  MediaInfo_Stream_Image,
197  MediaInfo_Stream_Menu,
198  MediaInfo_Stream_Max
199 } MediaInfo_stream_C;
200 
202 typedef enum MediaInfo_info_t {
203  MediaInfo_Info_Name,
204  MediaInfo_Info_Text,
205  MediaInfo_Info_Measure,
206  MediaInfo_Info_Options,
207  MediaInfo_Info_Name_Text,
208  MediaInfo_Info_Measure_Text,
209  MediaInfo_Info_Info,
210  MediaInfo_Info_HowTo,
211  MediaInfo_Info_Max
212 } MediaInfo_info_C;
213 
215 typedef enum MediaInfo_infooptions_t {
216  MediaInfo_InfoOption_ShowInInform,
217  MediaInfo_InfoOption_Reserved,
218  MediaInfo_InfoOption_ShowInSupported,
219  MediaInfo_InfoOption_TypeOfValue,
220  MediaInfo_InfoOption_Max
221 } MediaInfo_infooptions_C;
222 
224 typedef enum MediaInfo_fileoptions_t {
225  MediaInfo_FileOption_Nothing = 0x00,
226  MediaInfo_FileOption_NoRecursive = 0x01,
227  MediaInfo_FileOption_CloseAll = 0x02,
228  MediaInfo_FileOption_Max = 0x04
229 } MediaInfo_fileoptions_C;
230 
231 
232 #ifdef __cplusplus
233 extern "C"
234 {
235 #endif /* __cplusplus */
236 
237 #ifdef MEDIAINFO_GLIBC
238  #include <gmodule.h>
239  static GModule* MediaInfo_Module = NULL;
240 #elif defined (_WIN32) || defined (WIN32)
241  #include <windows.h>
242  static HMODULE MediaInfo_Module = NULL;
243 #else
244  #include <dlfcn.h>
245  static void* MediaInfo_Module = NULL;
246 #endif
247  static size_t Module_Count = 0;
248 
249 #ifdef MEDIAINFO_GLIBC
250 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
251  if (!g_module_symbol (MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfo_##_Name)) \
252  Errors++;
253 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
254  if (!g_module_symbol (MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfoList_##_Name)) \
255  Errors++;
256 #elif defined (_WIN32) || defined (WIN32)
257 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
258  MediaInfo_##_Name=(MEDIAINFO_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \
259  if (MediaInfo_##_Name==NULL) Errors++;
260 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
261  MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \
262  if (MediaInfoList_##_Name==NULL) Errors++;
263 #else
264 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
265  MediaInfo_##_Name=(MEDIAINFO_##_Name)dlsym(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \
266  if (MediaInfo_##_Name==NULL) Errors++;
267 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
268  MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)dlsym(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \
269  if (MediaInfoList_##_Name==NULL) Errors++;
270 #endif
271 
272  typedef void* (__stdcall *MEDIAINFO_New)();
273  static MEDIAINFO_New MediaInfo_New;
274  typedef void* (__stdcall *MEDIAINFOLIST_New)();
275  static MEDIAINFOLIST_New MediaInfoList_New;
276  typedef void (__stdcall *MEDIAINFO_Delete)(void*);
277  static MEDIAINFO_Delete MediaInfo_Delete;
278  typedef void (__stdcall *MEDIAINFOLIST_Delete)(void*);
279  static MEDIAINFOLIST_Delete MediaInfoList_Delete;
280  typedef size_t (__stdcall *MEDIAINFO_Open)(void*, const MediaInfo_Char*);
281  static MEDIAINFO_Open MediaInfo_Open;
282  typedef size_t (__stdcall *MEDIAINFOLIST_Open)(void*, const MediaInfo_Char*, const MediaInfo_fileoptions_C);
283  static MEDIAINFOLIST_Open MediaInfoList_Open;
284  typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Init)(void*, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset);
285  static MEDIAINFO_Open_Buffer_Init MediaInfo_Open_Buffer_Init;
286  typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Continue)(void*, MediaInfo_int8u* Buffer, size_t Buffer_Size);
287  static MEDIAINFO_Open_Buffer_Continue MediaInfo_Open_Buffer_Continue;
288  typedef MediaInfo_int64u(__stdcall *MEDIAINFO_Open_Buffer_Continue_GoTo_Get)(void*);
289  static MEDIAINFO_Open_Buffer_Continue_GoTo_Get MediaInfo_Open_Buffer_Continue_GoTo_Get;
290  typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Finalize)(void*);
291  static MEDIAINFO_Open_Buffer_Finalize MediaInfo_Open_Buffer_Finalize;
292  typedef size_t (__stdcall *MEDIAINFO_Open_NextPacket)(void*);
293  static MEDIAINFO_Open_NextPacket MediaInfo_Open_NextPacket;
294  typedef void (__stdcall *MEDIAINFO_Close)(void*);
295  static MEDIAINFO_Close MediaInfo_Close;
296  typedef void (__stdcall *MEDIAINFOLIST_Close)(void*, size_t);
297  static MEDIAINFOLIST_Close MediaInfoList_Close;
298  typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Inform)(void*, size_t Reserved);
299  static MEDIAINFO_Inform MediaInfo_Inform;
300  typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Inform)(void*, size_t, size_t Reserved);
301  static MEDIAINFOLIST_Inform MediaInfoList_Inform;
302  typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_GetI)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo);
303  static MEDIAINFO_GetI MediaInfo_GetI;
304  typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_GetI)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo);
305  static MEDIAINFOLIST_GetI MediaInfoList_GetI;
306  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);
307  static MEDIAINFO_Get MediaInfo_Get;
308  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);
309  static MEDIAINFOLIST_Get MediaInfoList_Get;
310  typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_Get)(void*, const MediaInfo_Char* Parameter);
311  static MEDIAINFO_Output_Buffer_Get MediaInfo_Output_Buffer_Get;
312  typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_GetI)(void*, size_t Pos);
313  static MEDIAINFO_Output_Buffer_GetI MediaInfo_Output_Buffer_GetI;
314  typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value);
315  static MEDIAINFO_Option MediaInfo_Option;
316  typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value);
317  static MEDIAINFOLIST_Option MediaInfoList_Option;
318  typedef size_t (__stdcall *MEDIAINFO_State_Get)(void*);
319  static MEDIAINFO_State_Get MediaInfo_State_Get;
320  typedef size_t (__stdcall *MEDIAINFOLIST_State_Get)(void*);
321  static MEDIAINFOLIST_State_Get MediaInfoList_State_Get;
322  typedef size_t (__stdcall *MEDIAINFO_Count_Get)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber);
323  static MEDIAINFO_Count_Get MediaInfo_Count_Get;
324  typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber);
325  static MEDIAINFOLIST_Count_Get MediaInfoList_Count_Get;
326  typedef size_t (__stdcall *MEDIAINFO_Count_Get_Files)(void*);
327  static MEDIAINFO_Count_Get_Files MediaInfo_Count_Get_Files;
328  typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get_Files)(void*);
329  static MEDIAINFOLIST_Count_Get_Files MediaInfoList_Count_Get_Files;
330 
331  static size_t MediaInfoDLL_Load()
332  {
333  size_t Errors = 0;
334 
335  if (Module_Count > 0) {
336  Module_Count++;
337  return 1;
338  }
339 
340  /* Load library */
341  #ifdef MEDIAINFO_GLIBC
342  MediaInfo_Module = g_module_open(MEDIAINFODLL_NAME, G_MODULE_BIND_LAZY);
343  #elif defined (_WIN32) || defined (WIN32)
344  MediaInfo_Module = LoadLibrary(MEDIAINFODLL_NAME);
345  #else
346  MediaInfo_Module = dlopen(MEDIAINFODLL_NAME, RTLD_LAZY);
347  if (!MediaInfo_Module)
348  MediaInfo_Module = dlopen("./" MEDIAINFODLL_NAME, RTLD_LAZY);
349  if (!MediaInfo_Module)
350  MediaInfo_Module = dlopen("/usr/local/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
351  if (!MediaInfo_Module)
352  MediaInfo_Module = dlopen("/usr/local/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
353  if (!MediaInfo_Module)
354  MediaInfo_Module = dlopen("/usr/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
355  if (!MediaInfo_Module)
356  MediaInfo_Module = dlopen("/usr/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
357  #endif
358  if (!MediaInfo_Module)
359  return (size_t) - 1;
360 
361  /* Load methods */
362  MEDIAINFO_ASSIGN(New, "New")
363  MEDIAINFOLIST_ASSIGN(New, "New")
364  MEDIAINFO_ASSIGN(Delete, "Delete")
365  MEDIAINFOLIST_ASSIGN(Delete, "Delete")
366  MEDIAINFO_ASSIGN(Open, "Open")
367  MEDIAINFOLIST_ASSIGN(Open, "Open")
368  MEDIAINFO_ASSIGN(Open_Buffer_Init, "Open_Buffer_Init")
369  MEDIAINFO_ASSIGN(Open_Buffer_Continue, "Open_Buffer_Continue")
370  MEDIAINFO_ASSIGN(Open_Buffer_Continue_GoTo_Get, "Open_Buffer_Continue_GoTo_Get")
371  MEDIAINFO_ASSIGN(Open_Buffer_Finalize, "Open_Buffer_Finalize")
372  MEDIAINFO_ASSIGN(Open_NextPacket, "Open_NextPacket")
373  MEDIAINFO_ASSIGN(Close, "Close")
374  MEDIAINFOLIST_ASSIGN(Close, "Close")
375  MEDIAINFO_ASSIGN(Inform, "Inform")
376  MEDIAINFOLIST_ASSIGN(Inform, "Inform")
377  MEDIAINFO_ASSIGN(GetI, "GetI")
378  MEDIAINFOLIST_ASSIGN(GetI, "GetI")
379  MEDIAINFO_ASSIGN(Get, "Get")
380  MEDIAINFOLIST_ASSIGN(Get, "Get")
381  MEDIAINFO_ASSIGN(Output_Buffer_Get, "Output_Buffer_Get")
382  MEDIAINFO_ASSIGN(Output_Buffer_GetI, "Output_Buffer_GetI")
383  MEDIAINFO_ASSIGN(Option, "Option")
384  MEDIAINFOLIST_ASSIGN(Option, "Option")
385  MEDIAINFO_ASSIGN(State_Get, "State_Get")
386  MEDIAINFOLIST_ASSIGN(State_Get, "State_Get")
387  MEDIAINFO_ASSIGN(Count_Get, "Count_Get")
388  MEDIAINFOLIST_ASSIGN(Count_Get, "Count_Get")
389  MEDIAINFOLIST_ASSIGN(Count_Get_Files, "Count_Get_Files")
390  if (Errors > 0) {
391  // Unload DLL with errors
392  #ifdef MEDIAINFO_GLIBC
393  g_module_close(MediaInfo_Module);
394  #elif defined (_WIN32) || defined (WIN32)
395  FreeLibrary(MediaInfo_Module);
396  #else
397  dlclose(MediaInfo_Module);
398  #endif
399  MediaInfo_Module = NULL;
400  return (size_t) - 1;
401  }
402 
403  Module_Count++;
404  return (size_t)1;
405  }
406 
407  static size_t MediaInfoDLL_IsLoaded()
408  {
409  if (MediaInfo_Module)
410  return 1;
411  else
412  return 0;
413  }
414 
415  static void MediaInfoDLL_UnLoad()
416  {
417  Module_Count--;
418  if (Module_Count > 0)
419  return;
420 
421  #ifdef MEDIAINFO_GLIBC
422  g_module_close(MediaInfo_Module);
423  #elif defined (_WIN32) || defined (WIN32)
424  FreeLibrary(MediaInfo_Module);
425  #else
426  dlclose(MediaInfo_Module);
427  #endif
428  MediaInfo_Module = NULL;
429  }
430 
431 #ifdef __cplusplus
432 }
433 #endif /*__cplusplus*/
434 
435 /***************************************************************************/
436 /***************************************************************************/
437 /***************************************************************************/
438 
439 #ifdef __cplusplus
440 //DLL C++ wrapper for C functions
441 
442 //---------------------------------------------------------------------------
443 #include <string>
444 #include <sstream>
445 //---------------------------------------------------------------------------
446 
447 namespace MediaInfoDLL
448 {
449 
450  //---------------------------------------------------------------------------
451  //MediaInfo_Char types
452 #undef __T
453 #define __T(__x) __T(__x)
454 #if defined(UNICODE) || defined (_UNICODE)
455  typedef wchar_t Char;
456  #undef __T
457  #define __T(__x) L ## __x
458 #else
459  typedef char Char;
460  #undef __T
461  #define __T(__x) __x
462 #endif
463  typedef std::basic_string<Char> String;
464  typedef std::basic_stringstream<Char> StringStream;
465  typedef std::basic_istringstream<Char> iStringStream;
466  typedef std::basic_ostringstream<Char> oStringStream;
467  typedef std::basic_istringstream<Char> tiStringStream; // Legacy
468  typedef std::basic_ostringstream<Char> toStringStream; //Legacy
469  const size_t Error = (size_t)(-1);
470  //---------------------------------------------------------------------------
471 
472  //---------------------------------------------------------------------------
474  enum stream_t {
476  Stream_Video,
477  Stream_Audio,
478  Stream_Text,
479  Stream_Other,
480  Stream_Image,
481  Stream_Menu,
482  Stream_Max
483  };
484 
486  enum info_t {
487  Info_Name,
488  Info_Text,
489  Info_Measure,
490  Info_Options,
493  Info_Info,
494  Info_HowTo,
495  Info_Max
496  };
497 
502  enum infooptions_t {
504  InfoOption_Reserved,
507  InfoOption_Max
508  };
509 
511  enum fileoptions_t {
512  FileOption_Nothing = 0x00,
513  FileOption_NoRecursive = 0x01,
514  FileOption_CloseAll = 0x02,
515  FileOption_Max = 0x04
516  };
517 
518  const String Unable_Load_DLL = __T("Unable to load ")MEDIAINFODLL_NAME;
519 #define MEDIAINFO_TEST_VOID \
520  if (!IsReady()) return
521 #define MEDIAINFO_TEST_INT \
522  if (!IsReady()) return 0
523 #define MEDIAINFO_TEST_STRING \
524  if (!IsReady()) return Unable_Load_DLL
525 #define MEDIAINFO_TEST_STRING_STATIC \
526  if (!MediaInfo_Module) return Unable_Load_DLL
527 
528  //---------------------------------------------------------------------------
529  class MediaInfo
530  {
531  public :
532  MediaInfo() {if (!MediaInfo_Module) MediaInfoDLL_Load(); if (!MediaInfo_Module) {Handle = NULL; return;}; Handle = MediaInfo_New();};
533  ~MediaInfo() {MEDIAINFO_TEST_VOID; MediaInfo_Delete(Handle);};
534 
535  //File
536  size_t Open(const String &File) {MEDIAINFO_TEST_INT; return MediaInfo_Open(Handle, File.c_str());};
537  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);};
538  size_t Open_Buffer_Continue(MediaInfo_int8u* Buffer, size_t Buffer_Size) {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue(Handle, Buffer, Buffer_Size);};
539  MediaInfo_int64u Open_Buffer_Continue_GoTo_Get() {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue_GoTo_Get(Handle);};
540  size_t Open_Buffer_Finalize() {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Finalize(Handle);};
541  size_t Open_NextPacket() {MEDIAINFO_TEST_INT; return MediaInfo_Open_NextPacket(Handle);};
542  //size_t Save () {MEDIAINFO_TEST_INT; return MediaInfo_Save(Handle);};
543  void Close() {MEDIAINFO_TEST_VOID; return MediaInfo_Close(Handle);};
544 
545  //General information
546  String Inform() {MEDIAINFO_TEST_STRING; return MediaInfo_Inform(Handle, 0);};
547  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);};
548  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);};
549  //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());};
550  //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());};
551  size_t Output_Buffer_Get(const String &Value) {return MediaInfo_Output_Buffer_Get(Handle, Value.c_str());}
552  size_t Output_Buffer_Get(size_t Pos) {return MediaInfo_Output_Buffer_GetI(Handle, Pos);}
553  String Option(const String &Option, const String &Value = __T("")) {MEDIAINFO_TEST_STRING; return MediaInfo_Option(Handle, Option.c_str(), Value.c_str());};
554  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());};
555  size_t State_Get() {MEDIAINFO_TEST_INT; return MediaInfo_State_Get(Handle);};
556  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);};
557 
558  bool IsReady() {return (Handle && MediaInfo_Module) ? true : false;}
559 
560  private :
561  void* Handle;
562  };
563 
564  class MediaInfoList
565  {
566  public :
567  MediaInfoList() {MediaInfoDLL_Load(); if (!MediaInfoDLL_IsLoaded()) {Handle = NULL; return;}; Handle = MediaInfoList_New();};
568  ~MediaInfoList() {MEDIAINFO_TEST_VOID; MediaInfoList_Delete(Handle); MediaInfoDLL_UnLoad();};
569 
570  //File
571  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);};
572  //size_t Save (size_t FilePos) {MEDIAINFO_TEST_INT; return MediaInfoList_Save(Handle, FilePos);};
573  void Close(size_t FilePos = (size_t) - 1) {MEDIAINFO_TEST_VOID; return MediaInfoList_Close(Handle, FilePos);};
574 
575  //General information
576  String Inform(size_t FilePos = (size_t) - 1) {MEDIAINFO_TEST_STRING; return MediaInfoList_Inform(Handle, FilePos, 0);};
577  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);};
578  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);};
579  //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());};
580  //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());};
581  String Option(const String &Option, const String &Value = __T("")) {MEDIAINFO_TEST_STRING; return MediaInfoList_Option(Handle, Option.c_str(), Value.c_str());};
582  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());};
583  size_t State_Get() {MEDIAINFO_TEST_INT; return MediaInfoList_State_Get(Handle);};
584  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);};
585  size_t Count_Get() {MEDIAINFO_TEST_INT; return MediaInfoList_Count_Get_Files(Handle);};
586 
587  bool IsReady() {return (Handle && MediaInfo_Module) ? true : false;}
588 
589  private :
590  void* Handle;
591  };
592 
593 } //NameSpace
594 #endif /*__cplusplus*/
595 
596 #endif