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  #include <new> //for size_t
133 #endif
134 
135 /*-------------------------------------------------------------------------*/
136 /*Char types */
137 #undef __T
138 #define __T(__x) __T(__x)
139 #if defined(UNICODE) || defined(_UNICODE)
140  typedef wchar_t MediaInfo_Char;
141  #undef __T
142  #define __T(__x) L ## __x
143  #define MEDIAINFO_Ansi ""
144 #else
145  typedef char MediaInfo_Char;
146  #undef __T
147  #define __T(__x) __x
148  #define MEDIAINFO_Ansi "A"
149 #endif
150 /*-------------------------------------------------------------------------*/
151 
152 /*-------------------------------------------------------------------------*/
153 /*8-bit int */
154 typedef unsigned char MediaInfo_int8u;
155 /*-------------------------------------------------------------------------*/
156 
157 /*-------------------------------------------------------------------------*/
158 /*64-bit int */
159 #if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__) || defined(__MACOSX__)
160  #undef MAXTYPE_INT
161  #define MAXTYPE_INT 64
162  typedef unsigned long long MediaInfo_int64u;
163 #elif defined(__WIN32__) || defined(_WIN32)
164  #undef MAXTYPE_INT
165  #define MAXTYPE_INT 64
166  typedef unsigned __int64 MediaInfo_int64u;
167 #else
168  #pragma message This machine has no 64-bit integer type?
169 #endif
170 /*-------------------------------------------------------------------------*/
171 
172 /*-------------------------------------------------------------------------*/
173 /*NULL */
174 #ifndef NULL
175  #define NULL 0
176 #endif
177 /*-------------------------------------------------------------------------*/
178 
180 typedef enum MediaInfo_stream_t {
181  MediaInfo_Stream_General,
182  MediaInfo_Stream_Video,
183  MediaInfo_Stream_Audio,
184  MediaInfo_Stream_Text,
185  MediaInfo_Stream_Other,
186  MediaInfo_Stream_Image,
187  MediaInfo_Stream_Menu,
188  MediaInfo_Stream_Max
189 } MediaInfo_stream_C;
190 
192 typedef enum MediaInfo_info_t {
193  MediaInfo_Info_Name,
194  MediaInfo_Info_Text,
195  MediaInfo_Info_Measure,
196  MediaInfo_Info_Options,
197  MediaInfo_Info_Name_Text,
198  MediaInfo_Info_Measure_Text,
199  MediaInfo_Info_Info,
200  MediaInfo_Info_HowTo,
201  MediaInfo_Info_Max
202 } MediaInfo_info_C;
203 
205 typedef enum MediaInfo_infooptions_t {
206  MediaInfo_InfoOption_ShowInInform,
207  MediaInfo_InfoOption_Reserved,
208  MediaInfo_InfoOption_ShowInSupported,
209  MediaInfo_InfoOption_TypeOfValue,
210  MediaInfo_InfoOption_Max
211 } MediaInfo_infooptions_C;
212 
214 typedef enum MediaInfo_fileoptions_t {
215  MediaInfo_FileOption_Nothing = 0x00,
216  MediaInfo_FileOption_NoRecursive = 0x01,
217  MediaInfo_FileOption_CloseAll = 0x02,
218  MediaInfo_FileOption_Max = 0x04
219 } MediaInfo_fileoptions_C;
220 
221 
222 #ifdef __cplusplus
223 extern "C"
224 {
225 #endif /* __cplusplus */
226 
227 #ifdef MEDIAINFO_GLIBC
228  #include <gmodule.h>
229  static GModule* MediaInfo_Module = NULL;
230 #elif defined(_WIN32) || defined(WIN32)
231  #include <windows.h>
232  static HMODULE MediaInfo_Module = NULL;
233 #else
234  #include <dlfcn.h>
235  static void* MediaInfo_Module = NULL;
236 #endif
237  static size_t Module_Count = 0;
238 
239 #ifdef MEDIAINFO_GLIBC
240 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
241  if (!g_module_symbol (MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfo_##_Name)) \
242  Errors++;
243 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
244  if (!g_module_symbol (MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfoList_##_Name)) \
245  Errors++;
246 #elif defined(_WIN32) || defined(WIN32)
247 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
248  MediaInfo_##_Name=(MEDIAINFO_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \
249  if (MediaInfo_##_Name==NULL) Errors++;
250 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
251  MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \
252  if (MediaInfoList_##_Name==NULL) Errors++;
253 #else
254 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
255  MediaInfo_##_Name=(MEDIAINFO_##_Name)dlsym(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \
256  if (MediaInfo_##_Name==NULL) Errors++;
257 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
258  MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)dlsym(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \
259  if (MediaInfoList_##_Name==NULL) Errors++;
260 #endif
261 
262  typedef void* (__stdcall *MEDIAINFO_New)();
263  static MEDIAINFO_New MediaInfo_New;
264  typedef void* (__stdcall *MEDIAINFOLIST_New)();
265  static MEDIAINFOLIST_New MediaInfoList_New;
266  typedef void (__stdcall *MEDIAINFO_Delete)(void*);
267  static MEDIAINFO_Delete MediaInfo_Delete;
268  typedef void (__stdcall *MEDIAINFOLIST_Delete)(void*);
269  static MEDIAINFOLIST_Delete MediaInfoList_Delete;
270  typedef size_t (__stdcall *MEDIAINFO_Open)(void*, const MediaInfo_Char*);
271  static MEDIAINFO_Open MediaInfo_Open;
272  typedef size_t (__stdcall *MEDIAINFOLIST_Open)(void*, const MediaInfo_Char*, const MediaInfo_fileoptions_C);
273  static MEDIAINFOLIST_Open MediaInfoList_Open;
274  typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Init)(void*, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset);
275  static MEDIAINFO_Open_Buffer_Init MediaInfo_Open_Buffer_Init;
276  typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Continue)(void*, MediaInfo_int8u* Buffer, size_t Buffer_Size);
277  static MEDIAINFO_Open_Buffer_Continue MediaInfo_Open_Buffer_Continue;
278  typedef MediaInfo_int64u(__stdcall *MEDIAINFO_Open_Buffer_Continue_GoTo_Get)(void*);
279  static MEDIAINFO_Open_Buffer_Continue_GoTo_Get MediaInfo_Open_Buffer_Continue_GoTo_Get;
280  typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Finalize)(void*);
281  static MEDIAINFO_Open_Buffer_Finalize MediaInfo_Open_Buffer_Finalize;
282  typedef size_t (__stdcall *MEDIAINFO_Open_NextPacket)(void*);
283  static MEDIAINFO_Open_NextPacket MediaInfo_Open_NextPacket;
284  typedef void (__stdcall *MEDIAINFO_Close)(void*);
285  static MEDIAINFO_Close MediaInfo_Close;
286  typedef void (__stdcall *MEDIAINFOLIST_Close)(void*, size_t);
287  static MEDIAINFOLIST_Close MediaInfoList_Close;
288  typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Inform)(void*, size_t Reserved);
289  static MEDIAINFO_Inform MediaInfo_Inform;
290  typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Inform)(void*, size_t, size_t Reserved);
291  static MEDIAINFOLIST_Inform MediaInfoList_Inform;
292  typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_GetI)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo);
293  static MEDIAINFO_GetI MediaInfo_GetI;
294  typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_GetI)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo);
295  static MEDIAINFOLIST_GetI MediaInfoList_GetI;
296  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);
297  static MEDIAINFO_Get MediaInfo_Get;
298  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);
299  static MEDIAINFOLIST_Get MediaInfoList_Get;
300  typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_Get)(void*, const MediaInfo_Char* Parameter);
301  static MEDIAINFO_Output_Buffer_Get MediaInfo_Output_Buffer_Get;
302  typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_GetI)(void*, size_t Pos);
303  static MEDIAINFO_Output_Buffer_GetI MediaInfo_Output_Buffer_GetI;
304  typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value);
305  static MEDIAINFO_Option MediaInfo_Option;
306  typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value);
307  static MEDIAINFOLIST_Option MediaInfoList_Option;
308  typedef size_t (__stdcall *MEDIAINFO_State_Get)(void*);
309  static MEDIAINFO_State_Get MediaInfo_State_Get;
310  typedef size_t (__stdcall *MEDIAINFOLIST_State_Get)(void*);
311  static MEDIAINFOLIST_State_Get MediaInfoList_State_Get;
312  typedef size_t (__stdcall *MEDIAINFO_Count_Get)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber);
313  static MEDIAINFO_Count_Get MediaInfo_Count_Get;
314  typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber);
315  static MEDIAINFOLIST_Count_Get MediaInfoList_Count_Get;
316  typedef size_t (__stdcall *MEDIAINFO_Count_Get_Files)(void*);
317  static MEDIAINFO_Count_Get_Files MediaInfo_Count_Get_Files;
318  typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get_Files)(void*);
319  static MEDIAINFOLIST_Count_Get_Files MediaInfoList_Count_Get_Files;
320 
321  static size_t MediaInfoDLL_Load()
322  {
323  size_t Errors = 0;
324 
325  if (Module_Count > 0) {
326  Module_Count++;
327  return 1;
328  }
329 
330  /* Load library */
331  #ifdef MEDIAINFO_GLIBC
332  MediaInfo_Module = g_module_open(MEDIAINFODLL_NAME, G_MODULE_BIND_LAZY);
333  #elif defined(_WIN32) || defined(WIN32)
334  MediaInfo_Module = LoadLibrary(MEDIAINFODLL_NAME);
335  #else
336  MediaInfo_Module = dlopen(MEDIAINFODLL_NAME, RTLD_LAZY);
337  if (!MediaInfo_Module)
338  MediaInfo_Module = dlopen("./" MEDIAINFODLL_NAME, RTLD_LAZY);
339  if (!MediaInfo_Module)
340  MediaInfo_Module = dlopen("/usr/local/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
341  if (!MediaInfo_Module)
342  MediaInfo_Module = dlopen("/usr/local/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
343  if (!MediaInfo_Module)
344  MediaInfo_Module = dlopen("/usr/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
345  if (!MediaInfo_Module)
346  MediaInfo_Module = dlopen("/usr/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
347  #endif
348  if (!MediaInfo_Module)
349  return (size_t) - 1;
350 
351  /* Load methods */
352  MEDIAINFO_ASSIGN(New, "New")
353  MEDIAINFOLIST_ASSIGN(New, "New")
354  MEDIAINFO_ASSIGN(Delete, "Delete")
355  MEDIAINFOLIST_ASSIGN(Delete, "Delete")
356  MEDIAINFO_ASSIGN(Open, "Open")
357  MEDIAINFOLIST_ASSIGN(Open, "Open")
358  MEDIAINFO_ASSIGN(Open_Buffer_Init, "Open_Buffer_Init")
359  MEDIAINFO_ASSIGN(Open_Buffer_Continue, "Open_Buffer_Continue")
360  MEDIAINFO_ASSIGN(Open_Buffer_Continue_GoTo_Get, "Open_Buffer_Continue_GoTo_Get")
361  MEDIAINFO_ASSIGN(Open_Buffer_Finalize, "Open_Buffer_Finalize")
362  MEDIAINFO_ASSIGN(Open_NextPacket, "Open_NextPacket")
363  MEDIAINFO_ASSIGN(Close, "Close")
364  MEDIAINFOLIST_ASSIGN(Close, "Close")
365  MEDIAINFO_ASSIGN(Inform, "Inform")
366  MEDIAINFOLIST_ASSIGN(Inform, "Inform")
367  MEDIAINFO_ASSIGN(GetI, "GetI")
368  MEDIAINFOLIST_ASSIGN(GetI, "GetI")
369  MEDIAINFO_ASSIGN(Get, "Get")
370  MEDIAINFOLIST_ASSIGN(Get, "Get")
371  MEDIAINFO_ASSIGN(Output_Buffer_Get, "Output_Buffer_Get")
372  MEDIAINFO_ASSIGN(Output_Buffer_GetI, "Output_Buffer_GetI")
373  MEDIAINFO_ASSIGN(Option, "Option")
374  MEDIAINFOLIST_ASSIGN(Option, "Option")
375  MEDIAINFO_ASSIGN(State_Get, "State_Get")
376  MEDIAINFOLIST_ASSIGN(State_Get, "State_Get")
377  MEDIAINFO_ASSIGN(Count_Get, "Count_Get")
378  MEDIAINFOLIST_ASSIGN(Count_Get, "Count_Get")
379  MEDIAINFOLIST_ASSIGN(Count_Get_Files, "Count_Get_Files")
380  if (Errors > 0) {
381  // Unload DLL with errors
382  #ifdef MEDIAINFO_GLIBC
383  g_module_close(MediaInfo_Module);
384  #elif defined(_WIN32) || defined(WIN32)
385  FreeLibrary(MediaInfo_Module);
386  #else
387  dlclose(MediaInfo_Module);
388  #endif
389  MediaInfo_Module = NULL;
390  return (size_t) - 1;
391  }
392 
393  Module_Count++;
394  return (size_t)1;
395  }
396 
397  static size_t MediaInfoDLL_IsLoaded()
398  {
399  if (MediaInfo_Module)
400  return 1;
401  else
402  return 0;
403  }
404 
405  static void MediaInfoDLL_UnLoad()
406  {
407  Module_Count--;
408  if (Module_Count > 0)
409  return;
410 
411  #ifdef MEDIAINFO_GLIBC
412  g_module_close(MediaInfo_Module);
413  #elif defined(_WIN32) || defined(WIN32)
414  FreeLibrary(MediaInfo_Module);
415  #else
416  dlclose(MediaInfo_Module);
417  #endif
418  MediaInfo_Module = NULL;
419  }
420 
421 #ifdef __cplusplus
422 }
423 #endif /*__cplusplus*/
424 
425 /***************************************************************************/
426 /***************************************************************************/
427 /***************************************************************************/
428 
429 #ifdef __cplusplus
430 //DLL C++ wrapper for C functions
431 
432 //---------------------------------------------------------------------------
433 #include <string>
434 #include <sstream>
435 //---------------------------------------------------------------------------
436 
437 namespace MediaInfoDLL
438 {
439 
440  //---------------------------------------------------------------------------
441  //MediaInfo_Char types
442 #undef __T
443 #define __T(__x) __T(__x)
444 #if defined(UNICODE) || defined(_UNICODE)
445  typedef wchar_t Char;
446  #undef __T
447  #define __T(__x) L ## __x
448 #else
449  typedef char Char;
450  #undef __T
451  #define __T(__x) __x
452 #endif
453  typedef std::basic_string<Char> String;
454  typedef std::basic_stringstream<Char> StringStream;
455  typedef std::basic_istringstream<Char> iStringStream;
456  typedef std::basic_ostringstream<Char> oStringStream;
457  typedef std::basic_istringstream<Char> tiStringStream; // Legacy
458  typedef std::basic_ostringstream<Char> toStringStream; //Legacy
459  const size_t Error = (size_t)(-1);
460  //---------------------------------------------------------------------------
461 
462  //---------------------------------------------------------------------------
464  enum stream_t {
466  Stream_Video,
467  Stream_Audio,
468  Stream_Text,
469  Stream_Other,
470  Stream_Image,
471  Stream_Menu,
472  Stream_Max
473  };
474 
476  enum info_t {
477  Info_Name,
478  Info_Text,
479  Info_Measure,
480  Info_Options,
483  Info_Info,
484  Info_HowTo,
485  Info_Max
486  };
487 
492  enum infooptions_t {
494  InfoOption_Reserved,
497  InfoOption_Max
498  };
499 
501  enum fileoptions_t {
502  FileOption_Nothing = 0x00,
503  FileOption_NoRecursive = 0x01,
504  FileOption_CloseAll = 0x02,
505  FileOption_Max = 0x04
506  };
507 
508  const String Unable_Load_DLL = __T("Unable to load ")MEDIAINFODLL_NAME;
509 #define MEDIAINFO_TEST_VOID \
510  if (!IsReady()) return
511 #define MEDIAINFO_TEST_INT \
512  if (!IsReady()) return 0
513 #define MEDIAINFO_TEST_STRING \
514  if (!IsReady()) return Unable_Load_DLL
515 #define MEDIAINFO_TEST_STRING_STATIC \
516  if (!MediaInfo_Module) return Unable_Load_DLL
517 
518  //---------------------------------------------------------------------------
519  class MediaInfo
520  {
521  public :
522  MediaInfo() {if (!MediaInfo_Module) MediaInfoDLL_Load(); if (!MediaInfo_Module) {Handle = NULL; return;}; Handle = MediaInfo_New();};
523  ~MediaInfo() {MEDIAINFO_TEST_VOID; MediaInfo_Delete(Handle);};
524 
525  //File
526  size_t Open(const String &File) {MEDIAINFO_TEST_INT; return MediaInfo_Open(Handle, File.c_str());};
527  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);};
528  size_t Open_Buffer_Continue(MediaInfo_int8u* Buffer, size_t Buffer_Size) {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue(Handle, Buffer, Buffer_Size);};
529  MediaInfo_int64u Open_Buffer_Continue_GoTo_Get() {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue_GoTo_Get(Handle);};
530  size_t Open_Buffer_Finalize() {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Finalize(Handle);};
531  size_t Open_NextPacket() {MEDIAINFO_TEST_INT; return MediaInfo_Open_NextPacket(Handle);};
532  //size_t Save () {MEDIAINFO_TEST_INT; return MediaInfo_Save(Handle);};
533  void Close() {MEDIAINFO_TEST_VOID; return MediaInfo_Close(Handle);};
534 
535  //General information
536  String Inform() {MEDIAINFO_TEST_STRING; return MediaInfo_Inform(Handle, 0);};
537  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);};
538  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);};
539  //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());};
540  //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());};
541  size_t Output_Buffer_Get(const String &Value) {return MediaInfo_Output_Buffer_Get(Handle, Value.c_str());}
542  size_t Output_Buffer_Get(size_t Pos) {return MediaInfo_Output_Buffer_GetI(Handle, Pos);}
543  String Option(const String &Option, const String &Value = __T("")) {MEDIAINFO_TEST_STRING; return MediaInfo_Option(Handle, Option.c_str(), Value.c_str());};
544  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());};
545  size_t State_Get() {MEDIAINFO_TEST_INT; return MediaInfo_State_Get(Handle);};
546  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);};
547 
548  bool IsReady() {return (Handle && MediaInfo_Module) ? true : false;}
549 
550  private :
551  void* Handle;
552  };
553 
554  class MediaInfoList
555  {
556  public :
557  MediaInfoList() {MediaInfoDLL_Load(); if (!MediaInfoDLL_IsLoaded()) {Handle = NULL; return;}; Handle = MediaInfoList_New();};
558  ~MediaInfoList() {MEDIAINFO_TEST_VOID; MediaInfoList_Delete(Handle); MediaInfoDLL_UnLoad();};
559 
560  //File
561  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);};
562  //size_t Save (size_t FilePos) {MEDIAINFO_TEST_INT; return MediaInfoList_Save(Handle, FilePos);};
563  void Close(size_t FilePos = (size_t) - 1) {MEDIAINFO_TEST_VOID; return MediaInfoList_Close(Handle, FilePos);};
564 
565  //General information
566  String Inform(size_t FilePos = (size_t) - 1) {MEDIAINFO_TEST_STRING; return MediaInfoList_Inform(Handle, FilePos, 0);};
567  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);};
568  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);};
569  //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());};
570  //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());};
571  String Option(const String &Option, const String &Value = __T("")) {MEDIAINFO_TEST_STRING; return MediaInfoList_Option(Handle, Option.c_str(), Value.c_str());};
572  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());};
573  size_t State_Get() {MEDIAINFO_TEST_INT; return MediaInfoList_State_Get(Handle);};
574  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);};
575  size_t Count_Get() {MEDIAINFO_TEST_INT; return MediaInfoList_Count_Get_Files(Handle);};
576 
577  bool IsReady() {return (Handle && MediaInfo_Module) ? true : false;}
578 
579  private :
580  void* Handle;
581  };
582 
583 } //NameSpace
584 #endif /*__cplusplus*/
585 
586 #endif