MediaInfoLib: MediaInfoDLL.h Source File

MediaInfoLib 0.7

- Main Page
- Namespaces
- Classes
- Files

- File List

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 #ifdef __cplusplus
130 #include <new> //for size_t
131 #else /* __cplusplus */
132 #include <stddef.h> //for size_t
133 #endif /* __cplusplus */
134 #else
135 #define MEDIAINFODLL_NAME "libmediainfo.so.0"
136 #define __stdcall
137 #endif
138
139 /*-------------------------------------------------------------------------*/
140 /*Char types */
141 #undef __T
142 #define __T(__x) __T(__x)
143 #if defined(UNICODE) || defined(_UNICODE)
144 typedef wchar_t MediaInfo_Char;
145 #undef __T
146 #define __T(__x) L ## __x
147 #define MEDIAINFO_Ansi ""
148 #else
149 typedef char MediaInfo_Char;
150 #undef __T
151 #define __T(__x) __x
152 #define MEDIAINFO_Ansi "A"
153 #endif
154 /*-------------------------------------------------------------------------*/
155
156 /*-------------------------------------------------------------------------*/
157 /*8-bit int */
158 typedef unsigned char MediaInfo_int8u;
159 /*-------------------------------------------------------------------------*/
160
161 /*-------------------------------------------------------------------------*/
162 /*64-bit int */
163 #if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__) || defined(__MACOSX__)
164 #undef MAXTYPE_INT
165 #define MAXTYPE_INT 64
166 typedef unsigned long long MediaInfo_int64u;
167 #elif defined(__WIN32__) || defined(_WIN32)
168 #undef MAXTYPE_INT
169 #define MAXTYPE_INT 64
170 typedef unsigned __int64 MediaInfo_int64u;
171 #else
172 #pragma message This machine has no 64-bit integer type?
173 #endif
174 /*-------------------------------------------------------------------------*/
175
176 /*-------------------------------------------------------------------------*/
177 /*NULL */
178 #ifndef NULL
179 #define NULL 0
180 #endif
181 /*-------------------------------------------------------------------------*/
182
184 typedef enum MediaInfo_stream_t {
185 MediaInfo_Stream_General,
186 MediaInfo_Stream_Video,
187 MediaInfo_Stream_Audio,
188 MediaInfo_Stream_Text,
189 MediaInfo_Stream_Other,
190 MediaInfo_Stream_Image,
191 MediaInfo_Stream_Menu,
192 MediaInfo_Stream_Max
193 } MediaInfo_stream_C;
194
196 typedef enum MediaInfo_info_t {
197 MediaInfo_Info_Name,
198 MediaInfo_Info_Text,
199 MediaInfo_Info_Measure,
200 MediaInfo_Info_Options,
201 MediaInfo_Info_Name_Text,
202 MediaInfo_Info_Measure_Text,
203 MediaInfo_Info_Info,
204 MediaInfo_Info_HowTo,
205 MediaInfo_Info_Max
206 } MediaInfo_info_C;
207
209 typedef enum MediaInfo_infooptions_t {
210 MediaInfo_InfoOption_ShowInInform,
211 MediaInfo_InfoOption_Reserved,
212 MediaInfo_InfoOption_ShowInSupported,
213 MediaInfo_InfoOption_TypeOfValue,
214 MediaInfo_InfoOption_Max
215 } MediaInfo_infooptions_C;
216
218 typedef enum MediaInfo_fileoptions_t {
219 MediaInfo_FileOption_Nothing = 0x00,
220 MediaInfo_FileOption_NoRecursive = 0x01,
221 MediaInfo_FileOption_CloseAll = 0x02,
222 MediaInfo_FileOption_Max = 0x04
223 } MediaInfo_fileoptions_C;
224
225
226 #ifdef __cplusplus
227 extern "C"
228 {
229 #endif /* __cplusplus */
230
231 #ifdef MEDIAINFO_GLIBC
232 #include <gmodule.h>
233 static GModule* MediaInfo_Module = NULL;
234 #elif defined(_WIN32) || defined(WIN32)
235 #include <windows.h>
236 static HMODULE MediaInfo_Module = NULL;
237 #else
238 #ifdef MACOSX
239 #include <CoreFoundation/CFBundle.h>
240 #endif
241
242 #include <dlfcn.h>
243 static void* MediaInfo_Module = NULL;
244 #endif
245 static size_t Module_Count = 0;
246
247 #ifdef MEDIAINFO_GLIBC
248 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
249 if (!g_module_symbol (MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfo_##_Name)) \
250 Errors++;
251 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
252 if (!g_module_symbol (MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2, (gpointer*)&MediaInfoList_##_Name)) \
253 Errors++;
254 #elif defined(_WIN32) || defined(WIN32)
255 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
256 MediaInfo_##_Name=(MEDIAINFO_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \
257 if (MediaInfo_##_Name==NULL) Errors++;
258 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
259 MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)GetProcAddress(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \
260 if (MediaInfoList_##_Name==NULL) Errors++;
261 #else
262 #define MEDIAINFO_ASSIGN(_Name,_Name2) \
263 MediaInfo_##_Name=(MEDIAINFO_##_Name)dlsym(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \
264 if (MediaInfo_##_Name==NULL) Errors++;
265 #define MEDIAINFOLIST_ASSIGN(_Name,_Name2) \
266 MediaInfoList_##_Name=(MEDIAINFOLIST_##_Name)dlsym(MediaInfo_Module, "MediaInfoList" MEDIAINFO_Ansi "_" _Name2); \
267 if (MediaInfoList_##_Name==NULL) Errors++;
268 #endif
269
270 typedef void* (__stdcall *MEDIAINFO_New)();
271 static MEDIAINFO_New MediaInfo_New;
272 typedef void* (__stdcall *MEDIAINFOLIST_New)();
273 static MEDIAINFOLIST_New MediaInfoList_New;
274 typedef void (__stdcall *MEDIAINFO_Delete)(void*);
275 static MEDIAINFO_Delete MediaInfo_Delete;
276 typedef void (__stdcall *MEDIAINFOLIST_Delete)(void*);
277 static MEDIAINFOLIST_Delete MediaInfoList_Delete;
278 typedef size_t (__stdcall *MEDIAINFO_Open)(void*, const MediaInfo_Char*);
279 static MEDIAINFO_Open MediaInfo_Open;
280 typedef size_t (__stdcall *MEDIAINFOLIST_Open)(void*, const MediaInfo_Char*, const MediaInfo_fileoptions_C);
281 static MEDIAINFOLIST_Open MediaInfoList_Open;
282 typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Init)(void*, MediaInfo_int64u File_Size, MediaInfo_int64u File_Offset);
283 static MEDIAINFO_Open_Buffer_Init MediaInfo_Open_Buffer_Init;
284 typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Continue)(void*, MediaInfo_int8u* Buffer, size_t Buffer_Size);
285 static MEDIAINFO_Open_Buffer_Continue MediaInfo_Open_Buffer_Continue;
286 typedef MediaInfo_int64u(__stdcall *MEDIAINFO_Open_Buffer_Continue_GoTo_Get)(void*);
287 static MEDIAINFO_Open_Buffer_Continue_GoTo_Get MediaInfo_Open_Buffer_Continue_GoTo_Get;
288 typedef size_t (__stdcall *MEDIAINFO_Open_Buffer_Finalize)(void*);
289 static MEDIAINFO_Open_Buffer_Finalize MediaInfo_Open_Buffer_Finalize;
290 typedef size_t (__stdcall *MEDIAINFO_Open_NextPacket)(void*);
291 static MEDIAINFO_Open_NextPacket MediaInfo_Open_NextPacket;
292 typedef void (__stdcall *MEDIAINFO_Close)(void*);
293 static MEDIAINFO_Close MediaInfo_Close;
294 typedef void (__stdcall *MEDIAINFOLIST_Close)(void*, size_t);
295 static MEDIAINFOLIST_Close MediaInfoList_Close;
296 typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Inform)(void*, size_t Reserved);
297 static MEDIAINFO_Inform MediaInfo_Inform;
298 typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Inform)(void*, size_t, size_t Reserved);
299 static MEDIAINFOLIST_Inform MediaInfoList_Inform;
300 typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_GetI)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo);
301 static MEDIAINFO_GetI MediaInfo_GetI;
302 typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_GetI)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber, size_t Parameter, MediaInfo_info_C KindOfInfo);
303 static MEDIAINFOLIST_GetI MediaInfoList_GetI;
304 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);
305 static MEDIAINFO_Get MediaInfo_Get;
306 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);
307 static MEDIAINFOLIST_Get MediaInfoList_Get;
308 typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_Get)(void*, const MediaInfo_Char* Parameter);
309 static MEDIAINFO_Output_Buffer_Get MediaInfo_Output_Buffer_Get;
310 typedef size_t (__stdcall *MEDIAINFO_Output_Buffer_GetI)(void*, size_t Pos);
311 static MEDIAINFO_Output_Buffer_GetI MediaInfo_Output_Buffer_GetI;
312 typedef const MediaInfo_Char* (__stdcall *MEDIAINFO_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value);
313 static MEDIAINFO_Option MediaInfo_Option;
314 typedef const MediaInfo_Char* (__stdcall *MEDIAINFOLIST_Option)(void*, const MediaInfo_Char* Parameter, const MediaInfo_Char* Value);
315 static MEDIAINFOLIST_Option MediaInfoList_Option;
316 typedef size_t (__stdcall *MEDIAINFO_State_Get)(void*);
317 static MEDIAINFO_State_Get MediaInfo_State_Get;
318 typedef size_t (__stdcall *MEDIAINFOLIST_State_Get)(void*);
319 static MEDIAINFOLIST_State_Get MediaInfoList_State_Get;
320 typedef size_t (__stdcall *MEDIAINFO_Count_Get)(void*, MediaInfo_stream_C StreamKind, size_t StreamNumber);
321 static MEDIAINFO_Count_Get MediaInfo_Count_Get;
322 typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get)(void*, size_t, MediaInfo_stream_C StreamKind, size_t StreamNumber);
323 static MEDIAINFOLIST_Count_Get MediaInfoList_Count_Get;
324 typedef size_t (__stdcall *MEDIAINFO_Count_Get_Files)(void*);
325 static MEDIAINFO_Count_Get_Files MediaInfo_Count_Get_Files;
326 typedef size_t (__stdcall *MEDIAINFOLIST_Count_Get_Files)(void*);
327 static MEDIAINFOLIST_Count_Get_Files MediaInfoList_Count_Get_Files;
328
329 static size_t MediaInfoDLL_Load()
330 {
331 size_t Errors = 0;
332
333 if (Module_Count > 0) {
334 Module_Count++;
335 return 1;
336 }
337
338 /* Load library */
339 #ifdef MEDIAINFO_GLIBC
340 MediaInfo_Module = g_module_open(MEDIAINFODLL_NAME, G_MODULE_BIND_LAZY);
341 #elif defined(_WIN32) || defined(WIN32)
342 MediaInfo_Module = LoadLibrary(MEDIAINFODLL_NAME);
343 #else
344 #ifdef MACOSX
345 MediaInfo_Module = dlopen("@executable_path/" MEDIAINFODLL_NAME, RTLD_LAZY);
346 if (!MediaInfo_Module)
347 {
348 CFBundleRef mainBundle = CFBundleGetMainBundle();
349
350 // get full app path and delete app name
351 CFURLRef app_url = CFBundleCopyExecutableURL(mainBundle);
352 CFURLRef app_path_url = CFURLCreateCopyDeletingLastPathComponent(NULL, app_url);
353
354 CFStringRef app_path = CFURLCopyFileSystemPath(app_path_url, kCFURLPOSIXPathStyle);
355
356 CFMutableStringRef mut_app_path = CFStringCreateMutableCopy(NULL, NULL, app_path);
357 CFStringAppend(mut_app_path, CFSTR("/"));
358 CFStringAppend(mut_app_path, CFSTR(MEDIAINFODLL_NAME));
359 CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
360 const char *fullPath = CFStringGetCStringPtr(mut_app_path, encodingMethod);
361
362 MediaInfo_Module = dlopen(fullPath, RTLD_LAZY);
363
364 CFRelease(app_url);
365 CFRelease(app_path_url);
366 CFRelease(app_path);
367 CFRelease(mut_app_path);
368 }
369 #endif /* MACOSX*/
370
371 if (!MediaInfo_Module)
372 MediaInfo_Module = dlopen(MEDIAINFODLL_NAME, RTLD_LAZY);
373 if (!MediaInfo_Module)
374 MediaInfo_Module = dlopen("./" MEDIAINFODLL_NAME, RTLD_LAZY);
375 if (!MediaInfo_Module)
376 MediaInfo_Module = dlopen("/usr/local/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
377 if (!MediaInfo_Module)
378 MediaInfo_Module = dlopen("/usr/local/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
379 if (!MediaInfo_Module)
380 MediaInfo_Module = dlopen("/usr/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
381 if (!MediaInfo_Module)
382 MediaInfo_Module = dlopen("/usr/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
383 #endif
384 if (!MediaInfo_Module)
385 return (size_t) - 1;
386
387 /* Load methods */
388 MEDIAINFO_ASSIGN(New, "New")
389 MEDIAINFOLIST_ASSIGN(New, "New")
390 MEDIAINFO_ASSIGN(Delete, "Delete")
391 MEDIAINFOLIST_ASSIGN(Delete, "Delete")
392 MEDIAINFO_ASSIGN(Open, "Open")
393 MEDIAINFOLIST_ASSIGN(Open, "Open")
394 MEDIAINFO_ASSIGN(Open_Buffer_Init, "Open_Buffer_Init")
395 MEDIAINFO_ASSIGN(Open_Buffer_Continue, "Open_Buffer_Continue")
396 MEDIAINFO_ASSIGN(Open_Buffer_Continue_GoTo_Get, "Open_Buffer_Continue_GoTo_Get")
397 MEDIAINFO_ASSIGN(Open_Buffer_Finalize, "Open_Buffer_Finalize")
398 MEDIAINFO_ASSIGN(Open_NextPacket, "Open_NextPacket")
399 MEDIAINFO_ASSIGN(Close, "Close")
400 MEDIAINFOLIST_ASSIGN(Close, "Close")
401 MEDIAINFO_ASSIGN(Inform, "Inform")
402 MEDIAINFOLIST_ASSIGN(Inform, "Inform")
403 MEDIAINFO_ASSIGN(GetI, "GetI")
404 MEDIAINFOLIST_ASSIGN(GetI, "GetI")
405 MEDIAINFO_ASSIGN(Get, "Get")
406 MEDIAINFOLIST_ASSIGN(Get, "Get")
407 MEDIAINFO_ASSIGN(Output_Buffer_Get, "Output_Buffer_Get")
408 MEDIAINFO_ASSIGN(Output_Buffer_GetI, "Output_Buffer_GetI")
409 MEDIAINFO_ASSIGN(Option, "Option")
410 MEDIAINFOLIST_ASSIGN(Option, "Option")
411 MEDIAINFO_ASSIGN(State_Get, "State_Get")
412 MEDIAINFOLIST_ASSIGN(State_Get, "State_Get")
413 MEDIAINFO_ASSIGN(Count_Get, "Count_Get")
414 MEDIAINFOLIST_ASSIGN(Count_Get, "Count_Get")
415 MEDIAINFOLIST_ASSIGN(Count_Get_Files, "Count_Get_Files")
416 if (Errors > 0) {
417 // Unload DLL with errors
418 #ifdef MEDIAINFO_GLIBC
419 g_module_close(MediaInfo_Module);
420 #elif defined(_WIN32) || defined(WIN32)
421 FreeLibrary(MediaInfo_Module);
422 #else
423 dlclose(MediaInfo_Module);
424 #endif
425 MediaInfo_Module = NULL;
426 return (size_t) - 1;
427 }
428
429 Module_Count++;
430 return (size_t)1;
431 }
432
433 static size_t MediaInfoDLL_IsLoaded()
434 {
435 if (MediaInfo_Module)
436 return 1;
437 else
438 return 0;
439 }
440
441 static void MediaInfoDLL_UnLoad()
442 {
443 Module_Count--;
444 if (Module_Count > 0)
445 return;
446
447 #ifdef MEDIAINFO_GLIBC
448 g_module_close(MediaInfo_Module);
449 #elif defined(_WIN32) || defined(WIN32)
450 FreeLibrary(MediaInfo_Module);
451 #else
452 dlclose(MediaInfo_Module);
453 #endif
454 MediaInfo_Module = NULL;
455 }
456
457 #ifdef __cplusplus
458 }
459 #endif /*__cplusplus*/
460
461 /***************************************************************************/
462 /***************************************************************************/
463 /***************************************************************************/
464
465 #ifdef __cplusplus
466 //DLL C++ wrapper for C functions
467
468 //---------------------------------------------------------------------------
469 #include <string>
470 #include <sstream>
471 //---------------------------------------------------------------------------
472
473 namespace MediaInfoDLL
474 {
475
476 //---------------------------------------------------------------------------
477 //MediaInfo_Char types
478 #undef __T
479 #define __T(__x) __T(__x)
480 #if defined(UNICODE) || defined(_UNICODE)
481 typedef wchar_t Char;
482 #undef __T
483 #define __T(__x) L ## __x
484 #else
485 typedef char Char;
486 #undef __T
487 #define __T(__x) __x
488 #endif
489 typedef std::basic_string<Char> String;
490 typedef std::basic_stringstream<Char> StringStream;
491 typedef std::basic_istringstream<Char> iStringStream;
492 typedef std::basic_ostringstream<Char> oStringStream;
493 typedef std::basic_istringstream<Char> tiStringStream; // Legacy
494 typedef std::basic_ostringstream<Char> toStringStream; //Legacy
495 const size_t Error = (size_t)(-1);
496 //---------------------------------------------------------------------------
497
498 //---------------------------------------------------------------------------
500 enum stream_t {
501 Stream_General,
502 Stream_Video,
503 Stream_Audio,
504 Stream_Text,
505 Stream_Other,
506 Stream_Image,
507 Stream_Menu,
508 Stream_Max
509 };
510
512 enum info_t {
513 Info_Name,
514 Info_Text,
515 Info_Measure,
516 Info_Options,
517 Info_Name_Text,
518 Info_Measure_Text,
519 Info_Info,
520 Info_HowTo,
521 Info_Max
522 };
523
528 enum infooptions_t {
529 InfoOption_ShowInInform,
530 InfoOption_Reserved,
531 InfoOption_ShowInSupported,
532 InfoOption_TypeOfValue,
533 InfoOption_Max
534 };
535
537 enum fileoptions_t {
538 FileOption_Nothing = 0x00,
539 FileOption_NoRecursive = 0x01,
540 FileOption_CloseAll = 0x02,
541 FileOption_Max = 0x04
542 };
543
544 const String Unable_Load_DLL = __T("Unable to load ")MEDIAINFODLL_NAME;
545 #define MEDIAINFO_TEST_VOID \
546 if (!MediaInfo_Module) {MediaInfoDLL_Load(); if (!MediaInfo_Module) return;}
547 #define MEDIAINFO_TEST_INT \
548 if (!MediaInfo_Module) {MediaInfoDLL_Load(); if (!MediaInfo_Module) return 0;}
549 #define MEDIAINFO_TEST_STRING \
550 if (!MediaInfo_Module) {MediaInfoDLL_Load(); if (!MediaInfo_Module) return Unable_Load_DLL;}
551 #define MEDIAINFO_TEST_STRING_STATIC \
552 if (!MediaInfo_Module) {MediaInfoDLL_Load(); if (!MediaInfo_Module) return Unable_Load_DLL;}
553
554 //---------------------------------------------------------------------------
555 class MediaInfo
556 {
557 public :
558 MediaInfo() {if (!MediaInfo_Module) MediaInfoDLL_Load(); if (!MediaInfo_Module) {Handle = NULL; return;}; Handle = MediaInfo_New();};
559 ~MediaInfo() {MEDIAINFO_TEST_VOID; MediaInfo_Delete(Handle);};
560
561 //File
562 size_t Open(const String &File) {MEDIAINFO_TEST_INT; return MediaInfo_Open(Handle, File.c_str());};
563 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);};
564 size_t Open_Buffer_Continue(MediaInfo_int8u* Buffer, size_t Buffer_Size) {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue(Handle, Buffer, Buffer_Size);};
565 MediaInfo_int64u Open_Buffer_Continue_GoTo_Get() {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Continue_GoTo_Get(Handle);};
566 size_t Open_Buffer_Finalize() {MEDIAINFO_TEST_INT; return MediaInfo_Open_Buffer_Finalize(Handle);};
567 size_t Open_NextPacket() {MEDIAINFO_TEST_INT; return MediaInfo_Open_NextPacket(Handle);};
568 //size_t Save () {MEDIAINFO_TEST_INT; return MediaInfo_Save(Handle);};
569 void Close() {MEDIAINFO_TEST_VOID; return MediaInfo_Close(Handle);};
570
571 //General information
572 String Inform() {MEDIAINFO_TEST_STRING; return MediaInfo_Inform(Handle, 0);};
573 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);};
574 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);};
575 //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());};
576 //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());};
577 size_t Output_Buffer_Get(const String &Value) {return MediaInfo_Output_Buffer_Get(Handle, Value.c_str());}
578 size_t Output_Buffer_Get(size_t Pos) {return MediaInfo_Output_Buffer_GetI(Handle, Pos);}
579 String Option(const String &Option, const String &Value = __T("")) {MEDIAINFO_TEST_STRING; return MediaInfo_Option(Handle, Option.c_str(), Value.c_str());};
580 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());};
581 size_t State_Get() {MEDIAINFO_TEST_INT; return MediaInfo_State_Get(Handle);};
582 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);};
583
584 bool IsReady() {return (Handle && MediaInfo_Module) ? true : false;}
585
586 private :
587 void* Handle;
588 };
589
590 class MediaInfoList
591 {
592 public :
593 MediaInfoList() {MediaInfoDLL_Load(); if (!MediaInfoDLL_IsLoaded()) {Handle = NULL; return;}; Handle = MediaInfoList_New();};
594 ~MediaInfoList() {MEDIAINFO_TEST_VOID; MediaInfoList_Delete(Handle); MediaInfoDLL_UnLoad();};
595
596 //File
597 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);};
598 //size_t Save (size_t FilePos) {MEDIAINFO_TEST_INT; return MediaInfoList_Save(Handle, FilePos);};
599 void Close(size_t FilePos = (size_t) - 1) {MEDIAINFO_TEST_VOID; return MediaInfoList_Close(Handle, FilePos);};
600
601 //General information
602 String Inform(size_t FilePos = (size_t) - 1) {MEDIAINFO_TEST_STRING; return MediaInfoList_Inform(Handle, FilePos, 0);};
603 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);};
604 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);};
605 //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());};
606 //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());};
607 String Option(const String &Option, const String &Value = __T("")) {MEDIAINFO_TEST_STRING; return MediaInfoList_Option(Handle, Option.c_str(), Value.c_str());};
608 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());};
609 size_t State_Get() {MEDIAINFO_TEST_INT; return MediaInfoList_State_Get(Handle);};
610 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);};
611 size_t Count_Get() {MEDIAINFO_TEST_INT; return MediaInfoList_Count_Get_Files(Handle);};
612
613 bool IsReady() {return (Handle && MediaInfo_Module) ? true : false;}
614
615 private :
616 void* Handle;
617 };
618
619 } //NameSpace
620 #endif /*__cplusplus*/
621
622 #endif
MediaInfoLib::FileOption_NoRecursive
Do not browse folders recursively.
Definition: MediaInfo_Const.h:105
MediaInfoLib::FileOption_CloseAll
Close all files before open.
Definition: MediaInfo_Const.h:106
MediaInfoLib::Info_Name
InfoKind = Unique name of parameter.
Definition: MediaInfo_Const.h:75
MediaInfoLib::Info_Name_Text
InfoKind = Translated name of parameter.
Definition: MediaInfo_Const.h:79
MediaInfoLib::Stream_Text
StreamKind = Text.
Definition: MediaInfo_Const.h:65
MediaInfoLib::String
std::basic_string< MediaInfoLib::Char > String
Unicode/Ansi independant string.
Definition: MediaInfo_Const.h:125
MediaInfoLib::Stream_Other
StreamKind = Chapters.
Definition: MediaInfo_Const.h:66
MediaInfoLib::Stream_Menu
StreamKind = Menu.
Definition: MediaInfo_Const.h:68
MediaInfoLib::Info_Options
InfoKind = See infooptions_t.
Definition: MediaInfo_Const.h:78
MediaInfoLib::InfoOption_ShowInInform
Show this parameter in Inform()
Definition: MediaInfo_Const.h:93
MediaInfoLib::Info_Measure_Text
InfoKind = Translated name of measure unit.
Definition: MediaInfo_Const.h:80
MediaInfoLib::Info_HowTo
InfoKind = How this parameter is supported, could be N (No), B (Beta), R (Read only), W (Read/Write)
Definition: MediaInfo_Const.h:82
MediaInfoLib::StringStream
std::basic_stringstream< MediaInfoLib::Char > StringStream
Unicode/Ansi independant stringstream.
Definition: MediaInfo_Const.h:126
MediaInfoLib::Stream_General
StreamKind = General.
Definition: MediaInfo_Const.h:62
MediaInfoLib::InfoOption_ShowInSupported
Internal use only (info : Must be showed in Info_Capacities() )
Definition: MediaInfo_Const.h:95
MediaInfoLib::info_t
info_t
Kind of information.
Definition: MediaInfo_Const.h:73
MediaInfoLib::InfoOption_TypeOfValue
Value return by a standard Get() can be : T (Text), I (Integer, warning up to 64 bits), F (Float), D (Date), B (Binary datas coded Base64) (Numbers are in Base 10)
Definition: MediaInfo_Const.h:96
MediaInfoLib::fileoptions_t
fileoptions_t
File opening options.
Definition: MediaInfo_Const.h:102
MediaInfoLib::stream_t
stream_t
Kinds of Stream.
Definition: MediaInfo_Const.h:60
MediaInfoLib::Stream_Audio
StreamKind = Audio.
Definition: MediaInfo_Const.h:64
MediaInfoLib::Info_Measure
InfoKind = Unique name of measure unit of parameter.
Definition: MediaInfo_Const.h:77
MediaInfoLib::Stream_Image
StreamKind = Image.
Definition: MediaInfo_Const.h:67
MediaInfoLib::tiStringStream
std::basic_istringstream< MediaInfoLib::Char > tiStringStream
Unicode/Ansi independant istringstream.
Definition: MediaInfo_Const.h:127
MediaInfoLib::toStringStream
std::basic_ostringstream< MediaInfoLib::Char > toStringStream
Unicode/Ansi independant ostringstream.
Definition: MediaInfo_Const.h:128
MediaInfoLib::Char
char Char
Unicode/Ansi independant char.
Definition: MediaInfo_Const.h:121
MediaInfoLib::Stream_Video
StreamKind = Video.
Definition: MediaInfo_Const.h:63
MediaInfoLib::infooptions_t
infooptions_t
Option if InfoKind = Info_Options.
Definition: MediaInfo_Const.h:91
MediaInfoLib::Info_Text
InfoKind = Value of parameter.
Definition: MediaInfo_Const.h:76
MediaInfoLib::Info_Info
InfoKind = More information about the parameter.
Definition: MediaInfo_Const.h:81