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